1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-21 06:10:16 +08:00

cmVisualStudio10TargetGenerator: use std::string for tag

This commit is contained in:
Vitaly Stakhovsky
2019-11-10 09:29:27 -05:00
parent a9c0959900
commit 64843b1737
6 changed files with 25 additions and 24 deletions

View File

@@ -2053,7 +2053,7 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(
} }
void cmVS7GeneratorOptions::OutputFlag(std::ostream& fout, int indent, void cmVS7GeneratorOptions::OutputFlag(std::ostream& fout, int indent,
const char* flag, const std::string& flag,
const std::string& content) const std::string& content)
{ {
fout.fill('\t'); fout.fill('\t');

View File

@@ -30,7 +30,7 @@ public:
: cmVisualStudioGeneratorOptions(lg, tool, table, extraTable) : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable)
{ {
} }
void OutputFlag(std::ostream& fout, int indent, const char* tag, void OutputFlag(std::ostream& fout, int indent, const std::string& tag,
const std::string& content) override; const std::string& content) override;
}; };

View File

@@ -52,7 +52,7 @@ struct cmVisualStudio10TargetGenerator::Elem
bool HasContent = false; bool HasContent = false;
std::string Tag; std::string Tag;
Elem(std::ostream& s, const char* tag) Elem(std::ostream& s, const std::string& tag)
: S(s) : S(s)
, Indent(0) , Indent(0)
, Tag(tag) , Tag(tag)
@@ -60,7 +60,7 @@ struct cmVisualStudio10TargetGenerator::Elem
this->StartElement(); this->StartElement();
} }
Elem(const Elem&) = delete; Elem(const Elem&) = delete;
Elem(Elem& par, const char* tag) Elem(Elem& par, const std::string& tag)
: S(par.S) : S(par.S)
, Indent(par.Indent + 1) , Indent(par.Indent + 1)
, Tag(tag) , Tag(tag)
@@ -77,7 +77,7 @@ struct cmVisualStudio10TargetGenerator::Elem
} }
std::ostream& WriteString(const char* line); std::ostream& WriteString(const char* line);
void StartElement() { this->WriteString("<") << this->Tag; } void StartElement() { this->WriteString("<") << this->Tag; }
void Element(const char* tag, const std::string& val) void Element(const std::string& tag, const std::string& val)
{ {
Elem(*this, tag).Content(val); Elem(*this, tag).Content(val);
} }
@@ -115,7 +115,7 @@ struct cmVisualStudio10TargetGenerator::Elem
} }
} }
void WritePlatformConfigTag(const char* tag, const std::string& cond, void WritePlatformConfigTag(const std::string& tag, const std::string& cond,
const std::string& content); const std::string& content);
}; };
@@ -131,8 +131,8 @@ public:
{ {
} }
void OutputFlag(std::ostream& /*fout*/, int /*indent*/, const char* tag, void OutputFlag(std::ostream& /*fout*/, int /*indent*/,
const std::string& content) override const std::string& tag, const std::string& content) override
{ {
if (!this->GetConfiguration().empty()) { if (!this->GetConfiguration().empty()) {
// if there are configuration specific flags, then // if there are configuration specific flags, then
@@ -274,7 +274,7 @@ std::string cmVisualStudio10TargetGenerator::CalcCondition(
} }
void cmVisualStudio10TargetGenerator::Elem::WritePlatformConfigTag( void cmVisualStudio10TargetGenerator::Elem::WritePlatformConfigTag(
const char* tag, const std::string& cond, const std::string& content) const std::string& tag, const std::string& cond, const std::string& content)
{ {
Elem(*this, tag).Attribute("Condition", cond).Content(content); Elem(*this, tag).Attribute("Condition", cond).Content(content);
} }
@@ -562,7 +562,7 @@ void cmVisualStudio10TargetGenerator::Generate()
const char* value = this->GeneratorTarget->GetProperty(keyIt); const char* value = this->GeneratorTarget->GetProperty(keyIt);
if (!value) if (!value)
continue; continue;
e1.Element(globalKey.c_str(), value); e1.Element(globalKey, value);
} }
if (this->Managed) { if (this->Managed) {
@@ -913,7 +913,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags(
} }
} }
for (auto const& tag : tags) { for (auto const& tag : tags) {
e2.Element(tag.first.c_str(), tag.second); e2.Element(tag.first, tag.second);
} }
} }
@@ -1019,7 +1019,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
if (!tagName.empty()) { if (!tagName.empty()) {
std::string value = props.GetPropertyValue(p); std::string value = props.GetPropertyValue(p);
if (!value.empty()) { if (!value.empty()) {
e2.Element(tagName.c_str(), value); e2.Element(tagName, value);
} }
} }
} }
@@ -1751,7 +1751,7 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources(
std::string const& filter = sourceGroup->GetFullName(); std::string const& filter = sourceGroup->GetFullName();
std::string path = this->ConvertPath(source, s.RelativePath); std::string path = this->ConvertPath(source, s.RelativePath);
ConvertToWindowsSlash(path); ConvertToWindowsSlash(path);
Elem e2(e1, name.c_str()); Elem e2(e1, name);
e2.Attribute("Include", path); e2.Attribute("Include", path);
if (!filter.empty()) { if (!filter.empty()) {
e2.Element("Filter", filter); e2.Element("Filter", filter);
@@ -2637,9 +2637,9 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
// Some link options belong here. Use them now and remove them so that // Some link options belong here. Use them now and remove them so that
// WriteLinkOptions does not use them. // WriteLinkOptions does not use them.
const char* flags[] = { "LinkDelaySign", "LinkKeyFile", 0 }; static const std::vector<std::string> flags{ "LinkDelaySign",
for (const char** f = flags; *f; ++f) { "LinkKeyFile" };
const char* flag = *f; for (const std::string& flag : flags) {
if (const char* value = linkOptions.GetFlag(flag)) { if (const char* value = linkOptions.GetFlag(flag)) {
e1.WritePlatformConfigTag(flag, cond, value); e1.WritePlatformConfigTag(flag, cond, value);
linkOptions.RemoveFlag(flag); linkOptions.RemoveFlag(flag);
@@ -4040,8 +4040,8 @@ void cmVisualStudio10TargetGenerator::WriteEvents(
} }
void cmVisualStudio10TargetGenerator::WriteEvent( void cmVisualStudio10TargetGenerator::WriteEvent(
Elem& e1, const char* name, std::vector<cmCustomCommand> const& commands, Elem& e1, const std::string& name,
std::string const& configName) std::vector<cmCustomCommand> const& commands, std::string const& configName)
{ {
if (commands.empty()) { if (commands.empty()) {
return; return;
@@ -4860,7 +4860,7 @@ void cmVisualStudio10TargetGenerator::WriteCSharpSourceProperties(
Elem& e2, const std::map<std::string, std::string>& tags) Elem& e2, const std::map<std::string, std::string>& tags)
{ {
for (const auto& i : tags) { for (const auto& i : tags) {
e2.Element(i.first.c_str(), i.second); e2.Element(i.first, i.second);
} }
} }

View File

@@ -165,7 +165,7 @@ private:
void WriteLibOptions(Elem& e1, std::string const& config); void WriteLibOptions(Elem& e1, std::string const& config);
void WriteManifestOptions(Elem& e1, std::string const& config); void WriteManifestOptions(Elem& e1, std::string const& config);
void WriteEvents(Elem& e1, std::string const& configName); void WriteEvents(Elem& e1, std::string const& configName);
void WriteEvent(Elem& e1, const char* name, void WriteEvent(Elem& e1, std::string const& name,
std::vector<cmCustomCommand> const& commands, std::vector<cmCustomCommand> const& commands,
std::string const& configName); std::string const& configName);
void WriteGroupSources(Elem& e0, std::string const& name, void WriteGroupSources(Elem& e0, std::string const& name,

View File

@@ -431,7 +431,7 @@ void cmVisualStudioGeneratorOptions::OutputPreprocessorDefinitions(
if (this->Defines.empty()) { if (this->Defines.empty()) {
return; return;
} }
const char* tag = "PreprocessorDefinitions"; std::string tag = "PreprocessorDefinitions";
if (lang == "CUDA") { if (lang == "CUDA") {
tag = "Defines"; tag = "Defines";
} }
@@ -473,7 +473,7 @@ void cmVisualStudioGeneratorOptions::OutputAdditionalIncludeDirectories(
return; return;
} }
const char* tag = "AdditionalIncludeDirectories"; std::string tag = "AdditionalIncludeDirectories";
if (lang == "CUDA") { if (lang == "CUDA") {
tag = "Include"; tag = "Include";
} else if (lang == "ASM_MASM" || lang == "ASM_NASM") { } else if (lang == "ASM_MASM" || lang == "ASM_NASM") {
@@ -528,6 +528,6 @@ void cmVisualStudioGeneratorOptions::OutputFlagMap(std::ostream& fout,
sep = ";"; sep = ";";
} }
this->OutputFlag(fout, indent, m.first.c_str(), oss.str()); this->OutputFlag(fout, indent, m.first, oss.str());
} }
} }

View File

@@ -86,7 +86,8 @@ public:
const std::string& GetConfiguration() const; const std::string& GetConfiguration() const;
protected: protected:
virtual void OutputFlag(std::ostream& fout, int indent, const char* tag, virtual void OutputFlag(std::ostream& fout, int indent,
const std::string& tag,
const std::string& content) = 0; const std::string& content) = 0;
private: private: