diff options
author | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2018-05-22 15:01:54 (GMT) |
---|---|---|
committer | Vitaly Stakhovsky <vvs31415@gitlab.org> | 2018-05-25 13:28:54 (GMT) |
commit | 726c09029729673cf66386bafb7152b2d3b55466 (patch) | |
tree | 98fe58de855fcb437580063ff0af003526d5254c /Source/cmVisualStudio10TargetGenerator.cxx | |
parent | 266fd716540f0e83879de01a82f289caf35c463b (diff) | |
download | CMake-726c09029729673cf66386bafb7152b2d3b55466.zip CMake-726c09029729673cf66386bafb7152b2d3b55466.tar.gz CMake-726c09029729673cf66386bafb7152b2d3b55466.tar.bz2 |
cmVisualStudio10TargetGenerator: close XML tag in Elem destructor
RAII actually implemented; EndElement() still kept to avoid major reformatting
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index fa6c8ad..b373dce 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -42,6 +42,7 @@ struct cmVisualStudio10TargetGenerator::Elem std::ostream& S; const int Indent; bool HasElements = false; + bool HasContent = false; std::string Tag; Elem(std::ostream& s) @@ -79,8 +80,7 @@ struct cmVisualStudio10TargetGenerator::Elem } void Element(const char* tag, const std::string& val) { - Elem(*this).WriteString("<") << tag << ">" << cmVS10EscapeXML(val) << "</" - << tag << ">\n"; + Elem(*this, tag).Content(val); } Elem& Attribute(const char* an, const std::string& av) { @@ -88,13 +88,17 @@ struct cmVisualStudio10TargetGenerator::Elem return *this; } // This method for now assumes that this->Tag has been set, e.g. by calling - // StartElement(). Also, it finishes the element so it should be the last - // one called + // StartElement(). void Content(const std::string& val) { - S << ">" << cmVS10EscapeXML(val) << "</" << this->Tag << ">\n"; + if (!this->HasContent) { + this->S << ">"; + this->HasContent = true; + } + this->S << cmVS10EscapeXML(val); } - void EndElement() + void EndElement() {} + ~Elem() { // Do not emit element which has not been started if (Tag.empty()) { @@ -108,6 +112,8 @@ struct cmVisualStudio10TargetGenerator::Elem } else { // special case: don't print EOL at EOF } + } else if (HasContent) { + this->S << "</" << this->Tag << ">\n"; } else { this->S << " />\n"; } |