Code::Blocks  SVN r11506
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
ProjectFile Class Reference

Represents a file in a Code::Blocks project. More...

#include <projectfile.h>

Collaboration diagram for ProjectFile:

Public Member Functions

 ProjectFile (cbProject *prj)
 Constructor. More...
 
 ~ProjectFile ()
 Destructor. More...
 
void Rename (const wxString &new_name)
 Change filename of the file. More...
 
void AddBuildTarget (const wxString &targetName)
 Make this file belong to an additional build target. More...
 
void RenameBuildTarget (const wxString &oldTargetName, const wxString &newTargetName)
 Rename a build target this file belongs in. More...
 
void RemoveBuildTarget (const wxString &targetName)
 Remove this file from the specified build target. More...
 
const wxArrayStringGetBuildTargets () const
 
bool ShowOptions (wxWindow *parent)
 Show the file properties dialog. More...
 
wxString GetBaseName () const
 
const wxStringGetObjName ()
 
void SetObjName (const wxString &name)
 Set the generated object filename. More...
 
cbProjectGetParentProject ()
 
void UpdateFileDetails (ProjectBuildTarget *target=nullptr)
 This is called automatically when adding/removing build targets. More...
 
const pfDetailsGetFileDetails (ProjectBuildTarget *target)
 Access the file details for this project file for the specified target. More...
 
void SetFileState (FileVisualState state)
 Set the visual state (modified, read-only, etc). More...
 
FileVisualState GetFileState () const
 
void SetUseCustomBuildCommand (const wxString &compilerId, bool useCustomBuildCommand)
 Modify 'Use custom command to build this file' for a compilerId. More...
 
void SetCustomBuildCommand (const wxString &compilerId, const wxString &newBuildCommand)
 Modify customBuild command for a compilerId. More...
 
bool GetUseCustomBuildCommand (const wxString &compilerId)
 Read 'Use custom command to build this file' for a compilerId. More...
 
wxString GetCustomBuildCommand (const wxString &compilerId)
 Read customBuild command for a compilerId. More...
 
ProjectFileAutoGeneratedBy () const
 If this is an auto-generated file, which file is generating it? More...
 
void SetAutoGeneratedBy (ProjectFile *TheFile)
 If this is an auto-generated file, set the file which is generating it? More...
 
const wxTreeItemIdGetTreeItemId () const
 Returns the wxTreeItemId for the file. More...
 
void SetTreeItemId (wxTreeItemId id)
 Sets the tree item id for the file. More...
 

Static Public Member Functions

static int CompareProjectFiles (ProjectFile *item1, ProjectFile *item2)
 Compare relative names of projectfiles. More...
 

Public Attributes

wxFileName file
 The full filename of this file. More...
 
wxString relativeFilename
 The relative (to the project) filename of this file. More...
 
wxString relativeToCommonTopLevelPath
 The relative filename to the common top-level path. More...
 
bool compile
 Compile flag. More...
 
unsigned short int weight
 The weight. More...
 
bool editorOpen
 If true, the file is open inside an editor. More...
 
int editorSplit
 Split type of the editor as int. More...
 
int editorSplitActive
 Last active splitview (1 or 2). More...
 
int editorSplitPos
 Last splitter position. More...
 
int editorPos
 The last known caret position in an editor for this file (left/top control if split). More...
 
int editorTopLine
 The last known caret line in an editor for this file (left/top control if split). More...
 
int editorZoom
 The zoom-factor of the editor for this file (left/top control if split). More...
 
int editorPos_2
 The last known caret position in an editor for this file (right/bottom control if split). More...
 
int editorTopLine_2
 The last known caret line in an editor for this file(right/bottom control if split). More...
 
int editorZoom_2
 The zoom-factor of the editor for this file(right/bottom control if split). More...
 
int editorTabPos
 The position of the editor-tab for this file. More...
 
wxArrayInt editorFoldLinesArray
 Fold lines. More...
 
pfCustomBuildMap customBuild
 A map for custom builds. More...
 
wxString compilerVar
 The compiler variable used for this file (e.g CPP, CC, etc). More...
 
wxArrayString buildTargets
 An array of strings, containing the names of all the build targets this file belongs to. More...
 
wxString virtual_path
 A string that represents the virtual folder this file will appear in. More...
 
ProjectFileautoGeneratedBy
 If this is an auto-generated file, which file is generating it? More...
 
ProjectFilesVector generatedFiles
 Auto-generated files when compiling this file. More...
 

Protected Member Functions

void DoUpdateFileDetails (ProjectBuildTarget *target)
 

Protected Attributes

cbProjectproject
 
FileVisualState m_VisualState
 
wxTreeItemId m_TreeItemId
 
wxString m_ObjName
 
PFDMap m_PFDMap
 

Friends

class cbProject
 

Detailed Description

Represents a file in a Code::Blocks project.

Definition at line 39 of file projectfile.h.

Constructor & Destructor Documentation

◆ ProjectFile()

ProjectFile::ProjectFile ( cbProject prj)

Constructor.

Definition at line 26 of file projectfile.cpp.

◆ ~ProjectFile()

ProjectFile::~ProjectFile ( )

Destructor.

Definition at line 47 of file projectfile.cpp.

References m_PFDMap.

Member Function Documentation

◆ AddBuildTarget()

void ProjectFile::AddBuildTarget ( const wxString targetName)

◆ AutoGeneratedBy()

ProjectFile* ProjectFile::AutoGeneratedBy ( ) const
inline

◆ CompareProjectFiles()

int ProjectFile::CompareProjectFiles ( ProjectFile item1,
ProjectFile item2 
)
static

Compare relative names of projectfiles.

Static helper function to sort array of projectfiles. Needed because the order of files in a hashset is not guaranteed.

Parameters
item1first projectfile.
item2second projectfile.
Returns
A negative value, 0, or positive value if the relative filename of item1 is less than, equal to or greater than the one of item2.

Definition at line 334 of file projectfile.cpp.

References relativeFilename.

Referenced by ProjectLoader::ExportTargetAsProject().

◆ DoUpdateFileDetails()

void ProjectFile::DoUpdateFileDetails ( ProjectBuildTarget target)
protected

◆ GetBaseName()

wxString ProjectFile::GetBaseName ( ) const
Returns
The relative (to the project) filename without extension.

Definition at line 153 of file projectfile.cpp.

References wxFileName::GetFullPath(), relativeFilename, wxFileName::SetExt(), and wxEmptyString.

Referenced by ScriptBindings::RegisterBindings().

◆ GetBuildTargets()

const wxArrayString & ProjectFile::GetBuildTargets ( ) const
Returns
An array of strings, containing the names of all the build targets this file belongs to.

Definition at line 141 of file projectfile.cpp.

References buildTargets.

Referenced by DirectCommands::CompileFile(), and ScriptBindings::RegisterBindings().

◆ GetCustomBuildCommand()

wxString ProjectFile::GetCustomBuildCommand ( const wxString compilerId)

Read customBuild command for a compilerId.

Definition at line 329 of file projectfile.cpp.

References customBuild.

Referenced by ScriptBindings::RegisterBindings().

◆ GetFileDetails()

const pfDetails & ProjectFile::GetFileDetails ( ProjectBuildTarget target)

Access the file details for this project file for the specified target.

Parameters
targetA pointer to the build target whose file details should be updated.
Returns
The details for this project file for the specified build target.

Definition at line 284 of file projectfile.cpp.

References DoUpdateFileDetails(), and m_PFDMap.

Referenced by DirectCommands::CompileFile(), DirectCommands::GetCompileFileCommand(), DirectCommands::GetTargetCleanCommands(), DirectCommands::GetTargetCompileCommands(), and DirectCommands::GetTargetLinkCommands().

◆ GetFileState()

FileVisualState ProjectFile::GetFileState ( ) const
Returns
The visual state (modified, read-only, etc).

Definition at line 295 of file projectfile.cpp.

References m_VisualState.

