21 const std::string_view doc)
22 : _name(
name), _doc(doc), _value(
value), _explicit(false)
27 if (!std::regex_match(
getName(), std::regex(
"[a-z0-9_-]+")))
30 "': Name has unallowed characters; allowed characters = 'a-z, 0-9, _, -'");
35 const std::regex string_regex(
"[a-z0-9_.-]+");
36 if (!std::regex_match(*string_ptr, string_regex))
38 "String capability '" +
getName() +
"': value '" + *string_ptr +
39 "' has unallowed characters; allowed characters = 'a-z, 0-9, _, ., -'");
49 const std::set<std::string> &
54 "' does not have an enumeration");
63 "' is bool-valued and cannot be set as explicit");
71 static const std::string error_prefix =
"Capability::setEnumeration(): ";
76 "' is not string-valued and cannot have an enumeration");
83 "' already has an enumeration set");
86 if (enumeration.empty())
89 for (
const auto &
value : enumeration)
90 if (!std::regex_match(
value, std::regex(
"[a-z0-9_-]+")))
92 "' for capability '" +
getName() +
"'" +
93 " has unallowed characters; allowed characters = 'a-z, 0-9, _, -'");
99 " value not within enumeration");
119 " is not an integer");
135 return *bool_ptr ?
"true" :
"false";
139 return std::to_string(*int_ptr);
157 "' does not have an enumeration");
std::string name(const ElemQuality q)
bool getBoolValue() const
const std::set< std::string > & getEnumeration() const
const std::string * queryStringValue() const
const std::string & getStringValue() const
std::string toString() const
const int * queryIntValue() const
bool _explicit
Whether or not this capability must be compared explicitly (not as a boolean check) ...
std::variant< bool, int, std::string > Value
A capability can have a bool, int, or string value.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
An entry for a single capability.
std::string enumerationToString() const
bool hasBoolValue() const
Common execption to be thrown when interacting with capabilities.
bool hasEnumeration(const std::string &value) const
const std::string & getName() const
MOOSE now contains C++17 code, so give a reasonable error message stating what the user can do to add...
std::optional< std::set< std::string > > _enumeration
Possible enumeration for the capability, if any (string capabilities only)
const bool * queryBoolValue() const
Capability & setEnumeration(const std::set< std::string > &enumeration)
Set the enumeration (allowed values) for the capability.
Capability & setExplicit()
Set the capability to be explicit.
std::string stringJoin(const std::vector< std::string > &values, const std::string &separator=" ")
Concatenates value into a single string separated by separator.
std::string valueToString() const