FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
zipnode.h
Go to the documentation of this file.
1 /***************************************************************************
2 * Copyright (C) 2005-2019 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 
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;
155 
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::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
uint32_t size_comp
Definition: zipnode.h:55
ZipEntryData m_entryData
Definition: zipnode.h:154
Definition: zipnode.h:48
std::ostream & operator<<(std::ostream &os, const Location &l)
Stream output operator.
Definition: location.cpp:164
uint16_t comp
Definition: zipnode.h:53
uint32_t offset
Definition: zipnode.h:57
unsigned short uint16_t
Definition: core.h:39
ZipNodeContainer m_directoryChildren
Definition: zipnode.h:158
ZipNode * m_parent
Definition: zipnode.h:156
ZipNodeContainer m_fileChildren
Definition: zipnode.h:157
unsigned int uint32_t
Definition: core.h:40
ZipContentType::Enum m_contentType
Definition: zipnode.h:153