mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
Merge topic 'cmStringAlgorithms'
f71f7ce3f0
cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.h
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3618
This commit is contained in:
commit
89dc04af1d
@ -142,6 +142,7 @@ set(SRCS
|
||||
|
||||
cmAffinity.cxx
|
||||
cmAffinity.h
|
||||
cmAlgorithms.h
|
||||
cmArchiveWrite.cxx
|
||||
cmArgumentParser.cxx
|
||||
cmArgumentParser.h
|
||||
@ -403,6 +404,7 @@ set(SRCS
|
||||
cmStateSnapshot.cxx
|
||||
cmStateSnapshot.h
|
||||
cmStateTypes.h
|
||||
cmStringAlgorithms.h
|
||||
cmSystemTools.cxx
|
||||
cmSystemTools.h
|
||||
cmTarget.cxx
|
||||
|
@ -2,9 +2,9 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmCPackNuGetGenerator.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCPackComponentGroup.h"
|
||||
#include "cmCPackLog.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmXMLWriter.h"
|
||||
|
||||
|
@ -10,11 +10,11 @@
|
||||
#include <time.h>
|
||||
#include <vector>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCTest.h"
|
||||
#include "cmCTestVC.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmProcessTools.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
static unsigned int cmCTestGITVersion(unsigned int epic, unsigned int major,
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "cmDuration.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmXMLParser.h"
|
||||
#include "cmake.h"
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCTest.h"
|
||||
#include "cmCTestMultiProcessHandler.h"
|
||||
#include "cmCommand.h"
|
||||
@ -30,6 +29,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmWorkingDirectory.h"
|
||||
#include "cmXMLWriter.h"
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include "cmParseGTMCoverage.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCTest.h"
|
||||
#include "cmCTestCoverageHandler.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
#include "cmsys/Directory.hxx"
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmDocumentation.h"
|
||||
#include "cmDocumentationEntry.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmVersion.h"
|
||||
#include "cmake.h"
|
||||
#include "cmsys/CommandLineArguments.hxx"
|
||||
|
@ -6,41 +6,14 @@
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include "cmRange.h"
|
||||
|
||||
#include "cm_kwiml.h"
|
||||
#include "cm_string_view.hxx"
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
struct cmStrCmp
|
||||
{
|
||||
cmStrCmp(const char* test)
|
||||
: m_test(test)
|
||||
{
|
||||
}
|
||||
cmStrCmp(std::string test)
|
||||
: m_test(std::move(test))
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(const std::string& input) const { return m_test == input; }
|
||||
|
||||
bool operator()(const char* input) const
|
||||
{
|
||||
return strcmp(input, m_test.c_str()) == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_test;
|
||||
};
|
||||
|
||||
template <typename FwdIt>
|
||||
FwdIt cmRotate(FwdIt first, FwdIt middle, FwdIt last)
|
||||
{
|
||||
@ -120,8 +93,6 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange;
|
||||
|
||||
class cmListFileBacktrace;
|
||||
typedef cmRange<std::vector<cmListFileBacktrace>::const_iterator>
|
||||
cmBacktraceRange;
|
||||
@ -145,31 +116,6 @@ void cmAppend(std::vector<T>& v, InputIt first, InputIt last)
|
||||
v.insert(v.end(), first, last);
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
std::string cmJoin(Range const& r, const char* delimiter)
|
||||
{
|
||||
if (r.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
std::ostringstream os;
|
||||
typedef typename Range::value_type ValueType;
|
||||
typedef typename Range::const_iterator InputIt;
|
||||
const InputIt first = r.begin();
|
||||
InputIt last = r.end();
|
||||
--last;
|
||||
std::copy(first, last, std::ostream_iterator<ValueType>(os, delimiter));
|
||||
|
||||
os << *last;
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
std::string cmJoin(Range const& r, std::string const& delimiter)
|
||||
{
|
||||
return cmJoin(r, delimiter.c_str());
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
typename Range::const_iterator cmRemoveN(Range& r, size_t n)
|
||||
{
|
||||
@ -248,23 +194,6 @@ typename Range::const_iterator cmRemoveDuplicates(Range& r)
|
||||
return cmRemoveDuplicates(r.begin(), r.end());
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
std::string cmWrap(std::string const& prefix, Range const& r,
|
||||
std::string const& suffix, std::string const& sep)
|
||||
{
|
||||
if (r.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
return prefix + cmJoin(r, suffix + sep + prefix) + suffix;
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
std::string cmWrap(char prefix, Range const& r, char suffix,
|
||||
std::string const& sep)
|
||||
{
|
||||
return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep);
|
||||
}
|
||||
|
||||
template <typename Range, typename T>
|
||||
typename Range::const_iterator cmFindNot(Range const& r, T const& t)
|
||||
{
|
||||
@ -277,61 +206,6 @@ std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it)
|
||||
return std::reverse_iterator<Iter>(it);
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with the character @a prefix. **/
|
||||
inline bool cmHasPrefix(cm::string_view str, char prefix)
|
||||
{
|
||||
return !str.empty() && (str.front() == prefix);
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with string @a prefix. **/
|
||||
inline bool cmHasPrefix(cm::string_view str, cm::string_view prefix)
|
||||
{
|
||||
return str.compare(0, prefix.size(), prefix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with string @a prefix. **/
|
||||
template <size_t N>
|
||||
inline bool cmHasLiteralPrefix(cm::string_view str, const char (&prefix)[N])
|
||||
{
|
||||
return cmHasPrefix(str, cm::string_view(prefix, N - 1));
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with the character @a suffix. **/
|
||||
inline bool cmHasSuffix(cm::string_view str, char suffix)
|
||||
{
|
||||
return !str.empty() && (str.back() == suffix);
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with string @a suffix. **/
|
||||
inline bool cmHasSuffix(cm::string_view str, cm::string_view suffix)
|
||||
{
|
||||
return str.size() >= suffix.size() &&
|
||||
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with string @a suffix. **/
|
||||
template <size_t N>
|
||||
inline bool cmHasLiteralSuffix(cm::string_view str, const char (&suffix)[N])
|
||||
{
|
||||
return cmHasSuffix(str, cm::string_view(suffix, N - 1));
|
||||
}
|
||||
|
||||
/** Removes an existing suffix character of from the string @a str. **/
|
||||
inline void cmStripSuffixIfExists(std::string& str, char suffix)
|
||||
{
|
||||
if (cmHasSuffix(str, suffix)) {
|
||||
str.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes an existing suffix string of from the string @a str. **/
|
||||
inline void cmStripSuffixIfExists(std::string& str, cm::string_view suffix)
|
||||
{
|
||||
if (cmHasSuffix(str, suffix)) {
|
||||
str.resize(str.size() - suffix.size());
|
||||
}
|
||||
}
|
||||
|
||||
namespace cm {
|
||||
|
||||
#if __cplusplus >= 201703L || defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
|
||||
|
@ -7,9 +7,9 @@
|
||||
#include <stddef.h>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include "cmBinUtilsMacOSMachOLinker.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.h"
|
||||
#include "cmRuntimeDependencyArchive.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
#include <sstream>
|
||||
|
@ -52,6 +52,7 @@
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmVersion.h"
|
||||
#include "cmVersionConfig.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmComputeLinkInformation.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalCommonGenerator.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
cmCommonTargetGenerator::cmCommonTargetGenerator(cmGeneratorTarget* gt)
|
||||
: GeneratorTarget(gt)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmake.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmComputeLinkInformation.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmComputeLinkDepends.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include "cmPolicies.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmake.h"
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <string.h>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmExportTryCompileFileGenerator.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmVersion.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmFortranParser.h" /* Interface to parser object. */
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "cmOutputConverter.h"
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
// TODO: Test compiler for the case of the mod file. Some always
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -6,13 +6,13 @@
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmLinkItem.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmExportBuildFileGenerator.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmExportSet.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
@ -12,6 +11,7 @@
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetExport.h"
|
||||
#include "cmake.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmExportFileGenerator.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmComputeLinkInformation.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include "cmPolicies.h"
|
||||
#include "cmPropertyMap.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetExport.h"
|
||||
|
@ -2,7 +2,6 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmExportInstallFileGenerator.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmExportSet.h"
|
||||
#include "cmExportSetMap.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
@ -15,6 +14,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetExport.h"
|
||||
|
@ -2,12 +2,12 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmFileAPI.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCryptoHash.h"
|
||||
#include "cmFileAPICMakeFiles.h"
|
||||
#include "cmFileAPICache.h"
|
||||
#include "cmFileAPICodemodel.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTimestamp.h"
|
||||
#include "cmake.h"
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "cmRange.h"
|
||||
#include "cmRuntimeDependencyArchive.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTimestamp.h"
|
||||
#include "cm_sys_stat.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "cmSearchPath.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
cmFindBase::cmFindBase()
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "cmSearchPath.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmVersion.h"
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "cmPolicies.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
// define the class for function commands
|
||||
class cmFunctionHelperCommand
|
||||
|
@ -2,12 +2,12 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmGeneratorExpressionDAGChecker.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmGeneratorExpressionContext.h"
|
||||
#include "cmGeneratorExpressionEvaluator.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmake.h"
|
||||
|
||||
#include <sstream>
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cm_static_string_view.hxx"
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmSourceFileLocation.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetLinkLibraryType.h"
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "cmDuration.h"
|
||||
#include "cmExportSetMap.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetDepend.h"
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetDepend.h"
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <stddef.h>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmArgumentParser.h"
|
||||
#include "cmExportSet.h"
|
||||
#include "cmExportSetMap.h"
|
||||
@ -27,6 +26,7 @@
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetExport.h"
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmComputeLinkInformation.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmOutputConverter;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmStringReplaceHelper.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "cmState.h"
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTestGenerator.h"
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmVersion.h"
|
||||
#include "cmake.h"
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "cmPolicies.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
// define the class for macro commands
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "cmSourceFileLocationKind.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
|
@ -2,11 +2,11 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmMessageCommand.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmMessenger.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmMessenger.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmDocumentationFormatter.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
cmNinjaNormalTargetGenerator::cmNinjaNormalTargetGenerator(
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmSourceFile.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
|
@ -7,11 +7,11 @@
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmArgumentParser.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cm_string_view.hxx"
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "cmPolicies.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmVersion.h"
|
||||
|
||||
|
@ -10,11 +10,11 @@
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmDuration.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmsys/FStream.hxx"
|
||||
#include "cmsys/RegularExpression.hxx"
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "cmQtAutoGen.h"
|
||||
#include "cmQtAutoGenGlobalInitializer.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCustomCommand.h"
|
||||
#include "cmCustomCommandLines.h"
|
||||
#include "cmFilePathChecksum.h"
|
||||
@ -23,6 +22,7 @@
|
||||
#include "cmSourceGroup.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmake.h"
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmQtAutoGen.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
#include "cmsys/FStream.hxx"
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "cmFileLockResult.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
// -- Class methods
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmVersion.h"
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmFindCommon.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
cmSearchPath::cmSearchPath(cmFindCommon* findCmd)
|
||||
|
@ -2,12 +2,12 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmSetCommand.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -2,10 +2,10 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmSourceFileLocation.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCacheManager.h"
|
||||
#include "cmCommand.h"
|
||||
#include "cmDefinitions.h"
|
||||
@ -22,6 +21,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStatePrivate.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmStatePrivate.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
class cmStateDirectory
|
||||
{
|
||||
|
139
Source/cmStringAlgorithms.h
Normal file
139
Source/cmStringAlgorithms.h
Normal file
@ -0,0 +1,139 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#ifndef cmStringAlgorithms_h
|
||||
#define cmStringAlgorithms_h
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include "cmRange.h"
|
||||
#include "cm_string_view.hxx"
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
typedef cmRange<std::vector<std::string>::const_iterator> cmStringRange;
|
||||
|
||||
struct cmStrCmp
|
||||
{
|
||||
cmStrCmp(const char* test)
|
||||
: m_test(test)
|
||||
{
|
||||
}
|
||||
cmStrCmp(std::string test)
|
||||
: m_test(std::move(test))
|
||||
{
|
||||
}
|
||||
|
||||
bool operator()(const std::string& input) const { return m_test == input; }
|
||||
|
||||
bool operator()(const char* input) const
|
||||
{
|
||||
return strcmp(input, m_test.c_str()) == 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string m_test;
|
||||
};
|
||||
|
||||
template <typename Range>
|
||||
std::string cmJoin(Range const& r, const char* delimiter)
|
||||
{
|
||||
if (r.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
std::ostringstream os;
|
||||
typedef typename Range::value_type ValueType;
|
||||
typedef typename Range::const_iterator InputIt;
|
||||
const InputIt first = r.begin();
|
||||
InputIt last = r.end();
|
||||
--last;
|
||||
std::copy(first, last, std::ostream_iterator<ValueType>(os, delimiter));
|
||||
|
||||
os << *last;
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
std::string cmJoin(Range const& r, std::string const& delimiter)
|
||||
{
|
||||
return cmJoin(r, delimiter.c_str());
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
std::string cmWrap(std::string const& prefix, Range const& r,
|
||||
std::string const& suffix, std::string const& sep)
|
||||
{
|
||||
if (r.empty()) {
|
||||
return std::string();
|
||||
}
|
||||
return prefix + cmJoin(r, suffix + sep + prefix) + suffix;
|
||||
}
|
||||
|
||||
template <typename Range>
|
||||
std::string cmWrap(char prefix, Range const& r, char suffix,
|
||||
std::string const& sep)
|
||||
{
|
||||
return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep);
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with the character @a prefix. **/
|
||||
inline bool cmHasPrefix(cm::string_view str, char prefix)
|
||||
{
|
||||
return !str.empty() && (str.front() == prefix);
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with string @a prefix. **/
|
||||
inline bool cmHasPrefix(cm::string_view str, cm::string_view prefix)
|
||||
{
|
||||
return str.compare(0, prefix.size(), prefix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with string @a prefix. **/
|
||||
template <size_t N>
|
||||
inline bool cmHasLiteralPrefix(cm::string_view str, const char (&prefix)[N])
|
||||
{
|
||||
return cmHasPrefix(str, cm::string_view(prefix, N - 1));
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with the character @a suffix. **/
|
||||
inline bool cmHasSuffix(cm::string_view str, char suffix)
|
||||
{
|
||||
return !str.empty() && (str.back() == suffix);
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with string @a suffix. **/
|
||||
inline bool cmHasSuffix(cm::string_view str, cm::string_view suffix)
|
||||
{
|
||||
return str.size() >= suffix.size() &&
|
||||
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with string @a suffix. **/
|
||||
template <size_t N>
|
||||
inline bool cmHasLiteralSuffix(cm::string_view str, const char (&suffix)[N])
|
||||
{
|
||||
return cmHasSuffix(str, cm::string_view(suffix, N - 1));
|
||||
}
|
||||
|
||||
/** Removes an existing suffix character of from the string @a str. **/
|
||||
inline void cmStripSuffixIfExists(std::string& str, char suffix)
|
||||
{
|
||||
if (cmHasSuffix(str, suffix)) {
|
||||
str.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes an existing suffix string of from the string @a str. **/
|
||||
inline void cmStripSuffixIfExists(std::string& str, cm::string_view suffix)
|
||||
{
|
||||
if (cmHasSuffix(str, suffix)) {
|
||||
str.resize(str.size() - suffix.size());
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -18,6 +18,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmStringReplaceHelper.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTimestamp.h"
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "cmDuration.h"
|
||||
#include "cmProcessOutput.h"
|
||||
#include "cmRange.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cm_uv.h"
|
||||
|
||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmTargetLinkLibraryType.h"
|
||||
|
||||
class cmCustomCommand;
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
class cmTarget;
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "cmMessenger.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
bool cmTargetPropertyComputer::HandleLocationPropertyPolicy(
|
||||
std::string const& tgtName, cmMessenger* messenger,
|
||||
|
@ -7,9 +7,9 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmMessenger;
|
||||
|
@ -4,11 +4,11 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmPolicies.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmUnsetCommand.h"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "cmMessenger.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmTarget.h"
|
||||
#include "cmTargetLinkLibraryType.h"
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
#include "cmcmd.h"
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "cmState.h"
|
||||
#include "cmStateDirectory.h"
|
||||
#include "cmStateSnapshot.h"
|
||||
#include "cmStringAlgorithms.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmUtils.hxx"
|
||||
#include "cmVersion.h"
|
||||
|
Loading…
Reference in New Issue
Block a user