stringapi: Use strings for variable names

Variable names are always generated by CMake and should never be NULL.
This commit is contained in:
Ben Boeckel 2014-02-04 16:06:56 -05:00 committed by Brad King
parent ec97ed7d0c
commit 3742bb0d32
38 changed files with 142 additions and 156 deletions

View File

@ -972,7 +972,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName)
}
//----------------------------------------------------------------------
void cmCPackGenerator::SetOptionIfNotSet(const char* op,
void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
const char* value)
{
const char* def = this->MakefileMap->GetDefinition(op);
@ -984,12 +984,8 @@ void cmCPackGenerator::SetOptionIfNotSet(const char* op,
}
//----------------------------------------------------------------------
void cmCPackGenerator::SetOption(const char* op, const char* value)
void cmCPackGenerator::SetOption(const std::string& op, const char* value)
{
if ( !op )
{
return;
}
if ( !value )
{
this->MakefileMap->RemoveDefinition(op);
@ -1176,19 +1172,19 @@ int cmCPackGenerator::InitializeInternal()
}
//----------------------------------------------------------------------
bool cmCPackGenerator::IsSet(const char* name) const
bool cmCPackGenerator::IsSet(const std::string& name) const
{
return this->MakefileMap->IsSet(name);
}
//----------------------------------------------------------------------
bool cmCPackGenerator::IsOn(const char* name) const
bool cmCPackGenerator::IsOn(const std::string& name) const
{
return cmSystemTools::IsOn(GetOption(name));
}
//----------------------------------------------------------------------
const char* cmCPackGenerator::GetOption(const char* op) const
const char* cmCPackGenerator::GetOption(const std::string& op) const
{
const char* ret = this->MakefileMap->GetDefinition(op);
if(!ret)

View File

@ -99,12 +99,12 @@ public:
virtual ~cmCPackGenerator();
//! Set and get the options
void SetOption(const char* op, const char* value);
void SetOptionIfNotSet(const char* op, const char* value);
const char* GetOption(const char* op) const;
void SetOption(const std::string& op, const char* value);
void SetOptionIfNotSet(const std::string& op, const char* value);
const char* GetOption(const std::string& op) const;
std::vector<std::string> GetOptions() const;
bool IsSet(const char* name) const;
bool IsOn(const char* name) const;
bool IsSet(const std::string& name) const;
bool IsOn(const std::string& name) const;
//! Set the logger
void SetLogger(cmCPackLog* log) { this->Logger = log; }

View File

@ -30,12 +30,8 @@ cmCTestGenericHandler::~cmCTestGenericHandler()
}
//----------------------------------------------------------------------
void cmCTestGenericHandler::SetOption(const char* op, const char* value)
void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
{
if ( !op )
{
return;
}
if ( !value )
{
cmCTestGenericHandler::t_StringToString::iterator remit
@ -51,14 +47,10 @@ void cmCTestGenericHandler::SetOption(const char* op, const char* value)
}
//----------------------------------------------------------------------
void cmCTestGenericHandler::SetPersistentOption(const char* op,
void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
const char* value)
{
this->SetOption(op, value);
if ( !op )
{
return;
}
if ( !value )
{
cmCTestGenericHandler::t_StringToString::iterator remit
@ -88,7 +80,7 @@ void cmCTestGenericHandler::Initialize()
}
//----------------------------------------------------------------------
const char* cmCTestGenericHandler::GetOption(const char* op)
const char* cmCTestGenericHandler::GetOption(const std::string& op)
{
cmCTestGenericHandler::t_StringToString::iterator remit
= this->Options.find(op);

View File

@ -74,9 +74,9 @@ public:
typedef std::map<cmStdString,cmStdString> t_StringToString;
void SetPersistentOption(const char* op, const char* value);
void SetOption(const char* op, const char* value);
const char* GetOption(const char* op);
void SetPersistentOption(const std::string& op, const char* value);
void SetOption(const std::string& op, const char* value);
const char* GetOption(const std::string& op);
void SetCommand(cmCTestCommand* command)
{

View File

@ -19,9 +19,10 @@
#include "cmCursesDummyWidget.h"
#include "../cmSystemTools.h"
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
int labelwidth,
int entrywidth) :
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
const std::string& key,
int labelwidth,
int entrywidth) :
Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
{
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
@ -31,7 +32,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
}
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
const char* key, const cmCacheManager::CacheIterator& it, bool isNew,
const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew,
int labelwidth, int entrywidth)
: Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
{

View File

@ -18,8 +18,9 @@
class cmCursesCacheEntryComposite
{
public:
cmCursesCacheEntryComposite(const char* key, int labelwidth, int entrywidth);
cmCursesCacheEntryComposite(const char* key,
cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
int entrywidth);
cmCursesCacheEntryComposite(const std::string& key,
const cmCacheManager::CacheIterator& it,
bool isNew, int labelwidth, int entrywidth);
~cmCursesCacheEntryComposite();

View File

@ -84,9 +84,9 @@ cmCursesMainForm::~cmCursesMainForm()
}
// See if a cache entry is in the list of entries in the ui.
bool cmCursesMainForm::LookForCacheEntry(const char* key)
bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
{
if (!key || !this->Entries)
if (!this->Entries)
{
return false;
}
@ -94,7 +94,7 @@ bool cmCursesMainForm::LookForCacheEntry(const char* key)
std::vector<cmCursesCacheEntryComposite*>::iterator it;
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
if (!strcmp(key, (*it)->Key.c_str()))
if (key == (*it)->Key)
{
return true;
}
@ -146,7 +146,7 @@ void cmCursesMainForm::InitializeUI()
this->CMakeInstance->GetCacheManager()->NewIterator();
!i.IsAtEnd(); i.Next())
{
const char* key = i.GetName();
std::string key = i.GetName();
if ( i.GetType() == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC ||
i.GetType() == cmCacheManager::UNINITIALIZED )
@ -168,7 +168,7 @@ void cmCursesMainForm::InitializeUI()
this->CMakeInstance->GetCacheManager()->NewIterator();
!i.IsAtEnd(); i.Next())
{
const char* key = i.GetName();
std::string key = i.GetName();
if ( i.GetType() == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC ||
i.GetType() == cmCacheManager::UNINITIALIZED )

View File

@ -51,7 +51,7 @@ public:
* Returns true if an entry with the given key is in the
* list of current composites.
*/
bool LookForCacheEntry(const char* key);
bool LookForCacheEntry(const std::string& key);
enum {
MIN_WIDTH = 65,

View File

@ -2593,13 +2593,9 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
}
//----------------------------------------------------------------------
void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def,
void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
VectorOfStrings& vec)
{
if ( !def)
{
return;
}
const char* dval = mf->GetDefinition(def);
if ( !dval )
{
@ -2620,12 +2616,9 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def,
}
//----------------------------------------------------------------------
void cmCTest::PopulateCustomInteger(cmMakefile* mf, const char* def, int& val)
void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def,
int& val)
{
if ( !def)
{
return;
}
const char* dval = mf->GetDefinition(def);
if ( !dval )
{
@ -2702,7 +2695,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
}
//----------------------------------------------------------------------
std::string cmCTest::GetCTestConfiguration(const char *name)
std::string cmCTest::GetCTestConfiguration(const std::string& name)
{
if ( this->CTestConfigurationOverwrites.find(name) !=
this->CTestConfigurationOverwrites.end() )
@ -2877,7 +2870,7 @@ void cmCTest::SetConfigType(const char* ct)
//----------------------------------------------------------------------
bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
const char* dconfig, const char* cmake_var)
const char* dconfig, const std::string& cmake_var)
{
const char* ctvar;
ctvar = mf->GetDefinition(cmake_var);

View File

@ -172,7 +172,7 @@ public:
std::string GetTestModelString();
static int GetTestModelFromString(const char* str);
static std::string CleanString(const std::string& str);
std::string GetCTestConfiguration(const char *name);
std::string GetCTestConfiguration(const std::string& name);
void SetCTestConfiguration(const char *name, const char* value);
void EmptyCTestConfiguration();
@ -185,9 +185,9 @@ public:
//! Set the notes files to be created.
void SetNotesFiles(const char* notes);
void PopulateCustomVector(cmMakefile* mf, const char* definition,
void PopulateCustomVector(cmMakefile* mf, const std::string& definition,
VectorOfStrings& vec);
void PopulateCustomInteger(cmMakefile* mf, const char* def,
void PopulateCustomInteger(cmMakefile* mf, const std::string& def,
int& val);
///! Get the current time as string
@ -332,7 +332,7 @@ public:
* Set the CTest variable from CMake variable
*/
bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
const char* dconfig, const char* cmake_var);
const char* dconfig, const std::string& cmake_var);
//! Make string safe to be send as an URL
static std::string MakeURLSafe(const std::string&);

View File

@ -650,7 +650,7 @@ void cmCacheManager::OutputHelpString(std::ostream& fout,
}
}
void cmCacheManager::RemoveCacheEntry(const char* key)
void cmCacheManager::RemoveCacheEntry(const std::string& key)
{
CacheEntryMap::iterator i = this->Cache.find(key);
if(i != this->Cache.end())
@ -660,7 +660,8 @@ void cmCacheManager::RemoveCacheEntry(const char* key)
}
cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(
const std::string& key)
{
CacheEntryMap::iterator i = this->Cache.find(key);
if(i != this->Cache.end())
@ -676,7 +677,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(
return CacheIterator(*this, key);
}
const char* cmCacheManager::GetCacheValue(const char* key) const
const char* cmCacheManager::GetCacheValue(const std::string& key) const
{
CacheEntryMap::const_iterator i = this->Cache.find(key);
if(i != this->Cache.end() &&
@ -708,7 +709,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const
}
void cmCacheManager::AddCacheEntry(const char* key,
void cmCacheManager::AddCacheEntry(const std::string& key,
const char* value,
const char* helpString,
CacheEntryType type)
@ -767,7 +768,7 @@ void cmCacheManager::CacheIterator::Begin()
this->Position = this->Container.Cache.begin();
}
bool cmCacheManager::CacheIterator::Find(const char* key)
bool cmCacheManager::CacheIterator::Find(const std::string& key)
{
this->Position = this->Container.Cache.find(key);
return !this->IsAtEnd();

View File

@ -53,7 +53,7 @@ public:
{
public:
void Begin();
bool Find(const char*);
bool Find(const std::string&);
bool IsAtEnd() const;
void Next();
const char *GetName() const {
@ -129,7 +129,7 @@ public:
cmCacheManager::CacheIterator GetCacheIterator(const char *key=0);
///! Remove an entry from the cache
void RemoveCacheEntry(const char* key);
void RemoveCacheEntry(const std::string& key);
///! Get the number of entries in the cache
int GetSize() {
@ -142,7 +142,7 @@ public:
CacheEntryType& type);
///! Get a value from the cache given a key
const char* GetCacheValue(const char* key) const;
const char* GetCacheValue(const std::string& key) const;
/** Get the version of CMake that wrote the cache. */
unsigned int GetCacheMajorVersion() const
@ -153,11 +153,11 @@ public:
protected:
///! Add an entry into the cache
void AddCacheEntry(const char* key, const char* value,
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString, CacheEntryType type);
///! Get a cache entry object for a key
CacheEntry *GetCacheEntry(const char *key);
CacheEntry *GetCacheEntry(const std::string& key);
///! Clean out the CMakeFiles directory if no CMakeCache.txt
void CleanCMakeFiles(const char* path);

View File

@ -28,7 +28,7 @@ void cmDefinitions::Reset(cmDefinitions* parent)
//----------------------------------------------------------------------------
cmDefinitions::Def const&
cmDefinitions::GetInternal(const char* key)
cmDefinitions::GetInternal(const std::string& key)
{
MapType::const_iterator i = this->Map.find(key);
if(i != this->Map.end())
@ -46,7 +46,7 @@ cmDefinitions::GetInternal(const char* key)
//----------------------------------------------------------------------------
cmDefinitions::Def const&
cmDefinitions::SetInternal(const char* key, Def const& def)
cmDefinitions::SetInternal(const std::string& key, Def const& def)
{
if(this->Up || def.Exists)
{
@ -71,14 +71,14 @@ cmDefinitions::SetInternal(const char* key, Def const& def)
}
//----------------------------------------------------------------------------
const char* cmDefinitions::Get(const char* key)
const char* cmDefinitions::Get(const std::string& key)
{
Def const& def = this->GetInternal(key);
return def.Exists? def.c_str() : 0;
}
//----------------------------------------------------------------------------
const char* cmDefinitions::Set(const char* key, const char* value)
const char* cmDefinitions::Set(const std::string& key, const char* value)
{
Def const& def = this->SetInternal(key, Def(value));
return def.Exists? def.c_str() : 0;

View File

@ -35,10 +35,10 @@ public:
/** Get the value associated with a key; null if none.
Store the result locally if it came from a parent. */
const char* Get(const char* key);
const char* Get(const std::string& key);
/** Set (or unset if null) a value associated with a key. */
const char* Set(const char* key, const char* value);
const char* Set(const std::string& key, const char* value);
/** Get the set of all local keys. */
std::set<cmStdString> LocalKeys() const;
@ -69,8 +69,8 @@ private:
MapType Map;
// Internal query and update methods.
Def const& GetInternal(const char* key);
Def const& SetInternal(const char* key, Def const& def);
Def const& GetInternal(const std::string& key);
Def const& SetInternal(const std::string& key, Def const& def);
// Implementation of Closure() method.
struct ClosureTag {};

View File

@ -151,7 +151,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName,
const cmStdString& outputName,
const std::string& outputName,
cmTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,

View File

@ -174,7 +174,7 @@ protected:
std::set<cmTarget*> ExportedTargets;
private:
void PopulateInterfaceProperty(const std::string&, const cmStdString&,
void PopulateInterfaceProperty(const std::string&, const std::string&,
cmTarget *target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,

View File

@ -268,7 +268,7 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
}
//----------------------------------------------------------------------------
void cmFindBase::AddCMakePrefixPath(const char* variable)
void cmFindBase::AddCMakePrefixPath(const std::string& variable)
{
// Get a path from a CMake variable.
if(const char* varPath = this->Makefile->GetDefinition(variable))
@ -280,11 +280,11 @@ void cmFindBase::AddCMakePrefixPath(const char* variable)
}
//----------------------------------------------------------------------------
void cmFindBase::AddEnvPrefixPath(const char* variable)
void cmFindBase::AddEnvPrefixPath(const std::string& variable)
{
// Get a path from the environment.
std::vector<std::string> tmp;
cmSystemTools::GetPath(tmp, variable);
cmSystemTools::GetPath(tmp, variable.c_str());
this->AddPrefixPaths(tmp, EnvPath);
}

View File

@ -63,8 +63,8 @@ private:
void AddUserGuessPath();
// Helpers.
void AddCMakePrefixPath(const char* variable);
void AddEnvPrefixPath(const char* variable);
void AddCMakePrefixPath(const std::string& variable);
void AddEnvPrefixPath(const std::string& variable);
void AddPrefixPaths(std::vector<std::string> const& in_paths,
PathType pathType);
};

View File

@ -374,7 +374,7 @@ void cmFindCommon::AddUserPath(std::string const& p,
}
//----------------------------------------------------------------------------
void cmFindCommon::AddCMakePath(const char* variable)
void cmFindCommon::AddCMakePath(const std::string& variable)
{
// Get a path from a CMake variable.
if(const char* varPath = this->Makefile->GetDefinition(variable))

View File

@ -63,7 +63,7 @@ protected:
void AddPathSuffix(std::string const& arg);
void AddUserPath(std::string const& p,
std::vector<std::string>& paths);
void AddCMakePath(const char* variable);
void AddCMakePath(const std::string& variable);
void AddEnvPath(const char* variable);
void AddPathsInternal(std::vector<std::string> const& in_paths,
PathType pathType);

View File

@ -535,7 +535,8 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
}
//----------------------------------------------------------------------------
void cmFindPackageCommand::AddFindDefinition(const char* var, const char* val)
void cmFindPackageCommand::AddFindDefinition(const std::string& var,
const char* val)
{
if(const char* old = this->Makefile->GetDefinition(var))
{

View File

@ -57,7 +57,7 @@ private:
void AppendToFoundProperty(bool found);
void SetModuleVariables(const std::string& components);
bool FindModule(bool& found);
void AddFindDefinition(const char* var, const char* val);
void AddFindDefinition(const std::string& var, const char* val);
void RestoreFindDefinitions();
bool HandlePackageMode();
bool FindConfig();

View File

@ -593,7 +593,7 @@ namespace
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
*(argP1) == "MATCHES")
{
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
def = cmIfCommand::GetVariableOrString(*arg, makefile);
const char* rex = (argP2)->c_str();
cmStringCommand::ClearMatches(makefile);
cmsys::RegularExpression regEntry;
@ -634,8 +634,8 @@ namespace
(*(argP1) == "LESS" || *(argP1) == "GREATER" ||
*(argP1) == "EQUAL"))
{
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
def = cmIfCommand::GetVariableOrString(*arg, makefile);
def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
double lhs;
double rhs;
bool result;
@ -665,8 +665,8 @@ namespace
*(argP1) == "STREQUAL" ||
*(argP1) == "STRGREATER"))
{
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
def = cmIfCommand::GetVariableOrString(*arg, makefile);
def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
int val = strcmp(def,def2);
bool result;
if (*(argP1) == "STRLESS")
@ -689,8 +689,8 @@ namespace
(*(argP1) == "VERSION_LESS" || *(argP1) == "VERSION_GREATER" ||
*(argP1) == "VERSION_EQUAL"))
{
def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
def = cmIfCommand::GetVariableOrString(*arg, makefile);
def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL;
if(*argP1 == "VERSION_LESS")
{
@ -907,13 +907,13 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
}
//=========================================================================
const char* cmIfCommand::GetVariableOrString(const char* str,
const char* cmIfCommand::GetVariableOrString(const std::string& str,
const cmMakefile* mf)
{
const char* def = mf->GetDefinition(str);
if(!def)
{
def = str;
def = str.c_str();
}
return def;
}

View File

@ -79,7 +79,7 @@ public:
// Get a definition from the makefile. If it doesn't exist,
// return the original string.
static const char* GetVariableOrString(const char* str,
static const char* GetVariableOrString(const std::string& str,
const cmMakefile* mf);
cmTypeMacro(cmIfCommand, cmCommand);

View File

@ -74,12 +74,9 @@ bool cmListCommand
}
//----------------------------------------------------------------------------
bool cmListCommand::GetListString(std::string& listString, const char* var)
bool cmListCommand::GetListString(std::string& listString,
const std::string& var)
{
if ( !var )
{
return false;
}
// get the old value
const char* cacheValue
= this->Makefile->GetDefinition(var);
@ -92,7 +89,8 @@ bool cmListCommand::GetListString(std::string& listString, const char* var)
}
//----------------------------------------------------------------------------
bool cmListCommand::GetList(std::vector<std::string>& list, const char* var)
bool cmListCommand::GetList(std::vector<std::string>& list,
const std::string& var)
{
std::string listString;
if ( !this->GetListString(listString, var) )

View File

@ -60,8 +60,8 @@ protected:
bool HandleReverseCommand(std::vector<std::string> const& args);
bool GetList(std::vector<std::string>& list, const char* var);
bool GetListString(std::string& listString, const char* var);
bool GetList(std::vector<std::string>& list, const std::string& var);
bool GetListString(std::string& listString, const std::string& var);
};

View File

@ -2324,7 +2324,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
const char* var,
const std::string& var,
const char* config)
{
// Add the flags from the variable itself.

View File

@ -145,7 +145,7 @@ public:
std::string const& lang, const char *config);
void AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
const char *lang);
void AddConfigVariableFlags(std::string& flags, const char* var,
void AddConfigVariableFlags(std::string& flags, const std::string& var,
const char* config);
///! Append flags to a string.
virtual void AppendFlags(std::string& flags, const char* newFlags);

View File

@ -1769,7 +1769,7 @@ cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
}
}
void cmMakefile::AddDefinition(const char* name, const char* value)
void cmMakefile::AddDefinition(const std::string& name, const char* value)
{
if (!value )
{
@ -1798,14 +1798,14 @@ void cmMakefile::AddDefinition(const char* name, const char* value)
}
void cmMakefile::AddCacheDefinition(const char* name, const char* value,
void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
const char* doc,
cmCacheManager::CacheEntryType type,
bool force)
{
const char* val = value;
cmCacheManager::CacheIterator it =
this->GetCacheManager()->GetCacheIterator(name);
this->GetCacheManager()->GetCacheIterator(name.c_str());
if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) &&
it.Initialized())
{
@ -1845,7 +1845,7 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value,
}
void cmMakefile::AddDefinition(const char* name, bool value)
void cmMakefile::AddDefinition(const std::string& name, bool value)
{
this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
if (this->Internal->VarUsageStack.size() &&
@ -1880,12 +1880,12 @@ void cmMakefile::CheckForUnusedVariables() const
}
}
void cmMakefile::MarkVariableAsUsed(const char* var)
void cmMakefile::MarkVariableAsUsed(const std::string& var)
{
this->Internal->VarUsageStack.top().insert(var);
}
bool cmMakefile::VariableInitialized(const char* var) const
bool cmMakefile::VariableInitialized(const std::string& var) const
{
if(this->Internal->VarInitStack.top().find(var) !=
this->Internal->VarInitStack.top().end())
@ -1895,7 +1895,7 @@ bool cmMakefile::VariableInitialized(const char* var) const
return false;
}
bool cmMakefile::VariableUsed(const char* var) const
bool cmMakefile::VariableUsed(const std::string& var) const
{
if(this->Internal->VarUsageStack.top().find(var) !=
this->Internal->VarUsageStack.top().end())
@ -1905,7 +1905,8 @@ bool cmMakefile::VariableUsed(const char* var) const
return false;
}
void cmMakefile::CheckForUnused(const char* reason, const char* name) const
void cmMakefile::CheckForUnused(const char* reason,
const std::string& name) const
{
if (this->WarnUnused && !this->VariableUsed(name))
{
@ -1943,7 +1944,7 @@ void cmMakefile::CheckForUnused(const char* reason, const char* name) const
}
}
void cmMakefile::RemoveDefinition(const char* name)
void cmMakefile::RemoveDefinition(const std::string& name)
{
this->Internal->VarStack.top().Set(name, 0);
if (this->Internal->VarUsageStack.size() &&
@ -1963,7 +1964,7 @@ void cmMakefile::RemoveDefinition(const char* name)
#endif
}
void cmMakefile::RemoveCacheDefinition(const char* name)
void cmMakefile::RemoveCacheDefinition(const std::string& name)
{
this->GetCacheManager()->RemoveCacheEntry(name);
}
@ -2329,13 +2330,13 @@ void cmMakefile::ExpandVariablesCMP0019()
}
}
bool cmMakefile::IsOn(const char* name) const
bool cmMakefile::IsOn(const std::string& name) const
{
const char* value = this->GetDefinition(name);
return cmSystemTools::IsOn(value);
}
bool cmMakefile::IsSet(const char* name) const
bool cmMakefile::IsSet(const std::string& name) const
{
const char* value = this->GetDefinition(name);
if ( !value )
@ -2406,7 +2407,7 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) const
return true;
}
const char* cmMakefile::GetRequiredDefinition(const char* name) const
const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
{
const char* ret = this->GetDefinition(name);
if(!ret)
@ -2414,13 +2415,13 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const
cmSystemTools::Error("Error required internal CMake variable not "
"set, cmake may be not be built correctly.\n",
"Missing variable is:\n",
name);
name.c_str());
return "";
}
return ret;
}
bool cmMakefile::IsDefinitionSet(const char* name) const
bool cmMakefile::IsDefinitionSet(const std::string& name) const
{
const char* def = this->Internal->VarStack.top().Get(name);
this->Internal->VarUsageStack.top().insert(name);
@ -2442,7 +2443,7 @@ bool cmMakefile::IsDefinitionSet(const char* name) const
return def?true:false;
}
const char* cmMakefile::GetDefinition(const char* name) const
const char* cmMakefile::GetDefinition(const std::string& name) const
{
if (this->WarnUnused)
{
@ -2483,7 +2484,7 @@ const char* cmMakefile::GetDefinition(const char* name) const
return def;
}
const char* cmMakefile::GetSafeDefinition(const char* def) const
const char* cmMakefile::GetSafeDefinition(const std::string& def) const
{
const char* ret = this->GetDefinition(def);
if(!ret)
@ -3995,7 +3996,7 @@ void cmMakefile::PopScope()
}
}
void cmMakefile::RaiseScope(const cmStdString& var, const char *varDef)
void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
{
if (var.empty())
{

View File

@ -69,11 +69,11 @@ public:
/* Check for unused variables in this scope */
void CheckForUnusedVariables() const;
/* Mark a variable as used */
void MarkVariableAsUsed(const char* var);
void MarkVariableAsUsed(const std::string& var);
/* return true if a variable has been initialized */
bool VariableInitialized(const char* ) const;
bool VariableInitialized(const std::string& ) const;
/* return true if a variable has been used */
bool VariableUsed(const char* ) const;
bool VariableUsed(const std::string& ) const;
/** Return whether compatibility features needed for a version of
the cache or lower should be enabled. */
bool NeedCacheCompatibility(int major, int minor) const;
@ -283,9 +283,9 @@ public:
* Add a variable definition to the build. This variable
* can be used in CMake to refer to lists, directories, etc.
*/
void AddDefinition(const char* name, const char* value);
void AddDefinition(const std::string& name, const char* value);
///! Add a definition to this makefile and the global cmake cache.
void AddCacheDefinition(const char* name, const char* value,
void AddCacheDefinition(const std::string& name, const char* value,
const char* doc,
cmCacheManager::CacheEntryType type,
bool force = false);
@ -293,15 +293,15 @@ public:
/**
* Add bool variable definition to the build.
*/
void AddDefinition(const char* name, bool);
void AddDefinition(const std::string& name, bool);
/**
* Remove a variable definition from the build. This is not valid
* for cache entries, and will only affect the current makefile.
*/
void RemoveDefinition(const char* name);
void RemoveDefinition(const std::string& name);
///! Remove a definition from the cache.
void RemoveCacheDefinition(const char* name);
void RemoveCacheDefinition(const std::string& name);
/**
* Specify the name of the project for this build.
@ -587,10 +587,10 @@ public:
* If the variable is not found in this makefile instance, the
* cache is then queried.
*/
const char* GetDefinition(const char*) const;
const char* GetSafeDefinition(const char*) const;
const char* GetRequiredDefinition(const char* name) const;
bool IsDefinitionSet(const char*) const;
const char* GetDefinition(const std::string&) const;
const char* GetSafeDefinition(const std::string&) const;
const char* GetRequiredDefinition(const std::string& name) const;
bool IsDefinitionSet(const std::string&) const;
/**
* Get the list of all variables in the current space. If argument
* cacheonly is specified and is greater than 0, then only cache
@ -601,8 +601,8 @@ public:
/** Test a boolean cache entry to see if it is true or false,
* returns false if no entry defined.
*/
bool IsOn(const char* name) const;
bool IsSet(const char* name) const;
bool IsOn(const std::string& name) const;
bool IsSet(const std::string& name) const;
/** Return whether the target platform is 64-bit. */
bool PlatformIs64Bit() const;
@ -837,7 +837,7 @@ public:
// push and pop variable scopes
void PushScope();
void PopScope();
void RaiseScope(const cmStdString& var, const char *value);
void RaiseScope(const std::string& var, const char *value);
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
@ -882,7 +882,7 @@ protected:
void AddGlobalLinkInformation(const char* name, cmTarget& target);
// Check for a an unused variable
void CheckForUnused(const char* reason, const char* name) const;
void CheckForUnused(const char* reason, const std::string& name) const;
std::string Prefix;
std::vector<std::string> AuxSourceDirectories; //

View File

@ -237,7 +237,7 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteLibraryRules
(const char* linkRuleVar, const char* extraFlags, bool relink)
(const std::string& linkRuleVar, const std::string& extraFlags, bool relink)
{
// TODO: Merge the methods that call this method to avoid
// code duplication.
@ -261,7 +261,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Create set of linking flags.
std::string linkFlags;
this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
this->LocalGenerator->AppendFlags(linkFlags, extraFlags.c_str());
// Add OSX version flags, if any.
if(this->Target->GetType() == cmTarget::SHARED_LIBRARY ||

View File

@ -30,7 +30,8 @@ protected:
void WriteStaticLibraryRules();
void WriteSharedLibraryRules(bool relink);
void WriteModuleLibraryRules(bool relink);
void WriteLibraryRules(const char *linkRule, const char *extraFlags,
void WriteLibraryRules(const std::string& linkRule,
const std::string& extraFlags,
bool relink);
// MacOSX Framework support methods
void WriteFrameworkRules(bool relink);

View File

@ -1682,7 +1682,8 @@ void cmMakefileTargetGenerator
}
//----------------------------------------------------------------------------
std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
std::string cmMakefileTargetGenerator::GetLinkRule(
const cmStdString& linkRuleVar)
{
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
if(this->Target->HasImplibGNUtoMS())

View File

@ -138,7 +138,7 @@ protected:
void AppendLinkDepends(std::vector<std::string>& depends);
// Lookup the link rule for this target.
std::string GetLinkRule(const char* linkRuleVar);
std::string GetLinkRule(const cmStdString& linkRuleVar);
/** In order to support parallel builds for custom commands with
multiple outputs the outputs are given a serial order, and only

View File

@ -15,7 +15,7 @@
//----------------------------------------------------------------------------
cmScriptGenerator
::cmScriptGenerator(const char* config_var,
::cmScriptGenerator(const std::string& config_var,
std::vector<std::string> const& configurations):
RuntimeConfigVariable(config_var),
Configurations(configurations),

View File

@ -47,7 +47,7 @@ inline std::ostream& operator<<(std::ostream& os,
class cmScriptGenerator
{
public:
cmScriptGenerator(const char* config_var,
cmScriptGenerator(const std::string& config_var,
std::vector<std::string> const& configurations);
virtual ~cmScriptGenerator();

View File

@ -1202,7 +1202,7 @@ struct SaveCacheEntry
cmCacheManager::CacheEntryType type;
};
int cmake::HandleDeleteCacheVariables(const char* var)
int cmake::HandleDeleteCacheVariables(const std::string& var)
{
std::vector<std::string> argsSplit;
cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true);
@ -1725,7 +1725,7 @@ int cmake::Generate()
return 0;
}
void cmake::AddCacheEntry(const char* key, const char* value,
void cmake::AddCacheEntry(const std::string& key, const char* value,
const char* helpString,
int type)
{
@ -1734,7 +1734,7 @@ void cmake::AddCacheEntry(const char* key, const char* value,
cmCacheManager::CacheEntryType(type));
}
const char* cmake::GetCacheDefinition(const char* name) const
const char* cmake::GetCacheDefinition(const std::string& name) const
{
return this->CacheManager->GetCacheValue(name);
}
@ -2676,7 +2676,7 @@ int cmake::Build(const std::string& dir,
nativeOptions);
}
void cmake::WatchUnusedCli(const char* var)
void cmake::WatchUnusedCli(const std::string& var)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
@ -2687,7 +2687,7 @@ void cmake::WatchUnusedCli(const char* var)
#endif
}
void cmake::UnwatchUnusedCli(const char* var)
void cmake::UnwatchUnusedCli(const std::string& var)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning);

View File

@ -203,9 +203,9 @@ class cmake
/**
* Given a variable name, return its value (as a string).
*/
const char* GetCacheDefinition(const char*) const;
const char* GetCacheDefinition(const std::string&) const;
///! Add an entry into the cache
void AddCacheEntry(const char* key, const char* value,
void AddCacheEntry(const std::string& key, const char* value,
const char* helpString,
int type);
@ -357,12 +357,12 @@ class cmake
const std::vector<std::string>& nativeOptions,
bool clean);
void UnwatchUnusedCli(const char* var);
void WatchUnusedCli(const char* var);
void UnwatchUnusedCli(const std::string& var);
void WatchUnusedCli(const std::string& var);
protected:
void RunCheckForUnusedVariables();
void InitializeProperties();
int HandleDeleteCacheVariables(const char* var);
int HandleDeleteCacheVariables(const std::string& var);
cmPropertyMap Properties;
std::set<std::pair<cmStdString,cmProperty::ScopeType> > AccessedProperties;