My Project
FilePath.h
1 #pragma once
2 #include <list>
3 #include <vector>
4 #include <string>
5 #include "IAttributeFields.h"
6 
7 namespace ParaEngine
8 {
11  {
12  public:
13  CPathVariable();
14  CPathVariable(const std::string& sVarName, const std::string& sVarValue);
15  CPathVariable(const std::string& sVarName, const std::string& sVarValue, bool bEditable, bool bEnableEncoding = true);
16  public:
18  std::string m_sVarName;
20  std::string m_sVarValue;
25  };
26 
34  {
35  public:
38  static CPathReplaceables& GetSingleton();
39  public:
47  void DecodePath(std::string& output, const std::string& input);
48 
54  void EncodePath(std::string& output, const std::string& input);
55 
60  void EncodePath(std::string& output, const std::string& input, const std::string& varNames);
61 
68  bool AddVariable(const CPathVariable& variable, bool bCheckCanEdit = true);
69 
71  CPathVariable * GetVariable(const char* sVarName);
72 
79  bool RemoveVariable(const char* sVarName, bool bCheckCanEdit);
80 
82  bool Clear();
83 
84  private:
85  std::vector <CPathVariable> m_variables;
86  };
87 
89  struct SearchPath
90  {
91  public:
92  SearchPath() :m_nPriority(0){};
93  SearchPath(const char* searchpath) : m_searchpath(searchpath), m_nPriority(0){};
94  SearchPath(const char* searchpath, int nPriority) : m_searchpath(searchpath), m_nPriority(nPriority){};
95 
96  bool operator==(const SearchPath& left){ return m_searchpath == left.m_searchpath; }
97  bool operator==(const std::string& left){ return m_searchpath == left; }
98 
99  std::string& GetPath(){ return m_searchpath; }
100  public:
101  std::string m_searchpath;
102  int m_nPriority;
103  };
104 
107  {
108  protected:
110  std::list <SearchPath> m_searchpaths;
111  public:
113  bool AddDiskSearchPath(const std::string& sFile, bool nFront = false);
114 
120  PE_CORE_DECL bool AddSearchPath(const char* sFile, int nPriority = 0);
124  PE_CORE_DECL bool RemoveSearchPath(const char* sFile);
128  PE_CORE_DECL bool ClearAllSearchPath();
129 
133  std::list <SearchPath>& GetSearchPaths(){ return m_searchpaths; }
134  };
135 
136 }
std::string m_sVarName
variable name
Definition: FilePath.h:18
bool m_bEnableEncoding
whether this is used during encoding.
Definition: FilePath.h:24
a search path.
Definition: FilePath.h:89
different physics engine has different winding order.
Definition: EventBinding.h:32
std::string m_sVarValue
to which string value this variable is mapped to.
Definition: FilePath.h:20
search path manager interface and implementation.
Definition: FilePath.h:106
A common interface for all classes implementing IAttributeFields By implementing this class&#39;s virtual...
Definition: IAttributeFields.h:59
replacing some known variables in string path.
Definition: FilePath.h:33
std::list< SearchPath > m_searchpaths
a list of all search paths
Definition: FilePath.h:110
bool m_bEditable
whether this variable can be replaced or overridden from scripting interface.
Definition: FilePath.h:22
a single path variable
Definition: FilePath.h:10
Definition: tool_writeout.c:63
std::list< SearchPath > & GetSearchPaths()
this function is used mostly internally.
Definition: FilePath.h:133