mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 21:00:17 -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;
|
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;
|
this->FlagMap[flag] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmIDEOptions::AddFlag(const char* flag,
|
void cmIDEOptions::AddFlag(std::string const& flag,
|
||||||
std::vector<std::string> const& value)
|
std::vector<std::string> const& value)
|
||||||
{
|
{
|
||||||
this->FlagMap[flag] = value;
|
this->FlagMap[flag] = value;
|
||||||
@@ -185,7 +185,7 @@ void cmIDEOptions::AppendFlagString(std::string const& flag,
|
|||||||
this->FlagMap[flag].append_with_space(value);
|
this->FlagMap[flag].append_with_space(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmIDEOptions::RemoveFlag(const char* flag)
|
void cmIDEOptions::RemoveFlag(std::string const& flag)
|
||||||
{
|
{
|
||||||
this->FlagMap.erase(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();
|
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!
|
// This method works only for single-valued flags!
|
||||||
std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(flag);
|
std::map<std::string, FlagValue>::const_iterator i =
|
||||||
if (i != this->FlagMap.end() && i->second.size() == 1) {
|
this->FlagMap.find(flag);
|
||||||
|
if (i != this->FlagMap.cend() && i->second.size() == 1) {
|
||||||
return i->second[0].c_str();
|
return i->second[0].c_str();
|
||||||
}
|
}
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,15 +26,15 @@ public:
|
|||||||
void AddDefines(const std::vector<std::string>& defines);
|
void AddDefines(const std::vector<std::string>& defines);
|
||||||
std::vector<std::string> const& GetDefines() const;
|
std::vector<std::string> const& GetDefines() const;
|
||||||
|
|
||||||
void AddFlag(const char* flag, const char* value);
|
void AddFlag(std::string const& flag, std::string const& value);
|
||||||
void AddFlag(const char* flag, std::vector<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::string const& value);
|
||||||
void AppendFlag(std::string const& flag,
|
void AppendFlag(std::string const& flag,
|
||||||
std::vector<std::string> const& value);
|
std::vector<std::string> const& value);
|
||||||
void AppendFlagString(std::string const& flag, 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;
|
bool HasFlag(std::string const& flag) const;
|
||||||
const char* GetFlag(const char* flag);
|
const char* GetFlag(std::string const& flag) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// create a map of xml tags to the values they should have in the output
|
// 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);
|
Options targetOptions(this, t, table, gg->ExtraFlagTable);
|
||||||
targetOptions.FixExceptionHandlingDefault();
|
targetOptions.FixExceptionHandlingDefault();
|
||||||
std::string asmLocation = configName + "/";
|
std::string asmLocation = configName + "/";
|
||||||
targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
|
targetOptions.AddFlag("AssemblerListingLocation", asmLocation);
|
||||||
targetOptions.Parse(flags.c_str());
|
targetOptions.Parse(flags.c_str());
|
||||||
targetOptions.Parse(defineFlags.c_str());
|
targetOptions.Parse(defineFlags.c_str());
|
||||||
targetOptions.ParseFinish();
|
targetOptions.ParseFinish();
|
||||||
@@ -1007,7 +1007,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
|
|||||||
if (mdi && !mdi->DefFile.empty()) {
|
if (mdi && !mdi->DefFile.empty()) {
|
||||||
std::string defFile =
|
std::string defFile =
|
||||||
this->ConvertToOutputFormat(mdi->DefFile, cmOutputConverter::SHELL);
|
this->ConvertToOutputFormat(mdi->DefFile, cmOutputConverter::SHELL);
|
||||||
linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
|
linkOptions.AddFlag("ModuleDefinitionFile", defFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (target->GetType()) {
|
switch (target->GetType()) {
|
||||||
|
|||||||
@@ -2448,7 +2448,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
|||||||
clOptions.FixExceptionHandlingDefault();
|
clOptions.FixExceptionHandlingDefault();
|
||||||
clOptions.AddFlag("PrecompiledHeader", "NotUsing");
|
clOptions.AddFlag("PrecompiledHeader", "NotUsing");
|
||||||
std::string asmLocation = configName + "/";
|
std::string asmLocation = configName + "/";
|
||||||
clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
|
clOptions.AddFlag("AssemblerListingLocation", asmLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clOptions.Parse(flags.c_str());
|
clOptions.Parse(flags.c_str());
|
||||||
@@ -3315,8 +3315,8 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
|
|||||||
imLib += "/";
|
imLib += "/";
|
||||||
imLib += targetNameImport;
|
imLib += targetNameImport;
|
||||||
|
|
||||||
linkOptions.AddFlag("ImportLibrary", imLib.c_str());
|
linkOptions.AddFlag("ImportLibrary", imLib);
|
||||||
linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
|
linkOptions.AddFlag("ProgramDataBaseFile", pdb);
|
||||||
|
|
||||||
// A Windows Runtime component uses internal .NET metadata,
|
// A Windows Runtime component uses internal .NET metadata,
|
||||||
// so does not have an import library.
|
// so does not have an import library.
|
||||||
@@ -3337,7 +3337,7 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
|
|||||||
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
|
linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
|
||||||
}
|
}
|
||||||
} else if (this->NsightTegra) {
|
} else if (this->NsightTegra) {
|
||||||
linkOptions.AddFlag("SoName", targetNameSO.c_str());
|
linkOptions.AddFlag("SoName", targetNameSO);
|
||||||
}
|
}
|
||||||
|
|
||||||
linkOptions.Parse(flags.c_str());
|
linkOptions.Parse(flags.c_str());
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration()
|
|||||||
|
|
||||||
void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
|
void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
|
||||||
{
|
{
|
||||||
static const char* ENABLE_UAC = "EnableUAC";
|
static std::string const ENABLE_UAC = "EnableUAC";
|
||||||
if (!HasFlag(ENABLE_UAC)) {
|
if (!HasFlag(ENABLE_UAC)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -304,8 +304,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddFlag(uacMap[keyValue[0]].c_str(),
|
AddFlag(uacMap[keyValue[0]], uacExecuteLevelMap[keyValue[1]]);
|
||||||
uacExecuteLevelMap[keyValue[1]].c_str());
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,7 +313,7 @@ void cmVisualStudioGeneratorOptions::FixManifestUACFlags()
|
|||||||
// unknown uiAccess value
|
// unknown uiAccess value
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AddFlag(uacMap[keyValue[0]].c_str(), keyValue[1].c_str());
|
AddFlag(uacMap[keyValue[0]], keyValue[1]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user