summaryrefslogtreecommitdiffstats
path: root/Source/cmStringAlgorithms.h
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2019-08-16 18:50:52 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-08-16 18:51:03 (GMT)
commit2beed5a4ef66f415f4efa327a8c479395d262e52 (patch)
tree48b1a8ad1a2fe87cb6a84de2b96379ebd7f78674 /Source/cmStringAlgorithms.h
parentdcf2beb7dec757b7e28eba43fb7f2d5498bded39 (diff)
parent2f6495e24e57cd4a03f38e615cc60177e89afb96 (diff)
downloadCMake-2beed5a4ef66f415f4efa327a8c479395d262e52.zip
CMake-2beed5a4ef66f415f4efa327a8c479395d262e52.tar.gz
CMake-2beed5a4ef66f415f4efa327a8c479395d262e52.tar.bz2
Merge topic 'cmExpandList'
2f6495e24e cmSystemTools: Remove ExpandListArgument methods f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument ff42dec891 cmStringAlgorithms: Add cmExpandList functions Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3682
Diffstat (limited to 'Source/cmStringAlgorithms.h')
-rw-r--r--Source/cmStringAlgorithms.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
index 968cc14..223d712 100644
--- a/Source/cmStringAlgorithms.h
+++ b/Source/cmStringAlgorithms.h
@@ -68,6 +68,48 @@ std::string cmJoin(Range const& rng, cm::string_view separator)
/** 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);
+/**
+ * Expand the ; separated string @a arg into multiple arguments.
+ * All found arguments are appended to @a argsOut.
+ */
+void cmExpandList(cm::string_view arg, std::vector<std::string>& argsOut,
+ bool emptyArgs = false);
+
+/**
+ * Expand out any arguments in the string range [@a first, @a last) that have
+ * ; separated strings into multiple arguments. All found arguments are
+ * appended to @a argsOut.
+ */
+template <class InputIt>
+void cmExpandLists(InputIt first, InputIt last,
+ std::vector<std::string>& argsOut)
+{
+ for (; first != last; ++first) {
+ ExpandList(*first, argsOut);
+ }
+}
+
+/**
+ * Same as cmExpandList but a new vector is created containing
+ * the expanded arguments from the string @a arg.
+ */
+std::vector<std::string> cmExpandedList(cm::string_view arg,
+ bool emptyArgs = false);
+
+/**
+ * Same as cmExpandList but a new vector is created containing the expanded
+ * versions of all arguments in the string range [@a first, @a last).
+ */
+template <class InputIt>
+std::vector<std::string> cmExpandedLists(InputIt first, InputIt last)
+{
+ std::vector<std::string> argsOut;
+ for (; first != last; ++first) {
+ cmExpandList(*first, argsOut);
+ }
+ return argsOut;
+}
+
/** Concatenate string pieces into a single string. */
std::string cmCatViews(std::initializer_list<cm::string_view> views);