stringapi: Use strings for AddString methods

It gets turned into a string anyways, so pass them in.
This commit is contained in:
Ben Boeckel 2014-02-03 21:16:12 -05:00 committed by Brad King
parent 9f48d3bac2
commit b26c70cc9a
6 changed files with 11 additions and 11 deletions

View File

@ -49,14 +49,14 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file)
this->FileName = file;
}
char* cmCommandArgumentParserHelper::AddString(const char* str)
char* cmCommandArgumentParserHelper::AddString(const std::string& str)
{
if ( !str || !*str )
if ( str.empty() )
{
return this->EmptyVariable;
}
char* stVal = new char[strlen(str)+1];
strcpy(stVal, str);
char* stVal = new char[str.size()+1];
strcpy(stVal, str.c_str());
this->Variables.push_back(stVal);
return stVal;
}
@ -153,7 +153,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
{
return this->AddString(cmSystemTools::EscapeQuotes(value).c_str());
}
return this->AddString(value);
return this->AddString(value ? value : "");
}
char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
@ -166,7 +166,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
// then return an empty string
if(!ret && this->RemoveEmpty)
{
return this->AddString(ret);
return this->AddString("");
}
// if the ret was not 0, then return it
if(ret)

View File

@ -86,7 +86,7 @@ private:
void Print(const char* place, const char* str);
void SafePrintMissing(const char* str, int line, int cnt);
char* AddString(const char* str);
char* AddString(const std::string& str);
void CleanupParser();
void SetError(std::string const& msg);

View File

@ -613,7 +613,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
//----------------------------------------------------------------------------
cmXCodeObject*
cmGlobalXCodeGenerator::CreateString(const char* s)
cmGlobalXCodeGenerator::CreateString(const std::string& s)
{
cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING);
obj->SetString(s);

View File

@ -135,7 +135,7 @@ private:
// correctly. All objects created are stored in this->XCodeObjects.
cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype);
cmXCodeObject* CreateObject(cmXCodeObject::Type type);
cmXCodeObject* CreateString(const char* s);
cmXCodeObject* CreateString(const std::string& s);
cmXCodeObject* CreateObjectReference(cmXCodeObject*);
cmXCodeObject* CreateXCodeTarget(cmTarget& target,
cmXCodeObject* buildPhases);

View File

@ -266,7 +266,7 @@ void cmXCodeObject::PrintString(std::ostream& os) const
}
//----------------------------------------------------------------------------
void cmXCodeObject::SetString(const char* s)
void cmXCodeObject::SetString(const std::string& s)
{
this->String = s;
}

View File

@ -37,7 +37,7 @@ public:
Type GetType() { return this->TypeValue;}
PBXType GetIsA() { return this->IsA;}
void SetString(const char* s);
void SetString(const std::string& s);
const char* GetString()
{
return this->String.c_str();