summaryrefslogtreecommitdiffstats
path: root/Source/cmStringAlgorithms.h
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-07-31 07:06:04 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-08-05 09:25:30 (GMT)
commit7fbcc16dcd92a80eb30baab93388a0b8e294969b (patch)
tree33958836b22312caaa67cd3eb331c5676e2cf8a7 /Source/cmStringAlgorithms.h
parent3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 (diff)
downloadCMake-7fbcc16dcd92a80eb30baab93388a0b8e294969b.zip
CMake-7fbcc16dcd92a80eb30baab93388a0b8e294969b.tar.gz
CMake-7fbcc16dcd92a80eb30baab93388a0b8e294969b.tar.bz2
cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize
This adds the following functions to `cmStringAlgorithms`: - `cmIsSpace` - `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`) - `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`) - `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to accept `cm::string_view`)
Diffstat (limited to 'Source/cmStringAlgorithms.h')
-rw-r--r--Source/cmStringAlgorithms.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
index cdb494f..1898649 100644
--- a/Source/cmStringAlgorithms.h
+++ b/Source/cmStringAlgorithms.h
@@ -7,6 +7,7 @@
#include "cmRange.h"
#include "cm_string_view.hxx"
+#include <cctype>
#include <initializer_list>
#include <sstream>
#include <string.h>
@@ -31,6 +32,18 @@ private:
std::string const Test_;
};
+/** Returns true if the character @a ch is a whitespace character. **/
+inline bool cmIsSpace(char ch)
+{
+ return ((ch & 0x80) == 0) && std::isspace(ch);
+}
+
+/** Returns a string that has whitespace removed from the start and the end. */
+std::string cmTrimWhitespace(cm::string_view str);
+
+/** Escape quotes in a string. */
+std::string cmEscapeQuotes(cm::string_view str);
+
/** Joins elements of a range with separator into a single string. */
template <typename Range>
std::string cmJoin(Range const& rng, cm::string_view separator)
@@ -49,6 +62,9 @@ std::string cmJoin(Range const& rng, cm::string_view separator)
return os.str();
}
+/** Extract tokens that are separated by any of the characters in @a sep. */
+std::vector<std::string> cmTokenize(cm::string_view str, cm::string_view sep);
+
/** Concatenate string pieces into a single string. */
std::string cmCatViews(std::initializer_list<cm::string_view> views);