mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-07 06:40:16 -05:00
cmArgumentParser: Add support for MaybeEmpty<std::string>
Add it for completeness, though it is the same as plain `std::string`. Also extend the SunPro/EDG workaround to cover this type.
This commit is contained in:
@@ -72,6 +72,16 @@ void Instance::Bind(std::string& val)
|
|||||||
ExpectAtLeast{ 1 });
|
ExpectAtLeast{ 1 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Instance::Bind(MaybeEmpty<std::string>& val)
|
||||||
|
{
|
||||||
|
this->Bind(
|
||||||
|
[&val](cm::string_view arg) -> Continue {
|
||||||
|
val = std::string(arg);
|
||||||
|
return Continue::No;
|
||||||
|
},
|
||||||
|
ExpectAtLeast{ 1 });
|
||||||
|
}
|
||||||
|
|
||||||
void Instance::Bind(NonEmpty<std::string>& val)
|
void Instance::Bind(NonEmpty<std::string>& val)
|
||||||
{
|
{
|
||||||
this->Bind(
|
this->Bind(
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ public:
|
|||||||
void Bind(std::function<Continue(cm::string_view)> f, ExpectAtLeast expect);
|
void Bind(std::function<Continue(cm::string_view)> f, ExpectAtLeast expect);
|
||||||
void Bind(bool& val);
|
void Bind(bool& val);
|
||||||
void Bind(std::string& val);
|
void Bind(std::string& val);
|
||||||
|
void Bind(MaybeEmpty<std::string>& val);
|
||||||
void Bind(NonEmpty<std::string>& val);
|
void Bind(NonEmpty<std::string>& val);
|
||||||
void Bind(Maybe<std::string>& val);
|
void Bind(Maybe<std::string>& val);
|
||||||
void Bind(MaybeEmpty<std::vector<std::string>>& val);
|
void Bind(MaybeEmpty<std::vector<std::string>>& val);
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ struct MaybeEmpty<std::vector<T>> : public std::vector<T>
|
|||||||
using std::vector<T>::vector;
|
using std::vector<T>::vector;
|
||||||
using std::vector<T>::operator=;
|
using std::vector<T>::operator=;
|
||||||
};
|
};
|
||||||
|
template <>
|
||||||
|
struct MaybeEmpty<std::string> : public std::string
|
||||||
|
{
|
||||||
|
using std::string::basic_string;
|
||||||
|
using std::string::operator=;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct NonEmpty;
|
struct NonEmpty;
|
||||||
|
|||||||
Reference in New Issue
Block a user