Referenced by ProjectManagerUI::BuildProjectTree(), EditorManager::CheckForExternallyModifiedFiles(), and ProjectManagerUI::ShowMenu().

◆ GetObjName()

const wxString & ProjectFile::GetObjName ( )

◆ GetParentProject()

cbProject* ProjectFile::GetParentProject ( )
inline

◆ GetTreeItemId()

const wxTreeItemId& ProjectFile::GetTreeItemId ( ) const
inline

Returns the wxTreeItemId for the file.

Definition at line 210 of file projectfile.h.

Referenced by ProjectManagerUI::ShowFileInTree().

◆ GetUseCustomBuildCommand()

bool ProjectFile::GetUseCustomBuildCommand ( const wxString compilerId)

Read 'Use custom command to build this file' for a compilerId.

Definition at line 324 of file projectfile.cpp.

References customBuild.

Referenced by ScriptBindings::RegisterBindings().

◆ RemoveBuildTarget()

void ProjectFile::RemoveBuildTarget ( const wxString targetName)

◆ Rename()

void ProjectFile::Rename ( const wxString new_name)

Change filename of the file.

Note that this does only update the internal variables. It does NOT rename the file on disk... It updates file, relativeFilename, relativeToCommonTopLevelPath and finally marks the parent project as modified.

Note
This allows renaming only the LAST part of the filename (the name and extension)

Definition at line 57 of file projectfile.cpp.

References wxString::Append(), wxFileName::Assign(), wxString::BeforeLast(), cbProject::CalculateCommonTopLevelPath(), file, wxFileName::GetPath(), wxString::IsEmpty(), project, cbProject::ProjectFileRenamed(), relativeFilename, cbProject::SetModified(), and UpdateFileDetails().

◆ RenameBuildTarget()

void ProjectFile::RenameBuildTarget ( const wxString oldTargetName,
const wxString newTargetName 
)

Rename a build target this file belongs in.

Parameters
oldTargetNameThe build target's old name.
newTargetNameThe build target's new name.
Note
This does not change the build target's name, just the reference in the project file. This is actually used by cbProject::RenameBuildTarget().

Definition at line 102 of file projectfile.cpp.

References buildTargets, generatedFiles, wxArrayString::Index(), and wxNOT_FOUND.

Referenced by ScriptBindings::RegisterBindings(), and cbProject::RenameBuildTarget().

◆ SetAutoGeneratedBy()

void ProjectFile::SetAutoGeneratedBy ( ProjectFile TheFile)
inline

If this is an auto-generated file, set the file which is generating it?

Definition at line 204 of file projectfile.h.

Referenced by cbProject::AddFile().

◆ SetCustomBuildCommand()

void ProjectFile::SetCustomBuildCommand ( const wxString compilerId,
const wxString newBuildCommand 
)

Modify customBuild command for a compilerId.

Definition at line 319 of file projectfile.cpp.

References customBuild.

Referenced by ProjectLoader::DoUnitOptions(), and ScriptBindings::RegisterBindings().

◆ SetFileState()

void ProjectFile::SetFileState ( FileVisualState  state)

◆ SetObjName()

void ProjectFile::SetObjName ( const wxString name)

◆ SetTreeItemId()

void ProjectFile::SetTreeItemId ( wxTreeItemId  id)
inline

Sets the tree item id for the file.

Should not be called by users!

Definition at line 213 of file projectfile.h.

Referenced by ProjectManagerUI::BuildProjectTree().

◆ SetUseCustomBuildCommand()

void ProjectFile::SetUseCustomBuildCommand ( const wxString compilerId,
bool  useCustomBuildCommand 
)

Modify 'Use custom command to build this file' for a compilerId.

Definition at line 314 of file projectfile.cpp.

References customBuild.

Referenced by ProjectLoader::DoUnitOptions(), and ScriptBindings::RegisterBindings().

◆ ShowOptions()

bool ProjectFile::ShowOptions ( wxWindow parent)

Show the file properties dialog.

