24 : _allow_out_of_range(allow_out_of_range)
26 if (names.find(
',') != std::string::npos)
27 mooseError(
"Spaces are required to separate options, comma support has been removed.");
33 : _items(other_enum._items),
34 _deprecated_items(other_enum._deprecated_items),
35 _allow_out_of_range(other_enum._allow_out_of_range)
47 std::set<MooseEnumItem>::const_iterator deprecated =
find(
name);
48 if (deprecated ==
_items.end())
49 mooseError(
"Cannot deprecate the enum item ",
name,
", is not an available value.");
51 std::set<MooseEnumItem>::const_iterator replaced =
find(raw_name);
52 if (replaced ==
_items.end())
55 ", since the replaced item ",
57 " it is not an available value.");
66 std::vector<std::string> elements;
68 for (
const std::string & raw_name : elements)
76 if (raw_name.find_first_of(
'=') == 0 || raw_name.find_last_of(
'=') == raw_name.length() - 1)
77 mooseError(
"You cannot place whitespace around the '=' character in MooseEnumBase");
80 std::vector<std::string> name_value;
84 if (name_value.size() < 1 || name_value.size() > 2)
85 mooseError(
"Invalid option supplied in MooseEnumBase: ", raw_name);
93 if (name_value.size() == 2)
94 value = std::strtol(name_value[1].c_str(), NULL, 0);
105 for (
const auto & item :
_items)
119 const auto & item_it =
find(item);
120 if (item_it !=
_items.end())
126 " already exists in the enumeration, cannot not add '",
130 mooseError(
"The name '", item.
name(),
"' already exists in the enumeration.");
132 return *
_items.insert(item).first;
138 std::map<MooseEnumItem, MooseEnumItem>::const_iterator it =
_deprecated_items.find(item);
141 if (it->second.name().empty())
144 mooseWarning(item.
name() +
" is deprecated, consider using " + it->second.name());
148 std::vector<std::string>
151 std::vector<std::string>
out;
153 for (
const auto & item :
_items)
154 out.push_back(item.name());
167 std::vector<int>
out;
169 for (
const auto & item :
_items)
170 out.push_back(item.id());
183 const std::map<MooseEnumItem, std::string> &
189 std::set<MooseEnumItem>::const_iterator
193 return std::find_if(
_items.begin(),
195 [&upper](
MooseEnumItem const & item) {
return item.name() == upper; });
198 std::set<MooseEnumItem>::const_iterator
205 std::set<MooseEnumItem>::const_iterator
209 return std::find_if(
_items.begin(),
212 {
return item.id() == other.
id() && item.name() == upper; });
226 for (
const auto &
name : names)
std::string name(const ElemQuality q)
int getNextValidID() const
Compute the next valid ID.
void tokenize(const std::string &str, std::vector< T > &elements, unsigned int min_len=1, const std::string &delims="/")
This function will split the passed in string on a set of delimiters appending the substrings to the ...
const std::string & name() const
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
std::map< MooseEnumItem, MooseEnumItem > _deprecated_items
The map of deprecated names and optional replacements.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
void addEnumerationNames(const std::string &names)
Methods to add possible enumeration value to the enum.
MooseEnumBase()
Private constuctor for use by libmesh::Parameters.
std::string getRawNames() const
Method for returning the raw name strings for this instance.
The base class for both the MooseEnum and MultiMooseEnum classes.
auto max(const L &left, const R &right)
const std::map< MooseEnumItem, std::string > & getItemDocumentation() const
Get the map containing each item's documentation string.
std::map< MooseEnumItem, std::string > _item_documentation
The map of items and their respective documentation strings.
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const MooseEnumItem & addEnumerationName(const std::string &raw_name)
std::string trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.
virtual void checkDeprecated() const =0
Method that must be implemented to check derived class values against the _deprecated_names.
const MooseEnumItem & addEnumerationItem(const MooseEnumItem &item)
std::vector< int > getIDs() const
Method for returning a vector of ids for this instance.
std::string stringify(const T &t)
conversion to string
std::vector< std::string > getNames() const
Method for returning a vector of all valid enumeration names for this instance.
std::set< MooseEnumItem > _items
Storage for the assigned items.
const int & id() const
Return the numeric, name, or raw name.
Class for containing MooseEnum item information.
void addDocumentation(const std::string &name, const std::string &doc)
Add an item documentation string.
virtual void deprecate(const std::string &name, const std::string &raw_name="")
Deprecates various options in the MOOSE enum.
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
MooseEnumBase & operator+=(const std::string &name)
Adds an enumeration item from name.