Merge topic 'xcode-attribute-conditions'

c519bb2 XCode: Also qoute [] as needed to set build-configurations.
This commit is contained in:
Brad King 2011-04-12 14:43:29 -04:00 committed by CMake Topic Stage
commit 89460b7fd7
2 changed files with 21 additions and 10 deletions

View File

@ -146,13 +146,15 @@ void cmXCodeObject::Print(std::ostream& out)
if(j->second->TypeValue == STRING) if(j->second->TypeValue == STRING)
{ {
out << j->first << " = "; cmXCodeObject::PrintString(out,j->first);
out << " = ";
j->second->PrintString(out); j->second->PrintString(out);
out << ";"; out << ";";
} }
else if(j->second->TypeValue == OBJECT_LIST) else if(j->second->TypeValue == OBJECT_LIST)
{ {
out << j->first << " = ("; cmXCodeObject::PrintString(out,j->first);
out << " = (";
for(unsigned int k = 0; k < j->second->List.size(); k++) for(unsigned int k = 0; k < j->second->List.size(); k++)
{ {
if(j->second->List[k]->TypeValue == STRING) if(j->second->List[k]->TypeValue == STRING)
@ -169,7 +171,8 @@ void cmXCodeObject::Print(std::ostream& out)
} }
else else
{ {
out << j->first << " = error_unexpected_TypeValue_" << cmXCodeObject::PrintString(out,j->first);
out << " = error_unexpected_TypeValue_" <<
j->second->TypeValue << ";"; j->second->TypeValue << ";";
} }
@ -180,7 +183,8 @@ void cmXCodeObject::Print(std::ostream& out)
} }
else if(object->TypeValue == OBJECT_REF) else if(object->TypeValue == OBJECT_REF)
{ {
out << i->first << " = " << object->Object->Id; cmXCodeObject::PrintString(out,i->first);
out << " = " << object->Object->Id;
if(object->Object->HasComment() && i->first != "remoteGlobalIDString") if(object->Object->HasComment() && i->first != "remoteGlobalIDString")
{ {
out << " "; out << " ";
@ -190,7 +194,8 @@ void cmXCodeObject::Print(std::ostream& out)
} }
else if(object->TypeValue == STRING) else if(object->TypeValue == STRING)
{ {
out << i->first << " = "; cmXCodeObject::PrintString(out,i->first);
out << " = ";
object->PrintString(out); object->PrintString(out);
out << ";" << separator; out << ";" << separator;
} }
@ -230,19 +235,19 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmXCodeObject::PrintString(std::ostream& os) const void cmXCodeObject::PrintString(std::ostream& os,cmStdString String)
{ {
// The string needs to be quoted if it contains any characters // The string needs to be quoted if it contains any characters
// considered special by the Xcode project file parser. // considered special by the Xcode project file parser.
bool needQuote = bool needQuote =
(this->String.empty() || (String.empty() ||
this->String.find_first_of(" <>.+-=@$") != this->String.npos); String.find_first_of(" <>.+-=@$[]") != String.npos);
const char* quote = needQuote? "\"" : ""; const char* quote = needQuote? "\"" : "";
// Print the string, quoted and escaped as necessary. // Print the string, quoted and escaped as necessary.
os << quote; os << quote;
for(std::string::const_iterator i = this->String.begin(); for(std::string::const_iterator i = String.begin();
i != this->String.end(); ++i) i != String.end(); ++i)
{ {
if(*i == '"') if(*i == '"')
{ {
@ -254,6 +259,11 @@ void cmXCodeObject::PrintString(std::ostream& os) const
os << quote; os << quote;
} }
void cmXCodeObject::PrintString(std::ostream& os) const
{
cmXCodeObject::PrintString(os,this->String);
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmXCodeObject::SetString(const char* s) void cmXCodeObject::SetString(const char* s)
{ {

View File

@ -141,6 +141,7 @@ public:
} }
std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;} std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
void SetComment(const char* c) { this->Comment = c;} void SetComment(const char* c) { this->Comment = c;}
static void PrintString(std::ostream& os,cmStdString String);
protected: protected:
void PrintString(std::ostream& os) const; void PrintString(std::ostream& os) const;