From 8d4a9ee398ef85b4f59a8e2b966d9675d7e53f44 Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Mon, 27 Apr 2020 16:38:14 +0200 Subject: Refactoring: rename "cm_static_string_view.hxx" as --- Source/CMakeLists.txt | 1 - Source/CTest/cmCTestBuildCommand.cxx | 2 +- Source/CTest/cmCTestConfigureCommand.cxx | 2 +- Source/CTest/cmCTestCoverageCommand.cxx | 3 +-- Source/CTest/cmCTestHandlerCommand.cxx | 2 +- Source/CTest/cmCTestMemCheckCommand.cxx | 2 +- Source/CTest/cmCTestSubmitCommand.cxx | 3 +-- Source/CTest/cmCTestTestCommand.cxx | 2 +- Source/CTest/cmCTestTestHandler.cxx | 2 +- Source/CTest/cmCTestUploadCommand.cxx | 3 +-- Source/cmArgumentParser.h | 3 +-- Source/cmCTest.cxx | 3 +-- Source/cmConfigureFileCommand.cxx | 3 +-- Source/cmCoreTryCompile.cxx | 4 +-- Source/cmExecuteProcessCommand.cxx | 3 +-- Source/cmExportCommand.cxx | 3 +-- Source/cmFileCommand.cxx | 2 +- Source/cmForEachCommand.cxx | 3 +-- Source/cmFunctionCommand.cxx | 3 +-- Source/cmGeneratorExpressionDAGChecker.cxx | 3 +-- Source/cmGeneratorExpressionNode.cxx | 3 +-- Source/cmGeneratorTarget.cxx | 3 +-- Source/cmIfCommand.cxx | 3 +-- Source/cmInstallCommand.cxx | 3 +-- Source/cmInstallCommandArguments.cxx | 2 +- Source/cmListCommand.cxx | 3 +-- Source/cmMacroCommand.cxx | 3 +-- Source/cmMakefile.cxx | 2 +- Source/cmMessageCommand.cxx | 3 +-- Source/cmString.hxx | 3 +-- Source/cmStringCommand.cxx | 3 +-- Source/cmSubcommandTable.h | 3 +-- Source/cmWhileCommand.cxx | 3 +-- Source/cm_static_string_view.hxx | 41 ----------------------------- Source/cmake.cxx | 2 +- Tests/CMakeLib/testArgumentParser.cxx | 3 +-- Tests/CMakeLib/testString.cxx | 3 +-- Utilities/std/CMakeLists.txt | 3 ++- Utilities/std/cmext/string_view | 42 ++++++++++++++++++++++++++++++ 39 files changed, 80 insertions(+), 103 deletions(-) delete mode 100644 Source/cm_static_string_view.hxx create mode 100644 Utilities/std/cmext/string_view diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 564e647..ec473d2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -698,7 +698,6 @@ set(SRCS cmWriteFileCommand.cxx cmWriteFileCommand.h - cm_static_string_view.hxx cm_get_date.h cm_get_date.c cm_utf8.h diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index d1b7701..44fdc29 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -5,7 +5,7 @@ #include #include -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestBuildHandler.h" diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 3854710..f42c3f1 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -6,7 +6,7 @@ #include #include -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestConfigureHandler.h" diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index e335923..7432d08 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -5,8 +5,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestCoverageHandler.h" diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index b1034c9..a755632 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -7,7 +7,7 @@ #include #include -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx index 39dec6d..d0e2974 100644 --- a/Source/CTest/cmCTestMemCheckCommand.cxx +++ b/Source/CTest/cmCTestMemCheckCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestMemCheckCommand.h" -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestMemCheckHandler.h" diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 5b2f2e6..279216e 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -9,8 +9,7 @@ #include #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestSubmitHandler.h" diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 6b317cb..c71b409 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -6,7 +6,7 @@ #include #include -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 2408d57..ef6955d 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -20,13 +20,13 @@ #include #include #include +#include #include "cmsys/FStream.hxx" #include #include #include -#include "cm_static_string_view.hxx" #include "cm_utf8.h" #include "cmCTest.h" diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index eaef1ca..f86ee0d 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -6,8 +6,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmCTest.h" #include "cmCTestUploadHandler.h" diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index 9426537..5d2dfa2 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -12,8 +12,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include namespace ArgumentParser { diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index c2b2a09..2a0ddba1 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -19,6 +19,7 @@ #include #include #include +#include #include "cmsys/Base64.h" #include "cmsys/Directory.hxx" @@ -36,8 +37,6 @@ # include // IWYU pragma: keep #endif -#include "cm_static_string_view.hxx" - #include "cmCTestBuildAndTestHandler.h" #include "cmCTestBuildHandler.h" #include "cmCTestConfigureHandler.h" diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index bac9337..5b3045d 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -5,8 +5,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index dc2df14..4e2caed 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -8,9 +8,9 @@ #include #include -#include "cmsys/Directory.hxx" +#include -#include "cm_static_string_view.hxx" +#include "cmsys/Directory.hxx" #include "cmExportTryCompileFileGenerator.h" #include "cmGlobalGenerator.h" diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 08a0f7e..9c53bdf 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -10,11 +10,10 @@ #include #include +#include #include "cmsys/Process.h" -#include "cm_static_string_view.hxx" - #include "cmArgumentParser.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index ad632ee..9f8a821 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -8,11 +8,10 @@ #include #include +#include #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmArgumentParser.h" #include "cmExecutionStatus.h" #include "cmExportBuildAndroidMKGenerator.h" diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4ec128e..161bbe8 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -17,13 +17,13 @@ #include #include +#include #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" #include "cm_kwiml.h" -#include "cm_static_string_view.hxx" #include "cm_sys_stat.h" #include "cmAlgorithms.h" diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 0546186..6e64e6d 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -18,8 +18,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index a4c9072..b6f58bd 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -7,8 +7,7 @@ #include #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index b4ba1a1..4f379cd 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -7,8 +7,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmGeneratorExpressionContext.h" #include "cmGeneratorExpressionEvaluator.h" diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index d48427e..947601e 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -17,12 +17,11 @@ #include #include #include +#include #include "cmsys/RegularExpression.hxx" #include "cmsys/String.h" -#include "cm_static_string_view.hxx" - #include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionContext.h" diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fd863a3..44a20fc 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -18,11 +18,10 @@ #include #include #include +#include #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" #include "cmCustomCommand.h" diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 290e064..5808f90 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -7,8 +7,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c9b22b6..ac57bc2 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -8,11 +8,10 @@ #include #include +#include #include "cmsys/Glob.hxx" -#include "cm_static_string_view.hxx" - #include "cmArgumentParser.h" #include "cmExecutionStatus.h" #include "cmExportSet.h" diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 31ba63f..a034689 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -4,7 +4,7 @@ #include -#include "cm_static_string_view.hxx" +#include #include "cmRange.h" #include "cmSystemTools.h" diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 1d82dfc..edec613 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -17,11 +17,10 @@ #include #include +#include #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmAlgorithms.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 0b0d9ac..c88b343 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -8,8 +8,7 @@ #include #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 028b0f5..979b9d8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -18,13 +18,13 @@ #include #include #include +#include #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include "cm_jsoncpp_value.h" #include "cm_jsoncpp_writer.h" -#include "cm_static_string_view.hxx" #include "cm_sys_stat.h" #include "cmCommandArgumentParserHelper.h" diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index bf8183b..c7bb9a7 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -6,8 +6,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmString.hxx b/Source/cmString.hxx index 9e91986..87bfdff 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -16,8 +16,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include namespace cm { diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 7662204..a7c21cc 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -11,11 +11,10 @@ #include #include +#include #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" diff --git a/Source/cmSubcommandTable.h b/Source/cmSubcommandTable.h index 65eb8c7..7deaaed 100644 --- a/Source/cmSubcommandTable.h +++ b/Source/cmSubcommandTable.h @@ -11,8 +11,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include class cmExecutionStatus; diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 26e7c75..0d8e894 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -7,8 +7,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cm_static_string_view.hxx b/Source/cm_static_string_view.hxx deleted file mode 100644 index 708ac95..0000000 --- a/Source/cm_static_string_view.hxx +++ /dev/null @@ -1,41 +0,0 @@ -/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying - file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_static_string_view_hxx -#define cm_static_string_view_hxx - -#include "cmConfigure.h" // IWYU pragma: keep - -#include - -#include - -namespace cm { - -/** A string_view that only binds to static storage. - * - * This is used together with the `""_s` user-defined literal operator - * to construct a type-safe abstraction of a string_view that only views - * statically allocated strings. These strings are const and available - * for the entire lifetime of the program. - */ -class static_string_view : public string_view -{ - static_string_view(string_view v) - : string_view(v) - { - } - - friend static_string_view operator"" _s(const char* data, size_t size); -}; - -/** Create a static_string_view using `""_s` literal syntax. */ -inline static_string_view operator"" _s(const char* data, size_t size) -{ - return string_view(data, size); -} - -} // namespace cm - -using cm::operator"" _s; - -#endif diff --git a/Source/cmake.cxx b/Source/cmake.cxx index c619e1e..c8a1e76 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -19,12 +19,12 @@ #endif #include +#include #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" #include "cm_sys_stat.h" #include "cmCommands.h" diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx index 20f98c2..965690c 100644 --- a/Tests/CMakeLib/testArgumentParser.cxx +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -7,8 +7,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmArgumentParser.h" diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index 1fd3f38..539f2dd 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -12,8 +12,7 @@ #include #include - -#include "cm_static_string_view.hxx" +#include #include "cmString.hxx" diff --git a/Utilities/std/CMakeLists.txt b/Utilities/std/CMakeLists.txt index a72abb7..17a7aaa 100644 --- a/Utilities/std/CMakeLists.txt +++ b/Utilities/std/CMakeLists.txt @@ -9,6 +9,7 @@ set(SRCS cm/bits/string_view.cxx cm/optional cm/shared_mutex cm/string_view - cm/utility) + cm/utility + cmext/string_view) add_library(cmstd STATIC ${SRCS}) diff --git a/Utilities/std/cmext/string_view b/Utilities/std/cmext/string_view new file mode 100644 index 0000000..ad52b11 --- /dev/null +++ b/Utilities/std/cmext/string_view @@ -0,0 +1,42 @@ +// -*-c++-*- +// vim: set ft=cpp: + +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmext_string_view +#define cmext_string_view + +#include + +#include + +namespace cm { + +/** A string_view that only binds to static storage. + * + * This is used together with the `""_s` user-defined literal operator + * to construct a type-safe abstraction of a string_view that only views + * statically allocated strings. These strings are const and available + * for the entire lifetime of the program. + */ +class static_string_view : public string_view +{ + static_string_view(string_view v) + : string_view(v) + { + } + + friend static_string_view operator"" _s(const char* data, size_t size); +}; + +/** Create a static_string_view using `""_s` literal syntax. */ +inline static_string_view operator"" _s(const char* data, size_t size) +{ + return string_view(data, size); +} + +} // namespace cm + +using cm::operator"" _s; + +#endif -- cgit v0.12