summaryrefslogtreecommitdiffstats
path: root/Source/cmArgumentParser.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-07-06 15:45:57 (GMT)
committerBrad King <brad.king@kitware.com>2022-07-07 13:49:04 (GMT)
commitf46b2e914256322fc8d33b425ec01e9d9c1496ba (patch)
treec52e8e524354fa7c7248ea5ed14802e470a6933b /Source/cmArgumentParser.cxx
parente6d1e29ffa6bd3141a769d1281f3407ed0774139 (diff)
downloadCMake-f46b2e914256322fc8d33b425ec01e9d9c1496ba.zip
CMake-f46b2e914256322fc8d33b425ec01e9d9c1496ba.tar.gz
CMake-f46b2e914256322fc8d33b425ec01e9d9c1496ba.tar.bz2
cmArgumentParser: Model maybe-missing string with wrapper type
Bindings to `std::string` require one value. Some clients have been filtering `keywordsMissingValue` to support keywords that tolerate a missing value. Offer them a type-safe way to achieve this instead.
Diffstat (limited to 'Source/cmArgumentParser.cxx')
-rw-r--r--Source/cmArgumentParser.cxx7
1 files changed, 7 insertions, 0 deletions
diff --git a/Source/cmArgumentParser.cxx b/Source/cmArgumentParser.cxx
index 1bb9051..f0c4cfc 100644
--- a/Source/cmArgumentParser.cxx
+++ b/Source/cmArgumentParser.cxx
@@ -46,6 +46,13 @@ void Instance::Bind(std::string& val)
this->ExpectValue = true;
}
+void Instance::Bind(Maybe<std::string>& val)
+{
+ this->CurrentString = &val;
+ this->CurrentList = nullptr;
+ this->ExpectValue = false;
+}
+
void Instance::Bind(MaybeEmpty<std::vector<std::string>>& val)
{
this->CurrentString = nullptr;