Parameters
parentThe parent window for the dialog (can be NULL).
Returns
True if the user closed the dialog with "OK", false if closed it with "Cancel".

Definition at line 146 of file projectfile.cpp.

References PlaceWindow(), wxDialog::ShowModal(), and wxID_OK.

Referenced by cbEditor::OnContextMenuEntry(), ProjectOptionsDlg::OnFileOptionsClick(), and EditorManager::OnProperties().

◆ UpdateFileDetails()

void ProjectFile::UpdateFileDetails ( ProjectBuildTarget target = nullptr)

This is called automatically when adding/removing build targets.

Parameters
targetA pointer to the build target whose file details should be updated.

Definition at line 243 of file projectfile.cpp.

References compile, DoUpdateFileDetails(), FileTypeOf(), ftHeader, cbProject::GetBuildTarget(), cbProject::GetBuildTargetsCount(), link, project, relativeFilename, relativeToCommonTopLevelPath, and SetObjName().

Referenced by Rename(), and cbProject::SetExtendedObjectNamesGeneration().

Friends And Related Function Documentation

◆ cbProject

friend class cbProject
friend

Definition at line 224 of file projectfile.h.

Member Data Documentation

◆ autoGeneratedBy

ProjectFile* ProjectFile::autoGeneratedBy

If this is an auto-generated file, which file is generating it?

Definition at line 198 of file projectfile.h.

◆ buildTargets

wxArrayString ProjectFile::buildTargets

◆ compile

bool ProjectFile::compile

◆ compilerVar

wxString ProjectFile::compilerVar

◆ customBuild

pfCustomBuildMap ProjectFile::customBuild

◆ editorFoldLinesArray

wxArrayInt ProjectFile::editorFoldLinesArray

◆ editorOpen

bool ProjectFile::editorOpen

◆ editorPos

int ProjectFile::editorPos

The last known caret position in an editor for this file (left/top control if split).

Definition at line 160 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), cbEditor::SetProjectFile(), and cbEditor::UpdateProjectFile().

◆ editorPos_2

int ProjectFile::editorPos_2

The last known caret position in an editor for this file (right/bottom control if split).

Definition at line 169 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), cbEditor::SetProjectFile(), and cbEditor::UpdateProjectFile().

◆ editorSplit

int ProjectFile::editorSplit

Split type of the editor as int.

Definition at line 151 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), cbEditor::SetProjectFile(), and cbEditor::UpdateProjectFile().

◆ editorSplitActive

int ProjectFile::editorSplitActive

Last active splitview (1 or 2).

Definition at line 154 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), and cbEditor::UpdateProjectFile().

◆ editorSplitPos

int ProjectFile::editorSplitPos

◆ editorTabPos

int ProjectFile::editorTabPos

The position of the editor-tab for this file.

Definition at line 178 of file projectfile.h.

Referenced by cbProject::LoadLayout(), ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), and EditorManager::UpdateProjectFiles().

◆ editorTopLine

int ProjectFile::editorTopLine

The last known caret line in an editor for this file (left/top control if split).

Definition at line 163 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), cbEditor::SetProjectFile(), and cbEditor::UpdateProjectFile().

◆ editorTopLine_2

int ProjectFile::editorTopLine_2

The last known caret line in an editor for this file(right/bottom control if split).

Definition at line 172 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), cbEditor::SetProjectFile(), and cbEditor::UpdateProjectFile().

◆ editorZoom

int ProjectFile::editorZoom

The zoom-factor of the editor for this file (left/top control if split).

Definition at line 166 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), cbEditor::SetProjectFile(), and cbEditor::UpdateProjectFile().

◆ editorZoom_2

int ProjectFile::editorZoom_2

The zoom-factor of the editor for this file(right/bottom control if split).

Definition at line 175 of file projectfile.h.

Referenced by ProjectLayoutLoader::Open(), ProjectLayoutLoader::Save(), cbEditor::SetProjectFile(), and cbEditor::UpdateProjectFile().

◆ file

wxFileName ProjectFile::file

The full filename of this file.

Usually you need to read from it and never write to it.

