mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-24 07:08:38 -05:00
strings: compare to static string_view instances in Windows-only code
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <cm/memory>
|
||||
#include <cm/string_view>
|
||||
#include <cmext/algorithm>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include "cmsys/Directory.hxx"
|
||||
#include "cmsys/Encoding.hxx"
|
||||
@@ -556,7 +557,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
|
||||
bool emitUninstallShortcut = true;
|
||||
cmValue cpackWixProgramMenuFolder =
|
||||
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
|
||||
if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
|
||||
if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == "."_s) {
|
||||
emitUninstallShortcut = false;
|
||||
} else if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) ==
|
||||
emittedShortcutTypes.end()) {
|
||||
@@ -613,7 +614,7 @@ std::string cmCPackWIXGenerator::GetRootFolderId() const
|
||||
result = *rootFolderId;
|
||||
}
|
||||
|
||||
if (GetArchitecture() == "x86") {
|
||||
if (GetArchitecture() == "x86"_s) {
|
||||
cmSystemTools::ReplaceString(result, "<64>", "");
|
||||
} else {
|
||||
cmSystemTools::ReplaceString(result, "<64>", "64");
|
||||
@@ -757,7 +758,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
|
||||
case cmWIXShortcuts::START_MENU: {
|
||||
cmValue cpackWixProgramMenuFolder =
|
||||
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
|
||||
if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == ".") {
|
||||
if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder == "."_s) {
|
||||
directoryId = "ProgramMenuFolder";
|
||||
} else {
|
||||
directoryId = "PROGRAM_MENU_FOLDER";
|
||||
@@ -818,7 +819,7 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
|
||||
if (type == cmWIXShortcuts::START_MENU) {
|
||||
cmValue cpackWixProgramMenuFolder =
|
||||
GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
|
||||
if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != ".") {
|
||||
if (cpackWixProgramMenuFolder && cpackWixProgramMenuFolder != "."_s) {
|
||||
fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
|
||||
idSuffix);
|
||||
}
|
||||
@@ -851,10 +852,10 @@ bool cmCPackWIXGenerator::CreateLicenseFile()
|
||||
|
||||
std::string extension = GetRightmostExtension(licenseSourceFilename);
|
||||
|
||||
if (extension == ".rtf") {
|
||||
if (extension == ".rtf"_s) {
|
||||
cmSystemTools::CopyAFile(licenseSourceFilename.c_str(),
|
||||
licenseDestinationFilename.c_str());
|
||||
} else if (extension == ".txt") {
|
||||
} else if (extension == ".txt"_s) {
|
||||
cmWIXRichTextFormatWriter rtfWriter(licenseDestinationFilename);
|
||||
|
||||
cmsys::ifstream licenseSource(licenseSourceFilename.c_str());
|
||||
@@ -923,7 +924,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitions(
|
||||
for (size_t i = 0; i < dir.GetNumberOfFiles(); ++i) {
|
||||
std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
|
||||
|
||||
if (fileName == "." || fileName == "..") {
|
||||
if (fileName == "."_s || fileName == ".."_s) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1001,7 +1002,7 @@ std::string cmCPackWIXGenerator::GetArchitecture() const
|
||||
std::string void_p_size;
|
||||
RequireOption("CPACK_WIX_SIZEOF_VOID_P", void_p_size);
|
||||
|
||||
if (void_p_size == "8") {
|
||||
if (void_p_size == "8"_s) {
|
||||
return "x64";
|
||||
} else {
|
||||
return "x86";
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmWIXDirectoriesSourceWriter.h"
|
||||
|
||||
#include <cmext/string_view>
|
||||
|
||||
cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(
|
||||
cmCPackLog* logger, std::string const& filename, GuidType componentGuidType)
|
||||
: cmWIXSourceWriter(logger, filename, componentGuidType)
|
||||
@@ -14,7 +16,7 @@ void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
|
||||
BeginElement("Directory");
|
||||
AddAttribute("Id", "ProgramMenuFolder");
|
||||
|
||||
if (startMenuFolder != ".") {
|
||||
if (startMenuFolder != "."_s) {
|
||||
BeginElement("Directory");
|
||||
AddAttribute("Id", "PROGRAM_MENU_FOLDER");
|
||||
AddAttribute("Name", startMenuFolder);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include <cm/memory>
|
||||
#include <cmext/string_view>
|
||||
|
||||
#include <cm3p/expat.h>
|
||||
|
||||
@@ -39,13 +40,13 @@ cmWIXPatchParser::cmWIXPatchParser(fragment_map_t& fragments,
|
||||
void cmWIXPatchParser::StartElement(const std::string& name, const char** atts)
|
||||
{
|
||||
if (State == BEGIN_DOCUMENT) {
|
||||
if (name == "CPackWiXPatch") {
|
||||
if (name == "CPackWiXPatch"_s) {
|
||||
State = BEGIN_FRAGMENTS;
|
||||
} else {
|
||||
ReportValidationError("Expected root element 'CPackWiXPatch'");
|
||||
}
|
||||
} else if (State == BEGIN_FRAGMENTS) {
|
||||
if (name == "CPackWiXFragment") {
|
||||
if (name == "CPackWiXFragment"_s) {
|
||||
State = INSIDE_FRAGMENT;
|
||||
StartFragment(atts);
|
||||
} else {
|
||||
@@ -78,7 +79,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
|
||||
const std::string key = attributes[i];
|
||||
const std::string value = attributes[i + 1];
|
||||
|
||||
if (key == "Id") {
|
||||
if (key == "Id"_s) {
|
||||
if (Fragments.find(value) != Fragments.end()) {
|
||||
std::ostringstream tmp;
|
||||
tmp << "Invalid reuse of 'CPackWixFragment' 'Id': " << value;
|
||||
@@ -98,7 +99,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
|
||||
const std::string key = attributes[i];
|
||||
const std::string value = attributes[i + 1];
|
||||
|
||||
if (key != "Id") {
|
||||
if (key != "Id"_s) {
|
||||
new_element->attributes[key] = value;
|
||||
}
|
||||
}
|
||||
@@ -108,7 +109,7 @@ void cmWIXPatchParser::StartFragment(const char** attributes)
|
||||
void cmWIXPatchParser::EndElement(const std::string& name)
|
||||
{
|
||||
if (State == INSIDE_FRAGMENT) {
|
||||
if (name == "CPackWiXFragment") {
|
||||
if (name == "CPackWiXFragment"_s) {
|
||||
State = BEGIN_FRAGMENTS;
|
||||
ElementStack.clear();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user