Code::Blocks  SVN r11506
projectloader.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Code::Blocks IDE and licensed under the GNU Lesser General Public License, version 3
3  * http://www.gnu.org/licenses/lgpl-3.0.html
4  */
5 
6 #ifndef PROJECTLOADER_H
7 #define PROJECTLOADER_H
8 
9 #include <wx/hashmap.h>
10 #include "ibaseloader.h"
11 
12 #define PROJECT_FILE_VERSION_MAJOR 1
13 #define PROJECT_FILE_VERSION_MINOR 6
14 
15 class cbProject;
16 class ProjectBuildTarget;
17 class ProjectFile;
18 
19 WX_DECLARE_STRING_HASH_MAP(wxString, CompilerSubstitutes);
20 
23 {
24  public:
27  ProjectLoader(cbProject* project);
29  ~ProjectLoader() override;
30 
34  bool Open(const wxString& filename) override;
35 
39  bool Save(const wxString& filename) override;
40 
47  bool Open(const wxString& filename, TiXmlElement** ppExtensions);
48 
55  bool Save(const wxString& filename, TiXmlElement* pExtensions);
56 
64  bool ExportTargetAsProject(const wxString& filename, const wxString& onlyTarget, TiXmlElement* pExtensions);
65 
67  bool FileUpgraded(){ return m_Upgraded; }
68 
70  bool FileModified(){ return m_OpenDirty; }
71  protected:
72  void DoProjectOptions(TiXmlElement* parentNode);
73  void DoCompilerOptions(TiXmlElement* parentNode, ProjectBuildTarget* target = nullptr);
74  void DoResourceCompilerOptions(TiXmlElement* parentNode, ProjectBuildTarget* target = nullptr);
75  void DoLinkerOptions(TiXmlElement* parentNode, ProjectBuildTarget* target = nullptr);
76  void DoIncludesOptions(TiXmlElement* parentNode, ProjectBuildTarget* target = nullptr);
77  void DoLibsOptions(TiXmlElement* parentNode, ProjectBuildTarget* target = nullptr);
78  void DoExtraCommands(TiXmlElement* parentNode, ProjectBuildTarget* target = nullptr);
79  void DoMakeCommands(TiXmlElement* parentNode, CompileTargetBase* target);
80  void DoVirtualTargets(TiXmlElement* parentNode);
81 
82  void DoBuild(TiXmlElement* parentNode);
83  void DoBuildTarget(TiXmlElement* parentNode);
84  void DoBuildTargetOptions(TiXmlElement* parentNode, ProjectBuildTarget* target);
85 
86  void DoEnvironment(TiXmlElement* parentNode, CompileOptionsBase* base);
87 
88  void DoUnits(const TiXmlElement* parentNode);
89  void DoUnitOptions(const TiXmlElement* parentNode, ProjectFile* file);
90  private:
91  void ConvertVersion_Pre_1_1();
92  void ConvertLibraries(CompileTargetBase* object);
93 
94  // convenience functions, used in Save()
95  TiXmlElement* AddElement(TiXmlElement* parent, const char* name, const char* attr = nullptr, const wxString& attribute = wxEmptyString);
96  TiXmlElement* AddElement(TiXmlElement* parent, const char* name, const char* attr, int attribute);
97  void AddArrayOfElements(TiXmlElement* parent, const char* name, const char* attr, const wxArrayString& array, bool isPath = false);
98  void SaveEnvironment(TiXmlElement* parent, CompileOptionsBase* base);
99 
100  // accepts a questionable compiler index and returns a valid compiler index
101  // (popping up a selection dialog if needed)
102  wxString GetValidCompilerID(const wxString& proposal, const wxString& scope);
103 
104  ProjectLoader(){} // no default ctor
105 
108  bool m_OpenDirty; // set this to true if the project is loaded but modified (like the case when setting another compiler, if invalid)
112  CompilerSubstitutes m_CompilerSubstitutes;
113 };
114 
115 #endif // PROJECTLOADER_H
116 
CompilerSubstitutes m_CompilerSubstitutes
cbProject * m_pProject
Represents a file in a Code::Blocks project.
Definition: projectfile.h:39
virtual bool Open(const wxString &filename)=0
Open a file.
#define DLLIMPORT
Definition: settings.h:16
bool FileModified()
Definition: projectloader.h:70
Represents a Code::Blocks project.
Definition: cbproject.h:96
Base interface for project loaders.
Definition: ibaseloader.h:14
This is a base class for all classes needing compilation parameters.
wxString wxEmptyString
WX_DECLARE_STRING_HASH_MAP(wxString, CompilerSubstitutes)
Code::Blocks project file loader.
Definition: projectloader.h:22
virtual bool Save(const wxString &filename)=0
Save a file.
bool FileUpgraded()
Definition: projectloader.h:67
Represents a Code::Blocks project build target.
int m_1_4_to_1_5_deftarget
Base class for build target classes Each Code::Blocks project consists of at least one target...