From 310ef08fed57b1c60ea8dc8ed98520e2cb0bff4e Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 6 Feb 2014 14:05:57 -0500 Subject: stringapi: Use strings for source names --- Source/cmMakefile.cxx | 31 +++++++++++++------------------ Source/cmMakefile.h | 14 +++++++------- Source/cmSourceFile.cxx | 2 +- Source/cmSourceFile.h | 2 +- Source/cmSourceFileLocation.cxx | 13 +++++++------ Source/cmSourceFileLocation.h | 8 ++++---- Source/cmSourceGroup.cxx | 2 +- Source/cmSourceGroup.h | 2 +- Source/cmTarget.cxx | 2 +- Source/cmTarget.h | 2 +- 10 files changed, 37 insertions(+), 41 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 76b3b09..97628f3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2060,9 +2060,8 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name) } cmSourceFile* -cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const +cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const { - std::string name = cname; std::string out; // look through all the source files that have custom commands @@ -2096,15 +2095,14 @@ cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const return 0; } -cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const +cmSourceFile *cmMakefile::GetSourceFileWithOutput( + const std::string& name) const { - std::string name = cname; - // If the queried path is not absolute we use the backward compatible // linear-time search for an output with a matching suffix. - if(!cmSystemTools::FileIsFullPath(cname)) + if(!cmSystemTools::FileIsFullPath(name.c_str())) { - return LinearGetSourceFileWithOutput(cname); + return LinearGetSourceFileWithOutput(name.c_str()); } // Otherwise we use an efficient lookup map. OutputToSourceMap::const_iterator o = this->OutputToSource.find(name); @@ -2149,15 +2147,12 @@ cmMakefile::GetSourceGroup(const std::vector&name) const return sg; } - void cmMakefile::AddSourceGroup(const char* name, +void cmMakefile::AddSourceGroup(const std::string& name, const char* regex) { - if (name) - { - std::vector nameVector; - nameVector.push_back(name); - AddSourceGroup(nameVector, regex); - } + std::vector nameVector; + nameVector.push_back(name); + AddSourceGroup(nameVector, regex); } void cmMakefile::AddSourceGroup(const std::vector& name, @@ -3011,9 +3006,9 @@ void cmMakefile::SetArgcArgv(const std::vector& args) } //---------------------------------------------------------------------------- -cmSourceFile* cmMakefile::GetSource(const char* sourceName) const +cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const { - cmSourceFileLocation sfl(this, sourceName); + cmSourceFileLocation sfl(this, sourceName.c_str()); for(std::vector::const_iterator sfi = this->SourceFiles.begin(); sfi != this->SourceFiles.end(); ++sfi) @@ -3028,7 +3023,7 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const } //---------------------------------------------------------------------------- -cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, +cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName, bool generated) { if(cmSourceFile* esf = this->GetSource(sourceName)) @@ -3037,7 +3032,7 @@ cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName, } else { - cmSourceFile* sf = new cmSourceFile(this, sourceName); + cmSourceFile* sf = new cmSourceFile(this, sourceName.c_str()); if(generated) { sf->SetProperty("GENERATED", "1"); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 559d49c..a8ad1e2 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -332,7 +332,7 @@ public: /** * Add a root source group for consideration when adding a new source. */ - void AddSourceGroup(const char* name, const char* regex=0); + void AddSourceGroup(const std::string& name, const char* regex=0); /** * Add a source group for consideration when adding a new source. @@ -555,14 +555,14 @@ public: /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then a null pointer is returned. */ - cmSourceFile* GetSource(const char* sourceName) const; + cmSourceFile* GetSource(const std::string& sourceName) const; /** Get a cmSourceFile pointer for a given source name, if the name is * not found, then create the source file and return it. generated * indicates if it is a generated file, this is used in determining * how to create the source file instance e.g. name */ - cmSourceFile* GetOrCreateSource(const char* sourceName, + cmSourceFile* GetOrCreateSource(const std::string& sourceName, bool generated = false); /** @@ -773,7 +773,7 @@ public: * Is there a source file that has the provided source file as an output? * if so then return it */ - cmSourceFile *GetSourceFileWithOutput(const char *outName) const; + cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const; /** * Add a macro to the list of macros. The arguments should be name of the @@ -1030,12 +1030,12 @@ private: bool GeneratingBuildSystem; /** - * Old version of GetSourceFileWithOutput(const char*) kept for + * Old version of GetSourceFileWithOutput(const std::string&) kept for * backward-compatibility. It implements a linear search and support * relative file paths. It is used as a fall back by - * GetSourceFileWithOutput(const char*). + * GetSourceFileWithOutput(const std::string&). */ - cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const; + cmSourceFile *LinearGetSourceFileWithOutput(const std::string& cname) const; // A map for fast output to input look up. #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index dd95f23..9feda6c 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -18,7 +18,7 @@ #include "cmake.h" //---------------------------------------------------------------------------- -cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name): +cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name): Location(mf, name) { this->CustomCommand = 0; diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 85d6332..833a490 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -31,7 +31,7 @@ public: * Construct with the makefile storing the source and the initial * name referencing it. */ - cmSourceFile(cmMakefile* mf, const char* name); + cmSourceFile(cmMakefile* mf, const std::string& name); ~cmSourceFile(); diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx index 5a8578b..832a6a7 100644 --- a/Source/cmSourceFileLocation.cxx +++ b/Source/cmSourceFileLocation.cxx @@ -18,9 +18,10 @@ //---------------------------------------------------------------------------- cmSourceFileLocation -::cmSourceFileLocation(cmMakefile const* mf, const char* name): Makefile(mf) +::cmSourceFileLocation(cmMakefile const* mf, const std::string& name) + : Makefile(mf) { - this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name); + this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str()); this->AmbiguousExtension = true; this->Directory = cmSystemTools::GetFilenamePath(name); this->Name = cmSystemTools::GetFilenameName(name); @@ -28,7 +29,7 @@ cmSourceFileLocation } //---------------------------------------------------------------------------- -void cmSourceFileLocation::Update(const char* name) +void cmSourceFileLocation::Update(const std::string& name) { if(this->AmbiguousDirectory) { @@ -80,7 +81,7 @@ void cmSourceFileLocation::DirectoryUseBinary() } //---------------------------------------------------------------------------- -void cmSourceFileLocation::UpdateExtension(const char* name) +void cmSourceFileLocation::UpdateExtension(const std::string& name) { // Check the extension. std::string ext = cmSystemTools::GetFilenameLastExtension(name); @@ -136,10 +137,10 @@ void cmSourceFileLocation::UpdateExtension(const char* name) } //---------------------------------------------------------------------------- -void cmSourceFileLocation::UpdateDirectory(const char* name) +void cmSourceFileLocation::UpdateDirectory(const std::string& name) { // If a full path was given we know the directory. - if(cmSystemTools::FileIsFullPath(name)) + if(cmSystemTools::FileIsFullPath(name.c_str())) { this->Directory = cmSystemTools::GetFilenamePath(name); this->AmbiguousDirectory = false; diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h index c03eee7..64b8c1f 100644 --- a/Source/cmSourceFileLocation.h +++ b/Source/cmSourceFileLocation.h @@ -33,7 +33,7 @@ public: * Construct for a source file created in a given cmMakefile * instance with an initial name. */ - cmSourceFileLocation(cmMakefile const* mf, const char* name); + cmSourceFileLocation(cmMakefile const* mf, const std::string& name); /** * Return whether the givne source file location could refers to the @@ -93,9 +93,9 @@ private: // Update the location with additional knowledge. void Update(cmSourceFileLocation const& loc); - void Update(const char* name); - void UpdateExtension(const char* name); - void UpdateDirectory(const char* name); + void Update(const std::string& name); + void UpdateExtension(const std::string& name); + void UpdateDirectory(const std::string& name); }; #endif diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx index d272b6c..195feb5 100644 --- a/Source/cmSourceGroup.cxx +++ b/Source/cmSourceGroup.cxx @@ -73,7 +73,7 @@ void cmSourceGroup::SetGroupRegex(const char* regex) } //---------------------------------------------------------------------------- -void cmSourceGroup::AddGroupFile(const char* name) +void cmSourceGroup::AddGroupFile(const std::string& name) { this->GroupFiles.insert(name); } diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h index 3bbdef9..2d891d1 100644 --- a/Source/cmSourceGroup.h +++ b/Source/cmSourceGroup.h @@ -46,7 +46,7 @@ public: /** * Add a file name to the explicit list of files for this group. */ - void AddGroupFile(const char* name); + void AddGroupFile(const std::string& name); /** * Add child to this sourcegroup diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d5cd140..34d92fa 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -592,7 +592,7 @@ void cmTarget::AddSources(std::vector const& srcs) } //---------------------------------------------------------------------------- -cmSourceFile* cmTarget::AddSource(const char* s) +cmSourceFile* cmTarget::AddSource(const std::string& s) { std::string src = s; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f0dd708..9f7b811 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -143,7 +143,7 @@ public: * Add sources to the target. */ void AddSources(std::vector const& srcs); - cmSourceFile* AddSource(const char* src); + cmSourceFile* AddSource(const std::string& src); enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED}; -- cgit v0.12