Note
Use Rename() if you want to change this or else bad things will happen

Definition at line 126 of file projectfile.h.

Referenced by cbProject::AddFile(), NativeParser::AddProjectToParser(), ProjectManagerUI::BuildProjectTree(), cbProject::CalculateCommonTopLevelPath(), cbProject::CloseAllFiles(), CodeCompletion::DoCodeCompleteIncludes(), NativeParser::DoFullParsing(), CompilerErrors::DoGotoError(), MarkFileAsLocalThreadedTask::Execute(), cbTreeCtrl::filesSort(), cbTreeCtrl::filesSortNameOnly(), FindReplace::FindInFiles(), CodeRefactoring::GetAllProjectFiles(), DirectCommands::GetCompileFileCommand(), DirectCommands::GetTargetCleanCommands(), ClassBrowserBuilderThread::Init(), cbProject::LoadLayout(), ProjectManagerUI::OnGotoFile(), CodeCompletion::OnOpenIncludeFile(), ProjectManagerUI::OnRenameFile(), CodeCompletion::OnSelectedFileReparse(), ProjectManagerUI::OnTreeBeginDrag(), EditorManager::Open(), CompilerGCC::PrepareCompileFilePM(), ProjectFileOptionsDlg::ProjectFileOptionsDlg(), cbProject::QueryCloseAllFiles(), ScriptBindings::RegisterBindings(), cbProject::RemoveFile(), ProjectManager::RemoveFileFromProject(), NativeParser::RemoveProjectFromParser(), Rename(), FindReplace::ReplaceInFiles(), cbProject::SaveAllFiles(), cbEditor::SetEditorStyleBeforeFileOpen(), cbEditor::SetProjectFile(), ProjectManagerUI::ShowMenu(), EditorManager::SwapActiveHeaderSource(), and pfDetails::Update().

◆ generatedFiles

ProjectFilesVector ProjectFile::generatedFiles

◆ link

bool ProjectFile::link

◆ m_ObjName

wxString ProjectFile::m_ObjName
protected

Definition at line 230 of file projectfile.h.

Referenced by GetObjName(), and SetObjName().

◆ m_PFDMap

PFDMap ProjectFile::m_PFDMap
protected

Definition at line 231 of file projectfile.h.

Referenced by DoUpdateFileDetails(), GetFileDetails(), and ~ProjectFile().

◆ m_TreeItemId

wxTreeItemId ProjectFile::m_TreeItemId
protected

Definition at line 229 of file projectfile.h.

Referenced by SetFileState().

◆ m_VisualState

FileVisualState ProjectFile::m_VisualState
protected

Definition at line 228 of file projectfile.h.

Referenced by GetFileState(), and SetFileState().

◆ project

cbProject* ProjectFile::project
protected

◆ relativeFilename

wxString ProjectFile::relativeFilename

◆ relativeToCommonTopLevelPath

wxString ProjectFile::relativeToCommonTopLevelPath

◆ virtual_path

wxString ProjectFile::virtual_path

A string that represents the virtual folder this file will appear in.

This is a relative path which doesn't have to exist in the filesystem hierarchy.

Definition at line 195 of file projectfile.h.

Referenced by ProjectManagerUI::BuildProjectTree(), ProjectManagerUI::CheckForExternallyModifiedProjects(), ProjectLoader::DoUnitOptions(), ProjectLoader::ExportTargetAsProject(), cbProject::RemoveVirtualFolders(), and cbProject::ReplaceVirtualFolder().

◆ weight

unsigned short int ProjectFile::weight

The weight.

This is a number between 0 and 100 (defaults to 50). Files with smaller weights are compiled earlier than those with larger weights.

Definition at line 145 of file projectfile.h.

Referenced by ProjectLoader::DoUnitOptions(), ProjectFileOptionsDlg::EndModal(), ProjectLoader::ExportTargetAsProject(), DirectCommands::GetTargetCompileCommands(), ProjectFileOptionsDlg::ProjectFileOptionsDlg(), and ScriptBindings::RegisterBindings().


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