cbp2make
Makefile generation tool for Code::Blocks IDE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
platforms.h
Go to the documentation of this file.
1 /*
2  cbp2make : Makefile generation tool for the Code::Blocks IDE
3  Copyright (C) 2010-2013 Mirai Computing (mirai.computing@gmail.com)
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 //------------------------------------------------------------------------------
20 #ifndef PLATFORMS_H
21 #define PLATFORMS_H
22 //------------------------------------------------------------------------------
23 #include "stlstrings.h"
24 #include "cbhelper.h"
25 //------------------------------------------------------------------------------
26 
27 static const CString STR_UNIX = "Unix";
28 static const CString STR_WINDOWS = "Windows";
29 static const CString STR_MAC = "Mac";
30 
31 class TiXmlElement;
32 class CPlatformSet;
33 
34 class CPlatform
35 {
36  public:
37  enum OS_Type
38  {
44  };
45  private:
46  bool m_Active;
53  //CString m_Cmd_TestFile;
56  //CString m_Cmd_TestDir;
65  //
68  //CString m_;
69  public:
70  static CString Name(const OS_Type PlatformOS);
71  static OS_Type OS(CString& PlatformName);
72  bool& Active(void) { return m_Active; }
73  OS_Type OS(void) const { return m_OS_Type; }
74  CString Name(void);
75  CString& Cmd_Copy(void) { return m_Cmd_Copy; }
76  CString& Cmd_Move(void) { return m_Cmd_Move; }
77  CString& Cmd_Make(void) { return m_Cmd_Make; }
78  CString& Tool_Make(void) { return m_Tool_Make; }
79  //CString& Cmd_TestFile(void) { return m_Cmd_TestFile; }
82  //CString& Cmd_TestDir(void) { return m_Cmd_TestDir; }
83  CString& Cmd_MakeDir(void) { return m_Cmd_MakeDir; }
90  char Pd(void) const { return m_PathDelimiter; }
91  CString Pd(const CString& Path) const;
92  CString SpecialChars(void) const;
93  CString ProtectPath(const CString& Path, const int QuoteMode = QUOTE_AUTO);
94  CString Copy(const CString& Source, const CString& Destination) const;
95  CString Move(const CString& Source, const CString& Destination) const;
96  CString Make(const CString& Options, const CString& Path) const;
97  CString RemoveFile(const CString& Path) const;
98  CString ForceRemoveFile(const CString& Path) const;
99  CString MakeDir(const CString& Path) const;
100  CString TestMakeDir(const CString& Path) const;
101  CString ForceMakeDir(const CString& Path) const;
102  CString RemoveDir(const CString& Path) const;
103  CString PrintWorkDir(void) const;
104  CString EvalWorkDir(void) const;
105  CString ChangeDir(const CString& Path) const;
106  CString MakefileCmd(const CString& Command) const;
107  //
108  bool IsStaticLibraryExtension(const CString& Ext) const;
109  bool IsDynamicLibraryExtension(const CString& Ext) const;
110  //CString (void) const { return m_; }
111  private:
112  void Read(const TiXmlElement *Root, const CString& Name, CString& Value);
113  void Write(TiXmlElement *Root, const CString& Name, const CString& Value);
114  public:
115  void Assign(const CPlatform& Platform);
116  void Clear(void);
117  void Reset(const CPlatform::OS_Type OS);
118  void Read(const TiXmlElement *PlatformRoot);
119  void Write(TiXmlElement *PlatformRoot);
120  void Show(void);
121  CPlatform& operator =(const CPlatform& Platform);
122  public:
123  CPlatform(void);
124  CPlatform(const CPlatform& Platform);
125  ~CPlatform(void);
126 };
127 
129 {
130  private:
131  std::vector<CPlatform *> m_Platforms;
132  bool m_Locked;
133  public:
134  void Lock(void);
135  void Unlock(void);
136  void Clear(void);
137  size_t GetCount(void) const;
138  CPlatform *Platform(const size_t Index) const;
139  CPlatform *Find(const CPlatform::OS_Type OS);
140  void AddDefault(void);
141  //CPlatform *Add(const CPlatform::OS_Type OS);
142  //void Remove(const CPlatform::OS_Type OS);
143  void Read(const TiXmlElement *ConfigRoot);
144  void Write(TiXmlElement *ConfigRoot);
145  //bool Load(const CString& FileName);
146  //bool Save(const CString& FileName);
147  void Show(void);
148  public:
149  CPlatformSet(void);
150  ~CPlatformSet(void);
151 };
152 
153 #endif
154 //------------------------------------------------------------------------------