summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx81
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h1
2 files changed, 50 insertions, 32 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index b56104e..b6ba814 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -28,14 +28,23 @@ static std::string cmVS10EscapeXML(std::string arg)
return arg;
}
+static std::string cmVS10EscapeAttr(std::string arg)
+{
+ cmSystemTools::ReplaceString(arg, "&", "&");
+ cmSystemTools::ReplaceString(arg, "<", "&lt;");
+ cmSystemTools::ReplaceString(arg, ">", "&gt;");
+ cmSystemTools::ReplaceString(arg, "\"", "&quot;");
+ return arg;
+}
+
struct cmVisualStudio10TargetGenerator::Elem
{
- cmGeneratedFileStream& S;
+ std::ostream& S;
int Indent;
bool HasElements = false;
const char* Tag = nullptr;
- Elem(cmGeneratedFileStream& s, int i)
+ Elem(std::ostream& s, int i)
: S(s)
, Indent(i)
{
@@ -61,7 +70,7 @@ struct cmVisualStudio10TargetGenerator::Elem
HasElements = true;
}
}
- cmGeneratedFileStream& WriteString(const char* line);
+ std::ostream& WriteString(const char* line);
void StartElement(const char* tag)
{
this->Tag = tag;
@@ -72,11 +81,20 @@ struct cmVisualStudio10TargetGenerator::Elem
{
this->WriteString("<") << tag << ">" << val << "</" << tag << ">\n";
}
+ void Element(const char* tag, const std::string& val)
+ {
+ Elem(*this).WriteElem(tag, cmVS10EscapeXML(val));
+ }
template <typename T>
void Attr(const char* an, const T& av)
{
this->S << " " << an << "=\"" << av << "\"";
}
+ Elem& Attribute(const char* an, const std::string& av)
+ {
+ Attr(an, cmVS10EscapeAttr(av));
+ return *this;
+ }
void WriteEndTag(const char* tag)
{
if (HasElements) {
@@ -139,15 +157,6 @@ inline void cmVisualStudio10TargetGenerator::WriteElemEscapeXML(
this->WriteElem(tag, cmVS10EscapeXML(val), indentLevel);
}
-static std::string cmVS10EscapeAttr(std::string arg)
-{
- cmSystemTools::ReplaceString(arg, "&", "&amp;");
- cmSystemTools::ReplaceString(arg, "<", "&lt;");
- cmSystemTools::ReplaceString(arg, ">", "&gt;");
- cmSystemTools::ReplaceString(arg, "\"", "&quot;");
- return arg;
-}
-
static std::string cmVS10EscapeComment(std::string comment)
{
// MSBuild takes the CDATA of a <Message></Message> element and just
@@ -238,38 +247,46 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
delete this->BuildFileStream;
}
+std::string cmVisualStudio10TargetGenerator::CalcCondition(
+ const std::string& config) const
+{
+ std::ostringstream oss;
+ oss << "'$(Configuration)|$(Platform)'=='";
+ oss << config << "|" << this->Platform;
+ oss << "'";
+ // handle special case for 32 bit C# targets
+ if (this->ProjectType == csproj && this->Platform == "Win32") {
+ oss << " Or ";
+ oss << "'$(Configuration)|$(Platform)'=='";
+ oss << config << "|x86";
+ oss << "'";
+ }
+ return oss.str();
+}
+
void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
const char* tag, const std::string& config, int indentLevel,
const char* attribute)
{
- std::ostream* stream = this->BuildFileStream;
- stream->fill(' ');
- stream->width(indentLevel * 2);
- (*stream) << ""; // applies indentation
- (*stream) << "<" << tag << " Condition=\"";
- (*stream) << "'$(Configuration)|$(Platform)'=='";
- (*stream) << config << "|" << this->Platform;
- (*stream) << "'";
- // handle special case for 32 bit C# targets
- if (this->ProjectType == csproj && this->Platform == "Win32") {
- (*stream) << " Or ";
- (*stream) << "'$(Configuration)|$(Platform)'=='";
- (*stream) << config << "|x86";
- (*stream) << "'";
- }
- (*stream) << "\"";
+ std::ostream& stream = *this->BuildFileStream;
+ stream.fill(' ');
+ stream.width(indentLevel * 2);
+ stream << ""; // applies indentation
+ stream << "<" << tag << " Condition=\"";
+ stream << this->CalcCondition(config);
+ stream << "\"";
if (attribute) {
- (*stream) << attribute;
+ stream << attribute;
}
// close the tag
- (*stream) << ">";
+ stream << ">";
if (attribute) {
- (*stream) << "\n";
+ stream << "\n";
}
}
-cmGeneratedFileStream& cmVisualStudio10TargetGenerator::Elem::WriteString(
+std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
const char* line)
{
this->S.fill(' ');
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 3c53d1b..02939ac 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -33,6 +33,7 @@ public:
~cmVisualStudio10TargetGenerator();
void Generate();
// used by cmVisualStudioGeneratorOptions
+ std::string CalcCondition(const std::string& config) const;
void WritePlatformConfigTag(const char* tag, const std::string& config,
int indentLevel, const char* attribute = 0);