FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
zipnode.h
1 /***************************************************************************
2 * Copyright (C) 2005-2008 by the FIFE team *
3 * http://www.fifengine.de *
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 
53  uint16_t comp;
54  uint32_t crc32;
55  uint32_t size_comp;
56  uint32_t size_real;
57  uint32_t offset;
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 
88  ZipContentType::Enum getContentType() const;
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;
153  ZipContentType::Enum m_contentType;
154  ZipEntryData m_entryData;
155 
156  ZipNode* m_parent;
157  ZipNodeContainer m_fileChildren;
158  ZipNodeContainer m_directoryChildren;
159  };
160 }
161 
168 std::ostream& operator<<(std::ostream& os, const FIFE::ZipNode& node);
169 
170 #endif
std::ostream & operator<<(std::ostream &os, const Location &l)
Definition: location.cpp:164