mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
cmIDEOptions: use std::string instead of const char*
Revise method signatures to save a few c_str() conversions.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user