OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4Reloc.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2011-2016, The OpenClonk Team and contributors
5  *
6  * Distributed under the terms of the ISC license; see accompanying file
7  * "COPYING" for details.
8  *
9  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
10  * See accompanying file "TRADEMARK" for details.
11  *
12  * To redistribute this file separately, substitute the full license texts
13  * for the above references.
14  */
15 
16 #ifndef C4RELOC_H
17 #define C4RELOC_H
18 
19 #include <vector>
20 
21 class C4Reloc
22 {
23 public:
24  enum PathType
25  {
28  };
29  struct PathInfo
30  {
33  PathInfo(const StdCopyStrBuf buf, PathType pathType): strBuf(buf), pathType(pathType) {}
34  bool operator==(const PathInfo&other) {return pathType==other.pathType && strBuf==other.strBuf;}
35  operator const char*() {return strBuf.getData();}
36  };
37  typedef std::vector<PathInfo> PathList;
38  typedef PathList::const_iterator iterator;
39 
40  // Can also be used for re-init, drops custom paths added with AddPath.
41  // Make sure to call after Config.Load.
42  void Init();
43 
44  bool AddPath(const char* path, PathType pathType = PATH_Regular);
45 
46  iterator begin() const;
47  iterator end() const;
48 
49  bool Open(C4Group& hGroup, const char* filename) const;
50  bool LocateItem(const char* filename, StdStrBuf& str) const;
51 private:
52  PathList Paths;
53 };
54 
55 extern C4Reloc Reloc;
56 
57 #endif // C4RELOC_H
const char * getData() const
Definition: StdBuf.h:450
C4Reloc Reloc
Definition: C4Reloc.cpp:22
PathList::const_iterator iterator
Definition: C4Reloc.h:38
PathInfo(const StdCopyStrBuf buf, PathType pathType)
Definition: C4Reloc.h:33
bool Open(C4Group &hGroup, const char *filename) const
Definition: C4Reloc.cpp:69
bool operator==(const PathInfo &other)
Definition: C4Reloc.h:34
PathType pathType
Definition: C4Reloc.h:32
iterator begin() const
Definition: C4Reloc.cpp:59
void Init()
Definition: C4Reloc.cpp:24
bool AddPath(const char *path, PathType pathType=PATH_Regular)
Definition: C4Reloc.cpp:47
iterator end() const
Definition: C4Reloc.cpp:64
std::vector< PathInfo > PathList
Definition: C4Reloc.h:37
StdCopyStrBuf strBuf
Definition: C4Reloc.h:31
PathType
Definition: C4Reloc.h:24
bool LocateItem(const char *filename, StdStrBuf &str) const
Definition: C4Reloc.cpp:80