stringapi: Use strings for AddString methods
It gets turned into a string anyways, so pass them in.
This commit is contained in:
parent
9f48d3bac2
commit
b26c70cc9a
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue