summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Stakhovsky <vvs31415@gitlab.org>2017-12-09 03:30:16 (GMT)
committerVitaly Stakhovsky <vvs31415@gitlab.org>2017-12-09 03:30:16 (GMT)
commitc62ffdcd4f6f638a7d57221528ffbe112887c1b4 (patch)
tree53ff5991e05654bc9105a8a439e2058f8193d683
parentd25bcab161bfccb43cbeb43dfe96c805e2c27530 (diff)
downloadCMake-c62ffdcd4f6f638a7d57221528ffbe112887c1b4.zip
CMake-c62ffdcd4f6f638a7d57221528ffbe112887c1b4.tar.gz
CMake-c62ffdcd4f6f638a7d57221528ffbe112887c1b4.tar.bz2
cmIDEOptions: use std::string instead of const char*
Revise method signatures to save a few c_str() conversions.
-rw-r--r--Source/cmIDEOptions.cxx15
-rw-r--r--Source/cmIDEOptions.h8
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx8
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx7
5 files changed, 21 insertions, 21 deletions
diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx
index 5e872d2..4b59f44 100644
--- a/Source/cmIDEOptions.cxx
+++ b/Source/cmIDEOptions.cxx
@@ -155,12 +155,12 @@ std::vector<std::string> const& cmIDEOptions::GetDefines() const
return this->Defines;
}
-void cmIDEOptions::AddFlag(const char* flag, const char* value)
+void cmIDEOptions::AddFlag(std::string const& flag, std::string const& value)
{
this->FlagMap[flag] = value;
}
-void cmIDEOptions::AddFlag(const char* flag,
+void cmIDEOptions::AddFlag(std::string const& flag,
std::vector<std::string> const& value)
{
this->FlagMap[flag] = value;
@@ -185,7 +185,7 @@ void cmIDEOptions::AppendFlagString(std::string const& flag,
this->FlagMap[flag].append_with_space(value);
}
-void cmIDEOptions::RemoveFlag(const char* flag)
+void cmIDEOptions::RemoveFlag(std::string const& flag)
{
this->FlagMap.erase(flag);
}
@@ -195,12 +195,13 @@ bool cmIDEOptions::HasFlag(std::string const& flag) const
return this->FlagMap.find(flag) != this->FlagMap.end();
}
-const char* cmIDEOptions::GetFlag(const char* flag)
+const char* cmIDEOptions::GetFlag(std::string const& flag) const
{
// This method works only for single-valued flags!
- std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(flag);
- if (i != this->FlagMap.end() && i->second.size() == 1) {
+ std::map<std::string, FlagValue>::const_iterator i =
+ this->FlagMap.find(flag);
+ if (i != this->FlagMap.cend() && i->second.size() == 1) {
return i->second[0].c_str();
}
- return 0;
+ return nullptr;
}
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h
index af03128..ded92ca 100644
--- a/Source/cmIDEOptions.h
+++ b/Source/cmIDEOptions.h
@@ -26,15 +26,15 @@ public:
void AddDefines(const std::vector<std::string>& defines);
std::vector<std::string> const& GetDefines() const;
- void AddFlag(const char* flag, const char* value);
- void AddFlag(const char* flag, std::vector<std::string> const& value);
+ void AddFlag(std::string const& flag, std::string const& value);
+ void AddFlag(std::string const& flag, std::vector<std::string> const& value);
void AppendFlag(std::string const& flag, std::string const& value);
void AppendFlag(std::string const& flag,
std::vector<std::string> const& value);
void AppendFlagString(std::string const& flag, std::string const& value);
- void RemoveFlag(const char* flag);
+ void RemoveFlag(std::string const& flag);
bool HasFlag(std::string const& flag) const;
- const char* GetFlag(const char* flag);
+ const char* GetFlag(std::string const& flag) const;
protected:
// create a map of xml tags to the values they should have in the output
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 53966cd..47e6d7d 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -701,7 +701,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
Options targetOptions(this, t, table, gg->ExtraFlagTable);
targetOptions.FixExceptionHandlingDefault();
std::string asmLocation = configName + "/";
- targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
+ targetOptions.AddFlag("AssemblerListingLocation", asmLocation);
targetOptions.Parse(flags.c_str());
targetOptions.Parse(defineFlags.c_str());
targetOptions.ParseFinish();
@@ -1007,7 +1007,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
if (mdi && !mdi->DefFile.empty()) {
std::string defFile =
this->ConvertToOutputFormat(mdi->DefFile, cmOutputConverter::SHELL);
- linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
+ linkOptions.AddFlag("ModuleDefinitionFile", defFile);
}
switch (target->GetType()) {
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 8589a96..fd2f899 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -2448,7 +2448,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
clOptions.FixExceptionHandlingDefault();
clOptions.AddFlag("PrecompiledHeader", "NotUsing");
std::string asmLocation = configName + "/";
- clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
+ clOptions.AddFlag("AssemblerListingLocation", asmLocation);
}
}
clOptions.Parse(flags.c_str());
@@ -3315,8 +3315,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
imLib += "/";
imLib += targetNameImport;
- linkOptions.AddFlag("ImportLibrary", imLib.c_str());
- linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
+ linkOptions.AddFlag("ImportLibrary", imLib);
+ linkOptions.AddFlag("ProgramDataBaseFile", pdb);
// A Windows Runtime component uses internal .NET metadata,
// so does not have an import library.
@@ -3337,7 +3337,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
}
} else if (this->NsightTegra) {
- linkOptions.AddFlag("SoName", targetNameSO.c_str());
+ linkOptions.AddFlag("SoName", targetNameSO);
}
linkOptions.Parse(flags.c_str());
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index b1686be..4f3d737 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -258,7 +258,7 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
{
- static const char* ENABLE_UAC = "EnableUAC";
+ static std::string const ENABLE_UAC = "EnableUAC";
if (!HasFlag(ENABLE_UAC)) {
return;
}
@@ -304,8 +304,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
continue;
}
- AddFlag(uacMap[keyValue[0]].c_str(),
- uacExecuteLevelMap[keyValue[1]].c_str());
+ AddFlag(uacMap[keyValue[0]], uacExecuteLevelMap[keyValue[1]]);
continue;
}
@@ -314,7 +313,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
// unknown uiAccess value
continue;
}
- AddFlag(uacMap[keyValue[0]].c_str(), keyValue[1].c_str());
+ AddFlag(uacMap[keyValue[0]], keyValue[1]);
continue;
}