Code::Blocks  SVN r11506
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
ProjectLoader Class Reference

Code::Blocks project file loader. More...

#include <projectloader.h>

Inheritance diagram for ProjectLoader:
Collaboration diagram for ProjectLoader:

Public Member Functions

 ProjectLoader (cbProject *project)
 Constructor. More...
 
 ~ProjectLoader () override
 Destructor. More...
 
bool Open (const wxString &filename) override
 Open a file. More...
 
bool Save (const wxString &filename) override
 Save a file. More...
 
bool Open (const wxString &filename, TiXmlElement **ppExtensions)
 Open a file. More...
 
bool Save (const wxString &filename, TiXmlElement *pExtensions)
 Save a file. More...
 
bool ExportTargetAsProject (const wxString &filename, const wxString &onlyTarget, TiXmlElement *pExtensions)
 Export a target as a new project. More...
 
bool FileUpgraded ()
 
bool FileModified ()
 
- Public Member Functions inherited from IBaseLoader
 IBaseLoader ()
 Constructor. More...
 
virtual ~IBaseLoader ()
 Destructor. More...
 

Protected Member Functions

void DoProjectOptions (TiXmlElement *parentNode)
 
void DoCompilerOptions (TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
 
void DoResourceCompilerOptions (TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
 
void DoLinkerOptions (TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
 
void DoIncludesOptions (TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
 
void DoLibsOptions (TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
 
void DoExtraCommands (TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
 
void DoMakeCommands (TiXmlElement *parentNode, CompileTargetBase *target)
 
void DoVirtualTargets (TiXmlElement *parentNode)
 
void DoBuild (TiXmlElement *parentNode)
 
void DoBuildTarget (TiXmlElement *parentNode)
 
void DoBuildTargetOptions (TiXmlElement *parentNode, ProjectBuildTarget *target)
 
void DoEnvironment (TiXmlElement *parentNode, CompileOptionsBase *base)
 
void DoUnits (const TiXmlElement *parentNode)
 
void DoUnitOptions (const TiXmlElement *parentNode, ProjectFile *file)
 

Private Member Functions

void ConvertVersion_Pre_1_1 ()
 
void ConvertLibraries (CompileTargetBase *object)
 
TiXmlElement * AddElement (TiXmlElement *parent, const char *name, const char *attr=nullptr, const wxString &attribute=wxEmptyString)
 
TiXmlElement * AddElement (TiXmlElement *parent, const char *name, const char *attr, int attribute)
 
void AddArrayOfElements (TiXmlElement *parent, const char *name, const char *attr, const wxArrayString &array, bool isPath=false)
 
void SaveEnvironment (TiXmlElement *parent, CompileOptionsBase *base)
 
wxString GetValidCompilerID (const wxString &proposal, const wxString &scope)
 
 ProjectLoader ()
 

Private Attributes

cbProjectm_pProject
 
bool m_Upgraded
 
bool m_OpenDirty
 
bool m_IsPre_1_2
 
int m_1_4_to_1_5_deftarget
 
bool m_IsPre_1_6
 
CompilerSubstitutes m_CompilerSubstitutes
 

Detailed Description

Code::Blocks project file loader.

Definition at line 22 of file projectloader.h.

Constructor & Destructor Documentation

◆ ProjectLoader() [1/2]

ProjectLoader::ProjectLoader ( cbProject project)

Constructor.

Parameters
projectThe project to handle (load/save).

Definition at line 41 of file projectloader.cpp.

◆ ~ProjectLoader()

ProjectLoader::~ProjectLoader ( )
override

Destructor.

Definition at line 51 of file projectloader.cpp.

◆ ProjectLoader() [2/2]

ProjectLoader::ProjectLoader ( )
inlineprivate

Definition at line 104 of file projectloader.h.

Member Function Documentation

◆ AddArrayOfElements()

void ProjectLoader::AddArrayOfElements ( TiXmlElement *  parent,
const char *  name,
const char *  attr,
const wxArrayString array,
bool  isPath = false 
)
private

◆ AddElement() [1/2]

TiXmlElement * ProjectLoader::AddElement ( TiXmlElement *  parent,
const char *  name,
const char *  attr = nullptr,
const wxString attribute = wxEmptyString 
)
private

Definition at line 1146 of file projectloader.cpp.

References cbU2C().

Referenced by AddArrayOfElements(), ExportTargetAsProject(), and SaveEnvironment().

◆ AddElement() [2/2]

TiXmlElement * ProjectLoader::AddElement ( TiXmlElement *  parent,
const char *  name,
const char *  attr,
int  attribute 
)
private

Definition at line 1157 of file projectloader.cpp.

◆ ConvertLibraries()

void ProjectLoader::ConvertLibraries ( CompileTargetBase object)
private

◆ ConvertVersion_Pre_1_1()

void ProjectLoader::ConvertVersion_Pre_1_1 ( )
private

◆ DoBuild()

void ProjectLoader::DoBuild ( TiXmlElement *  parentNode)
protected

◆ DoBuildTarget()

void ProjectLoader::DoBuildTarget ( TiXmlElement *  parentNode)
protected

◆ DoBuildTargetOptions()

void ProjectLoader::DoBuildTargetOptions ( TiXmlElement *  parentNode,
ProjectBuildTarget target 
)
protected

◆ DoCompilerOptions()

void ProjectLoader::DoCompilerOptions ( TiXmlElement *  parentNode,
ProjectBuildTarget target = nullptr 
)
protected

◆ DoEnvironment()

void ProjectLoader::DoEnvironment ( TiXmlElement *  parentNode,
CompileOptionsBase base 
)
protected

◆ DoExtraCommands()

void ProjectLoader::DoExtraCommands ( TiXmlElement *  parentNode,
ProjectBuildTarget target = nullptr 
)
protected

◆ DoIncludesOptions()

void ProjectLoader::DoIncludesOptions ( TiXmlElement *  parentNode,
ProjectBuildTarget target = nullptr 
)
protected

◆ DoLibsOptions()

void ProjectLoader::DoLibsOptions ( TiXmlElement *  parentNode,
ProjectBuildTarget target = nullptr 
)
protected

◆ DoLinkerOptions()

void ProjectLoader::DoLinkerOptions ( TiXmlElement *  parentNode,
ProjectBuildTarget target = nullptr 
)
protected

◆ DoMakeCommands()

void ProjectLoader::DoMakeCommands ( TiXmlElement *  parentNode,
CompileTargetBase target 
)
protected

◆ DoProjectOptions()

void ProjectLoader::DoProjectOptions ( TiXmlElement *  parentNode)
protected

◆ DoResourceCompilerOptions()

void ProjectLoader::DoResourceCompilerOptions ( TiXmlElement *  parentNode,
ProjectBuildTarget target = nullptr 
)
protected

◆ DoUnitOptions()

void ProjectLoader::DoUnitOptions ( const TiXmlElement *  parentNode,
ProjectFile file 
)
protected

◆ DoUnits()

void ProjectLoader::DoUnits ( const TiXmlElement *  parentNode)
protected

◆ DoVirtualTargets()

void ProjectLoader::DoVirtualTargets ( TiXmlElement *  parentNode)
protected

◆ ExportTargetAsProject()

bool ProjectLoader::ExportTargetAsProject ( const wxString filename,
const wxString onlyTarget,
TiXmlElement *  pExtensions 
)

Export a target as a new project.

In other words, save a copy of the project containing only the specified target.

Parameters
filenameThe new project filename.
pExtensionsA pointer of type TiXmlElement. This will be added as the <Extensions> element.
onlyTargetThe target name. If empty, it's like saving the project under a different name (i.e. all targets are exported to the new project).

Definition at line 1219 of file projectloader.cpp.

References _T, AddArrayOfElements(), AddElement(), wxString::AfterLast(), ProjectFile::AutoGeneratedBy(), pfCustomBuild::buildCommand, ProjectFile::buildTargets, FileFilters::C_EXT, ProjectLoaderHooks::CallHooks(), cbSaveTinyXMLDocument(), cbU2C(), wxFileName::ClearExt(), ProjectFile::CompareProjectFiles(), ProjectFile::compile, ProjectFile::compilerVar, ProjectFile::customBuild, FileTypeOf(), ftObject, ftResource, ftResourceBin, ftSource, ftStaticLib, ProjectBuildTarget::GetAdditionalOutputFiles(), CompileOptionsBase::GetAlwaysRunPostBuildSteps(), CompileTargetBase::GetBasePath(), CompileOptionsBase::GetBuildScripts(), cbProject::GetBuildTarget(), cbProject::GetBuildTargetsCount(), cbProject::GetCheckForExternallyModifiedFiles(), CompileOptionsBase::GetCommandsAfterBuild(), CompileOptionsBase::GetCommandsBeforeBuild(), CompilerFactory::GetCompiler(), CompileTargetBase::GetCompilerID(), CompileOptionsBase::GetCompilerOptions(), wxArrayString::GetCount(), ProjectBuildTarget::GetCreateDefFile(), ProjectBuildTarget::GetCreateStaticLib(), cbProject::GetDefaultExecuteTarget(), CompileTargetBase::GetDepsOutput(), CompileTargetBase::GetDynamicLibDefFilename(), CompileTargetBase::GetDynamicLibImportFilename(), CompileTargetBase::GetExecutionParameters(), cbProject::GetExtendedObjectNamesGeneration(), ProjectBuildTarget::GetExternalDeps(), ProjectBuildTarget::GetFilesList(), cbProject::GetFilesList(), cbProject::GetFirstValidBuildTargetName(), wxFileName::GetFullName(), wxFileName::GetFullPath(), cbProject::GetGlobs(), CompileTargetBase::GetHostApplication(), CompileOptionsBase::GetIncludeDirs(), CompileOptionsBase::GetLibDirs(), CompileOptionsBase::GetLinkerOptions(), CompileOptionsBase::GetLinkLibs(), CompileTargetBase::GetMakeCommandFor(), cbProject::GetMakefile(), cbProject::GetMakefileExecutionDir(), cbProject::GetModeForPCH(), cbProject::GetNotes(), CompileTargetBase::GetObjectOutput(), CompileTargetBase::GetOptionRelation(), CompileTargetBase::GetOutputFilename(), CompileOptionsBase::GetPlatforms(), CompileOptionsBase::GetResourceCompilerOptions(), CompileOptionsBase::GetResourceIncludeDirs(), CompileTargetBase::GetRunHostApplicationInTerminal(), cbProject::GetShowNotesOnLoad(), GetStringFromArray(), GetStringFromPlatforms(), Compiler::GetSwitches(), CompileTargetBase::GetTargetFilenameGenerationPolicy(), CompileTargetBase::GetTargetType(), CompileTargetBase::GetTitle(), ProjectBuildTarget::GetUseConsoleRunner(), cbProject::GetVirtualBuildTargetGroup(), cbProject::GetVirtualBuildTargets(), cbProject::GetVirtualFolders(), CompileTargetBase::GetWorkingDir(), ProjectLoaderHooks::HasRegisteredHooks(), wxString::IsEmpty(), cbProject::IsMakefileCustom(), wxString::IsSameAs(), wxArrayString::Item(), CompilerSwitches::libPrefix, ProjectFile::link, wxString::Lower(), cbProject::Glob::m_Path, m_pProject, cbProject::Glob::m_Recursive, cbProject::Glob::m_WildCard, CompileTargetBase::MakeCommandsModified(), wxString::mb_str(), mcAskRebuildNeeded, mcBuild, mcClean, mcCompileFile, mcDistClean, mcSilentBuild, wxString::Mid(), ortCompilerOptions, ortIncludeDirs, ortLibDirs, ortLinkerOptions, ortResDirs, pchObjectDir, PROJECT_FILE_VERSION_MAJOR, PROJECT_FILE_VERSION_MINOR, ProjectFile::relativeFilename, wxString::Replace(), FileFilters::RESOURCE_EXT, SaveEnvironment(), wxFileName::SetFullName(), spAll, tgfpPlatformDefault, ttCommandsOnly, ttConsoleOnly, ttDynamicLib, ttStaticLib, UnixFilename(), pfCustomBuild::useCustomBuildCommand, ProjectFile::virtual_path, ProjectFile::weight, wxPATH_UNIX, and wxT.

Referenced by cbProject::ExportTargetAsProject(), and Save().

◆ FileModified()

bool ProjectLoader::FileModified ( )
inline
Returns
True if the file was modified while loading, false if not. This is usually true if FileUpgraded() returned true.

Definition at line 70 of file projectloader.h.

References wxEmptyString.

Referenced by cbProject::Open().

◆ FileUpgraded()

bool ProjectLoader::FileUpgraded ( )
inline
Returns
True if the file was upgraded after load, false if not.

Definition at line 67 of file projectloader.h.

Referenced by cbProject::Open().

◆ GetValidCompilerID()

wxString ProjectLoader::GetValidCompilerID ( const wxString proposal,
const wxString scope 
)
private

◆ Open() [1/2]

bool ProjectLoader::Open ( const wxString filename)
overridevirtual

Open a file.

Parameters
filenameThe file to open.
Returns
True on success, false on failure.

Implements IBaseLoader.

Definition at line 56 of file projectloader.cpp.

Referenced by cbProject::Open().

◆ Open() [2/2]

bool ProjectLoader::Open ( const wxString filename,
TiXmlElement **  ppExtensions 
)

◆ Save() [1/2]

bool ProjectLoader::Save ( const wxString filename)
overridevirtual

Save a file.

Parameters
filenameThe file to save.
Returns
True on success, false on failure.

Implements IBaseLoader.

Definition at line 1204 of file projectloader.cpp.

Referenced by cbProject::Save(), and cbProject::SaveAs().

◆ Save() [2/2]

bool ProjectLoader::Save ( const wxString filename,
TiXmlElement *  pExtensions 
)

Save a file.

This version of Save, can override the <Extensions> element.

Parameters
filenameThe file to save.
pExtensionsA pointer of type TiXmlElement. This will be added as the <Extensions> element.
Returns
True on success, false on failure.

Definition at line 1209 of file projectloader.cpp.

References ExportTargetAsProject(), m_pProject, cbProject::SetModified(), and wxEmptyString.

◆ SaveEnvironment()

void ProjectLoader::SaveEnvironment ( TiXmlElement *  parent,
CompileOptionsBase base 
)
private

Definition at line 1182 of file projectloader.cpp.

References AddElement(), cbU2C(), and CompileOptionsBase::GetAllVars().

Referenced by ExportTargetAsProject().

Member Data Documentation

◆ m_1_4_to_1_5_deftarget

int ProjectLoader::m_1_4_to_1_5_deftarget
private

Definition at line 110 of file projectloader.h.

Referenced by DoProjectOptions(), and Open().

◆ m_CompilerSubstitutes

CompilerSubstitutes ProjectLoader::m_CompilerSubstitutes
private

Definition at line 112 of file projectloader.h.

Referenced by GetValidCompilerID().

◆ m_IsPre_1_2

bool ProjectLoader::m_IsPre_1_2
private

Definition at line 109 of file projectloader.h.

Referenced by DoBuildTargetOptions(), DoProjectOptions(), and Open().

◆ m_IsPre_1_6

bool ProjectLoader::m_IsPre_1_6
private

Definition at line 111 of file projectloader.h.

Referenced by DoUnitOptions(), and Open().

◆ m_OpenDirty

bool ProjectLoader::m_OpenDirty
private

Definition at line 108 of file projectloader.h.

Referenced by GetValidCompilerID().

◆ m_pProject

cbProject* ProjectLoader::m_pProject
private

◆ m_Upgraded

bool ProjectLoader::m_Upgraded
private

Definition at line 107 of file projectloader.h.

Referenced by ConvertVersion_Pre_1_1(), and Open().


The documentation for this class was generated from the following files: