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 class C4Reloc
20 {
21 public:
22  enum PathType
23  {
26  };
27  struct PathInfo
28  {
31  PathInfo(const StdCopyStrBuf buf, PathType pathType): strBuf(buf), pathType(pathType) {}
32  bool operator==(const PathInfo&other) {return pathType==other.pathType && strBuf==other.strBuf;}
33  operator const char*() {return strBuf.getData();}
34  };
35  typedef std::vector<PathInfo> PathList;
36  typedef PathList::const_iterator iterator;
37 
38  // Can also be used for re-init, drops custom paths added with AddPath.
39  // Make sure to call after Config.Load.
40  void Init();
41 
42  bool AddPath(const char* path, PathType pathType = PATH_Regular);
43 
44  iterator begin() const;
45  iterator end() const;
46 
47  bool Open(C4Group& hGroup, const char* filename) const;
48  bool LocateItem(const char* filename, StdStrBuf& str) const;
49 private:
50  PathList Paths;
51 };
52 
53 extern C4Reloc Reloc;
54 
55 #endif // C4RELOC_H
const char * getData() const
Definition: StdBuf.h:442
C4Reloc Reloc
Definition: C4Reloc.cpp:21
PathList::const_iterator iterator
Definition: C4Reloc.h:36
PathInfo(const StdCopyStrBuf buf, PathType pathType)
Definition: C4Reloc.h:31
bool Open(C4Group &hGroup, const char *filename) const
Definition: C4Reloc.cpp:68
bool operator==(const PathInfo &other)
Definition: C4Reloc.h:32
PathType pathType
Definition: C4Reloc.h:30
iterator begin() const
Definition: C4Reloc.cpp:58
void Init()
Definition: C4Reloc.cpp:23
bool AddPath(const char *path, PathType pathType=PATH_Regular)
Definition: C4Reloc.cpp:46
iterator end() const
Definition: C4Reloc.cpp:63
std::vector< PathInfo > PathList
Definition: C4Reloc.h:35
StdCopyStrBuf strBuf
Definition: C4Reloc.h:29
PathType
Definition: C4Reloc.h:22
bool LocateItem(const char *filename, StdStrBuf &str) const
Definition: C4Reloc.cpp:79