FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
zipnode.h
Go to the documentation of this file.
1 /***************************************************************************
2 * Copyright (C) 2005-2013 by the FIFE team *
3 * http://www.fifengine.net *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or *
7 * modify it under the terms of the GNU Lesser General Public *
8 * License as published by the Free Software Foundation; either *
9 * version 2.1 of the License, or (at your option) any later version. *
10 * *
11 * This library is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21 #ifndef FIFE_VFS_ZIP_ZIPNODE_H
22 #define FIFE_VFS_ZIP_ZIPNODE_H
23 
24 // Standard C++ library includes
25 #include <string>
26 #include <vector>
27 #include <ostream>
28 
29 // 3rd party library includes
30 
31 // FIFE includes
32 // These includes are split up in two parts, separated by one empty line
33 // First block: files included from the FIFE root src directory
34 // Second block: files included from the same folder
35 #include "util/base/fife_stdint.h"
36 
37 namespace FIFE {
38 
39  struct ZipContentType {
40  enum Enum
41  {
42  File = 0, // specifies files as content type
43  Directory, // specifies directories as content type
44  All // specifies everything as content type (no filter)
45  };
46  };
47 
48  struct ZipEntryData {
51  ZipEntryData();
52 
58  };
59 
60  // convenience typedef
61  class ZipNode;
62  typedef std::vector<ZipNode*> ZipNodeContainer;
63 
64  class ZipNode {
65  public:
70  ZipNode(const std::string& name, ZipNode* parent=0);
71 
74  ~ZipNode();
75 
79  std::string getName() const;
80 
83  std::string getFullName() const;
84 
89 
93  ZipNode* getParent() const;
94 
100  std::vector<ZipNode*> getChildren(ZipContentType::Enum contentType=ZipContentType::All) const;
101 
107  ZipNode* getChild(const std::string& name,
108  ZipContentType::Enum contentType=ZipContentType::All) const;
109 
115  ZipNode* addChild(const std::string& child);
116 
120  void removeChild(ZipNode* child);
121 
125  void removeChild(const std::string& name);
126 
131  bool isLeaf() const;
132 
137  bool isBranch() const;
138 
143  void setZipEntryData(const ZipEntryData& entryData);
144 
149  const ZipEntryData& getZipEntryData() const;
150 
151  private:
152  std::string m_name;
155 
159  };
160 }
161 
168 std::ostream& operator<<(std::ostream& os, const FIFE::ZipNode& node);
169 
170 #endif
std::string m_name
Definition: zipnode.h:152
uint32_t size_real
Definition: zipnode.h:56
std::vector< ZipNode * > ZipNodeContainer
Definition: zipnode.h:61
uint32_t crc32
Definition: zipnode.h:54
bool isBranch() const
accessor for checking if this node has children
Definition: zipnode.cpp:235
std::vector< ZipNode * > getChildren(ZipContentType::Enum contentType=ZipContentType::All) const
gives access to retrieve the children of this node
Definition: zipnode.cpp:122
ZipContentType::Enum getContentType() const
accessor for the content type of this node
Definition: zipnode.cpp:114
uint32_t size_comp
Definition: zipnode.h:55
ZipEntryData m_entryData
Definition: zipnode.h:154
std::string getName() const
accessor for the name of this node
Definition: zipnode.cpp:95
ZipEntryData()
constructor
Definition: zipnode.cpp:63
Definition: zipnode.h:48
~ZipNode()
destructor
Definition: zipnode.cpp:82
std::ostream & operator<<(std::ostream &os, const Location &l)
Stream output operator.
Definition: location.cpp:164
uint16_t comp
Definition: zipnode.h:53
void removeChild(ZipNode *child)
allows removing a child from this node
Definition: zipnode.cpp:197
uint32_t offset
Definition: zipnode.h:57
unsigned short uint16_t
Definition: core.h:39
ZipNodeContainer m_directoryChildren
Definition: zipnode.h:158
ZipNode * getChild(const std::string &name, ZipContentType::Enum contentType=ZipContentType::All) const
gives access to retrieving a specific child node by name
Definition: zipnode.cpp:146
ZipNode(const std::string &name, ZipNode *parent=0)
constructor for creating a node
Definition: zipnode.cpp:67
ZipNode * addChild(const std::string &child)
allows adding a child node to this node
Definition: zipnode.cpp:180
ZipNode * getParent() const
accessor for the parent node of this node will be NULL if this node has no parent ...
Definition: zipnode.cpp:118
std::string getFullName() const
accessor for the absolute path name of this node
Definition: zipnode.cpp:99
ZipNode * m_parent
Definition: zipnode.h:156
void setZipEntryData(const ZipEntryData &entryData)
sets the zip file entry information for this node in the zip archive
Definition: zipnode.cpp:240
ZipNodeContainer m_fileChildren
Definition: zipnode.h:157
unsigned int uint32_t
Definition: core.h:40
bool isLeaf() const
accessor for checking if this node has any children
Definition: zipnode.cpp:230
const ZipEntryData & getZipEntryData() const
accessor for the entry data associated with this node in the zip archive
Definition: zipnode.cpp:245
ZipContentType::Enum m_contentType
Definition: zipnode.h:153