www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Private Attributes | Friends | List of all members
MultiMooseEnum Class Reference

This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It should be initialized with a comma-separated list of strings which become the enum values. More...

#include <MultiMooseEnum.h>

Inheritance diagram for MultiMooseEnum:
[legend]

Public Member Functions

 MultiMooseEnum (std::string names, std::string default_names="", bool allow_out_of_range=false)
 Constructor that takes a list of enumeration values, and a separate string to set a default for this instance. More...
 
 MultiMooseEnum (const MultiMooseEnum &other_enum)
 Copy Constructor. More...
 
const std::string & operator[] (unsigned int i) const
 Indexing operator Operator to retrieve an item from the MultiMooseEnum. More...
 
unsigned int get (unsigned int i) const
 Indexing operator Operator to retrieve an item from the MultiMooseEnum. More...
 
void clear ()
 Clear the MultiMooseEnum. More...
 
unsigned int size () const
 Return the number of items in the MultiMooseEnum. More...
 
virtual bool isValid () const override
 IsValid. More...
 
void deprecate (const std::string &name, const std::string &new_name="")
 Deprecates various options in the MOOSE enum. More...
 
std::vector< std::string > getNames () const
 Method for returning a vector of all valid enumeration names for this instance. More...
 
std::string getRawNames () const
 Method for returning the raw name strings for this instance. More...
 
bool isOutOfRangeAllowed () const
 isOutOfRangeAllowed More...
 
bool operator== (const MultiMooseEnum &value) const
 Comparison operators for comparing with character constants, MultiMooseEnums or integer values. More...
 
bool operator!= (const MultiMooseEnum &value) const
 
bool contains (const std::string &value) const
 Contains methods for seeing if a value is in the MultiMooseEnum. More...
 
bool contains (int value) const
 
bool contains (unsigned short value) const
 
bool contains (const MultiMooseEnum &value) const
 
bool contains (const MooseEnumItem &value) const
 
MultiMooseEnumoperator= (const std::string &names)
 Assignment operators. More...
 
MultiMooseEnumoperator= (const std::vector< std::string > &names)
 
MultiMooseEnumoperator= (const std::set< std::string > &names)
 
void erase (const std::string &names)
 Un-assign a value. More...
 
void erase (const std::vector< std::string > &names)
 
void erase (const std::set< std::string > &names)
 
void push_back (const std::string &names)
 Insert operators Operator to insert (push_back) values into the enum. More...
 
void push_back (const std::vector< std::string > &names)
 
void push_back (const std::set< std::string > &names)
 
MooseEnumIterator begin () const
 Returns a begin/end iterator to all of the items in the enum. More...
 
MooseEnumIterator end () const
 

Protected Member Functions

virtual void checkDeprecated () const override
 Check whether any of the current values are deprecated when called. More...
 
void fillNames (std::string names, std::string option_delim=" ")
 Populates the _names vector. More...
 
void checkDeprecatedBase (const std::string &name_upper) const
 Check and warn deprecated values. More...
 
std::set< MooseEnumItem >::const_iterator find (const MooseEnumItem &other) const
 Locate an item. More...
 
std::set< MooseEnumItem >::const_iterator find (const std::string &name) const
 
std::set< MooseEnumItem >::const_iterator find (int id) const
 

Protected Attributes

std::set< MooseEnumItem_items
 Storage for the assigned items. More...
 
std::map< std::string, std::string > _deprecated_names
 The map of deprecated names and optional replacements. More...
 
int _out_of_range_index
 The index of values assigned that are NOT values in this enum. More...
 

Static Protected Attributes

static const int INVALID_ID = std::numeric_limits<int>::min()
 Constants. More...
 

Private Member Functions

 MultiMooseEnum ()
 Private constructor for use by libmesh::Parameters. More...
 
 MultiMooseEnum (const MooseEnumBase &other_enum)
 Private constructor that can accept a MooseEnumBase for ::withOptionsFrom() More...
 
template<typename InputIterator >
MultiMooseEnumassign (InputIterator first, InputIterator last, bool append)
 Helper method for all inserts and assignment operators. More...
 
template<typename InputIterator >
void remove (InputIterator first, InputIterator last)
 Helper method for un-assigning enumeration values. More...
 

Private Attributes

std::vector< MooseEnumItem_current
 The current id. More...
 

Friends

class libMesh::Parameters
 
std::ostream & operator<< (std::ostream &out, const MultiMooseEnum &obj)
 Operator for printing to iostreams. More...
 

Detailed Description

This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It should be initialized with a comma-separated list of strings which become the enum values.

You may also optionally supply numeric ints for one or more values similar to a C++ enum. This is done with the "=" sign. It can be used any place where an integer (switch statements), const char* or std::string is expected. In addition the InputParameters system has full support for this Enum type

Definition at line 42 of file MultiMooseEnum.h.

Constructor & Destructor Documentation

MultiMooseEnum::MultiMooseEnum ( std::string  names,
std::string  default_names = "",
bool  allow_out_of_range = false 
)

Constructor that takes a list of enumeration values, and a separate string to set a default for this instance.

Parameters
names- a list of names for this enumeration
default_names- the default value for this enumeration instance
allow_out_of_range- determines whether this enumeration will accept values outside of it's range of defined values.

Definition at line 28 of file MultiMooseEnum.C.

31  : MooseEnumBase(names, allow_out_of_range)
32 {
33  *this = default_names;
34 }
MooseEnumBase()
Private constuctor for use by libmesh::Parameters.
Definition: MooseEnumBase.C:54
MultiMooseEnum::MultiMooseEnum ( const MultiMooseEnum other_enum)

Copy Constructor.

Parameters
other_enum- The other enumeration to copy state from

Definition at line 36 of file MultiMooseEnum.C.

37  : MooseEnumBase(other_enum), _current(other_enum._current)
38 {
39 }
std::vector< MooseEnumItem > _current
The current id.
MooseEnumBase()
Private constuctor for use by libmesh::Parameters.
Definition: MooseEnumBase.C:54
MultiMooseEnum::MultiMooseEnum ( )
private

Private constructor for use by libmesh::Parameters.

Private constuctor for use by libmesh::Parameters.

Definition at line 44 of file MultiMooseEnum.C.

44 {}
MultiMooseEnum::MultiMooseEnum ( const MooseEnumBase other_enum)
private

Private constructor that can accept a MooseEnumBase for ::withOptionsFrom()

Parameters
other_enum- MooseEnumBase type to copy names and out-of-range data from

Definition at line 46 of file MultiMooseEnum.C.

46 : MooseEnumBase(other_enum) {}
MooseEnumBase()
Private constuctor for use by libmesh::Parameters.
Definition: MooseEnumBase.C:54

Member Function Documentation

template<typename InputIterator >
MultiMooseEnum & MultiMooseEnum::assign ( InputIterator  first,
InputIterator  last,
bool  append 
)
private

Helper method for all inserts and assignment operators.

Definition at line 188 of file MultiMooseEnum.C.

Referenced by operator=(), and push_back().

189 {
190  if (!append)
191  clear();
192 
193  for (InputIterator it = first; it != last; ++it)
194  {
195  std::string upper(MooseUtils::toUpper(*it));
196  checkDeprecatedBase(upper);
197  const auto iter = find(upper);
198 
199  if (iter == _items.end())
200  {
201  if (_out_of_range_index == 0) // Are out of range values allowed?
202  mooseError("Invalid option \"",
203  upper,
204  "\" in MultiMooseEnum. Valid options (not case-sensitive) are \"",
205  getRawNames(),
206  "\".");
207  else
208  {
209  MooseEnumItem created(upper, _out_of_range_index++);
210  _current.push_back(created);
211  _items.insert(created);
212  }
213  }
214  else
215  _current.push_back(*iter);
216  }
217  return *this;
218 }
void checkDeprecatedBase(const std::string &name_upper) const
Check and warn deprecated values.
Definition: MooseEnumBase.C:99
std::vector< MooseEnumItem > _current
The current id.
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:555
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
int _out_of_range_index
The index of values assigned that are NOT values in this enum.
void clear()
Clear the MultiMooseEnum.
std::set< MooseEnumItem > _items
Storage for the assigned items.
std::string getRawNames() const
Method for returning the raw name strings for this instance.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
std::set< MooseEnumItem >::const_iterator find(const MooseEnumItem &other) const
Locate an item.
MooseEnumIterator MultiMooseEnum::begin ( ) const
inline

Returns a begin/end iterator to all of the items in the enum.

Items will always be capitalized.

Definition at line 143 of file MultiMooseEnum.h.

143 { return _current.begin(); }
std::vector< MooseEnumItem > _current
The current id.
void MultiMooseEnum::checkDeprecated ( ) const
overrideprotectedvirtual

Check whether any of the current values are deprecated when called.

Implements MooseEnumBase.

Definition at line 251 of file MultiMooseEnum.C.

252 {
253  for (const auto & item : _current)
254  checkDeprecatedBase(item.name());
255 }
void checkDeprecatedBase(const std::string &name_upper) const
Check and warn deprecated values.
Definition: MooseEnumBase.C:99
std::vector< MooseEnumItem > _current
The current id.
void MooseEnumBase::checkDeprecatedBase ( const std::string &  name_upper) const
protectedinherited

Check and warn deprecated values.

Definition at line 99 of file MooseEnumBase.C.

Referenced by assign(), MooseEnum::checkDeprecated(), checkDeprecated(), MooseEnumBase::isOutOfRangeAllowed(), and MooseEnum::operator=().

100 {
101  std::map<std::string, std::string>::const_iterator it = _deprecated_names.find(name_upper);
102 
103  if (it != _deprecated_names.end())
104  {
105  if (it->second != "")
106  mooseWarning(name_upper + " is deprecated, consider using " + it->second);
107  else
108  mooseWarning(name_upper + " is deprecated");
109  }
110 }
std::map< std::string, std::string > _deprecated_names
The map of deprecated names and optional replacements.
void mooseWarning(Args &&...args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:194
void MultiMooseEnum::clear ( )

Clear the MultiMooseEnum.

Definition at line 239 of file MultiMooseEnum.C.

Referenced by assign().

240 {
241  _current.clear();
242 }
std::vector< MooseEnumItem > _current
The current id.
bool MultiMooseEnum::contains ( const std::string &  value) const

Contains methods for seeing if a value is in the MultiMooseEnum.

Returns
bool - the truth value indicating whether the value is present

Definition at line 66 of file MultiMooseEnum.C.

Referenced by AdvancedOutput::addValidParams(), contains(), Console::initialSetup(), AdvancedOutput::initPostprocessorOrVectorPostprocessorLists(), Console::output(), Console::outputSystemInformation(), Output::shouldOutput(), and PetscOutput::solveSetup().

67 {
68  std::string upper(MooseUtils::toUpper(value));
69  return std::find_if(_current.begin(), _current.end(), [&upper](const MooseEnumItem & item) {
70  return item.name() == upper;
71  }) != _current.end();
72 }
std::vector< MooseEnumItem > _current
The current id.
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:555
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
bool MultiMooseEnum::contains ( int  value) const

Definition at line 75 of file MultiMooseEnum.C.

76 {
77  return std::find_if(_current.begin(), _current.end(), [&value](const MooseEnumItem & item) {
78  return item.id() == value;
79  }) != _current.end();
80 }
std::vector< MooseEnumItem > _current
The current id.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
bool MultiMooseEnum::contains ( unsigned short  value) const

Definition at line 83 of file MultiMooseEnum.C.

84 {
85  return std::find_if(_current.begin(), _current.end(), [&value](const MooseEnumItem & item) {
86  return item.id() == value;
87  }) != _current.end();
88 }
std::vector< MooseEnumItem > _current
The current id.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
bool MultiMooseEnum::contains ( const MultiMooseEnum value) const

Definition at line 91 of file MultiMooseEnum.C.

92 {
93  for (const auto & item : value._current)
94  if (!contains(item))
95  return false;
96  return true;
97 }
std::vector< MooseEnumItem > _current
The current id.
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
bool MultiMooseEnum::contains ( const MooseEnumItem value) const

Definition at line 100 of file MultiMooseEnum.C.

101 {
102  return std::find_if(_current.begin(), _current.end(), [&value](const MooseEnumItem & item) {
103  return item.id() == value.id();
104  }) != _current.end();
105 }
std::vector< MooseEnumItem > _current
The current id.
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:38
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
void MooseEnumBase::deprecate ( const std::string &  name,
const std::string &  new_name = "" 
)
inherited

Deprecates various options in the MOOSE enum.

For each deprecated option, you may supply an option new option that will be used in a message telling the user which new option replaces the old one.

Definition at line 57 of file MooseEnumBase.C.

58 {
59  std::string upper(MooseUtils::toUpper(name));
60  std::string upper_new(MooseUtils::toUpper(new_name));
61  _deprecated_names[upper] = upper_new;
63 }
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:555
std::map< std::string, std::string > _deprecated_names
The map of deprecated names and optional replacements.
virtual void checkDeprecated() const =0
MooseEnumIterator MultiMooseEnum::end ( ) const
inline

Definition at line 144 of file MultiMooseEnum.h.

144 { return _current.end(); }
std::vector< MooseEnumItem > _current
The current id.
void MultiMooseEnum::erase ( const std::string &  names)

Un-assign a value.

Parameters
names- a string, set, or vector giving the name to erase from the enumeration values

Definition at line 128 of file MultiMooseEnum.C.

Referenced by Console::Console().

129 {
130  std::vector<std::string> names_vector;
131  MooseUtils::tokenize(names, names_vector, 1, " ");
132  remove(names_vector.begin(), names_vector.end());
133 }
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 ...
Definition: MooseUtils.h:350
void MultiMooseEnum::erase ( const std::vector< std::string > &  names)

Definition at line 136 of file MultiMooseEnum.C.

137 {
138  remove(names.begin(), names.end());
139 }
void MultiMooseEnum::erase ( const std::set< std::string > &  names)

Definition at line 142 of file MultiMooseEnum.C.

143 {
144  remove(names.begin(), names.end());
145 }
void MooseEnumBase::fillNames ( std::string  names,
std::string  option_delim = " " 
)
protectedinherited

Populates the _names vector.

Parameters
names- a space separated list of names used to populate the internal names vector

Definition at line 66 of file MooseEnumBase.C.

Referenced by MooseEnumBase::isOutOfRangeAllowed(), and MooseEnumBase::MooseEnumBase().

67 {
68  std::vector<std::string> elements;
69  // split on spaces
70  MooseUtils::tokenize(names, elements, 1, option_delim);
71 
72  int value = 0;
73  for (unsigned int i = 0; i < elements.size(); ++i)
74  {
75  std::vector<std::string> name_value;
76 
77  // Make sure the option is not malformed
78  if (elements[i].find_first_of('=') == 0 ||
79  elements[i].find_last_of('=') == elements[i].length() - 1)
80  mooseError("You cannot place whitespace around the '=' character in MooseEnumBase");
81 
82  // split on equals sign
83  MooseUtils::tokenize(MooseUtils::trim(elements[i]), name_value, 1, "=");
84 
85  if (name_value.size() < 1 || name_value.size() > 2)
86  mooseError("Invalid option supplied in MooseEnumBase: ", elements[i]);
87 
88  // See if there is a value supplied for this option
89  // strtol allows for proper conversions of both int and hex strings
90  if (name_value.size() == 2)
91  value = strtol(name_value[1].c_str(), NULL, 0);
92 
93  // create item entry
94  _items.emplace(name_value[0], value++);
95  }
96 }
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 ...
Definition: MooseUtils.h:350
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::set< MooseEnumItem > _items
Storage for the assigned items.
std::string trim(const std::string &str, const std::string &white_space=" \t\n\v\f\r")
Standard scripting language trim function.
Definition: MooseUtils.C:95
std::set< MooseEnumItem >::const_iterator MooseEnumBase::find ( const MooseEnumItem other) const
protectedinherited

Locate an item.

Definition at line 144 of file MooseEnumBase.C.

Referenced by assign(), MooseEnumBase::isOutOfRangeAllowed(), MooseEnum::operator=(), and MooseEnum::operator==().

145 {
146  return std::find_if(
147  _items.begin(), _items.end(), [&other](MooseEnumItem const & item) { return item == other; });
148 }
std::set< MooseEnumItem > _items
Storage for the assigned items.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
std::set< MooseEnumItem >::const_iterator MooseEnumBase::find ( const std::string &  name) const
protectedinherited

Definition at line 129 of file MooseEnumBase.C.

130 {
131  return std::find_if(_items.begin(), _items.end(), [&name](MooseEnumItem const & item) {
132  return item.name() == name;
133  });
134 }
std::set< MooseEnumItem > _items
Storage for the assigned items.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
std::set< MooseEnumItem >::const_iterator MooseEnumBase::find ( int  id) const
protectedinherited

Definition at line 137 of file MooseEnumBase.C.

138 {
139  return std::find_if(
140  _items.begin(), _items.end(), [&id](MooseEnumItem const & item) { return item.id() == id; });
141 }
std::set< MooseEnumItem > _items
Storage for the assigned items.
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
unsigned int MultiMooseEnum::get ( unsigned int  i) const

Indexing operator Operator to retrieve an item from the MultiMooseEnum.

The reference may not be used to change the item.

Parameters
iindex
Returns
a read/read-write reference to the item as an unsigned int.

Definition at line 177 of file MultiMooseEnum.C.

Referenced by InputParameters::getParamHelper(), and Parser::setScalarParameter().

178 {
179  mooseAssert(i < _current.size(),
180  "Access out of bounds in MultiMooseEnum (i: " << i << " size: " << _current.size()
181  << ")");
182 
183  return _current[i].id();
184 }
std::vector< MooseEnumItem > _current
The current id.
std::vector< std::string > MooseEnumBase::getNames ( ) const
inherited

Method for returning a vector of all valid enumeration names for this instance.

Returns
a vector of names

Definition at line 113 of file MooseEnumBase.C.

114 {
115  std::vector<std::string> out;
116  out.reserve(_items.size());
117  for (auto it = _items.begin(); it != _items.end(); ++it)
118  out.push_back(it->name());
119  return out;
120 }
std::set< MooseEnumItem > _items
Storage for the assigned items.
std::string MooseEnumBase::getRawNames ( ) const
inherited

Method for returning the raw name strings for this instance.

Returns
a space separated list of names

Definition at line 123 of file MooseEnumBase.C.

Referenced by assign(), AdvancedOutput::enableOutputTypes(), MooseEnum::operator=(), MooseEnum::operator==(), validParams< LeastSquaresFit >(), validParams< MultiAppTransfer >(), validParams< PiecewiseConstant >(), and validParams< Residual >().

124 {
125  return Moose::stringify(_items, " ");
126 }
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:66
std::set< MooseEnumItem > _items
Storage for the assigned items.
bool MooseEnumBase::isOutOfRangeAllowed ( ) const
inlineinherited

isOutOfRangeAllowed

Returns
- a Boolean indicating whether enum names out of range are allowed

Definition at line 83 of file MooseEnumBase.h.

83 { return _out_of_range_index; }
int _out_of_range_index
The index of values assigned that are NOT values in this enum.
virtual bool MultiMooseEnum::isValid ( ) const
inlineoverridevirtual

IsValid.

Returns
- a Boolean indicating whether this Enumeration has been set

Implements MooseEnumBase.

Definition at line 161 of file MultiMooseEnum.h.

161 { return !_current.empty(); }
std::vector< MooseEnumItem > _current
The current id.
bool MultiMooseEnum::operator!= ( const MultiMooseEnum value) const

Definition at line 60 of file MultiMooseEnum.C.

61 {
62  return !(*this == value);
63 }
MultiMooseEnum & MultiMooseEnum::operator= ( const std::string &  names)

Assignment operators.

Parameters
names- a string, set, or vector representing one of the enumeration values.
Returns
A reference to this object for chaining

Definition at line 108 of file MultiMooseEnum.C.

109 {
110  std::vector<std::string> names_vector;
111  MooseUtils::tokenize(names, names_vector, 1, " ");
112  return assign(names_vector.begin(), names_vector.end(), false);
113 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
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 ...
Definition: MooseUtils.h:350
MultiMooseEnum & MultiMooseEnum::operator= ( const std::vector< std::string > &  names)

Definition at line 116 of file MultiMooseEnum.C.

117 {
118  return assign(names.begin(), names.end(), false);
119 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
MultiMooseEnum & MultiMooseEnum::operator= ( const std::set< std::string > &  names)

Definition at line 122 of file MultiMooseEnum.C.

123 {
124  return assign(names.begin(), names.end(), false);
125 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
bool MultiMooseEnum::operator== ( const MultiMooseEnum value) const

Comparison operators for comparing with character constants, MultiMooseEnums or integer values.

Parameters
value- RHS value to compare against
Returns
bool - the truth value for the comparison

Definition at line 49 of file MultiMooseEnum.C.

50 {
51  // Not the same if the lengths are different
52  if (value.size() != size())
53  return false;
54 
55  // Return false if this enum does not contain an item from the other
56  return (_current == value._current) && (_items == value._items);
57 }
std::vector< MooseEnumItem > _current
The current id.
std::set< MooseEnumItem > _items
Storage for the assigned items.
unsigned int size() const
Return the number of items in the MultiMooseEnum.
const std::string & MultiMooseEnum::operator[] ( unsigned int  i) const

Indexing operator Operator to retrieve an item from the MultiMooseEnum.

The reference may not be used to change the item.

Parameters
iindex
Returns
a read/read-write reference to the item as a string.

Definition at line 167 of file MultiMooseEnum.C.

168 {
169  mooseAssert(i < _current.size(),
170  "Access out of bounds in MultiMooseEnum (i: " << i << " size: " << _current.size()
171  << ")");
172 
173  return _current[i].rawName();
174 }
std::vector< MooseEnumItem > _current
The current id.
void MultiMooseEnum::push_back ( const std::string &  names)

Insert operators Operator to insert (push_back) values into the enum.

Existing values are preserved and duplicates are stored.

Parameters
names- a string, set, or vector representing one of the enumeration values.

Definition at line 148 of file MultiMooseEnum.C.

Referenced by Console::Console(), Output::Output(), PetscOutput::PetscOutput(), and Split::setup().

149 {
150  std::vector<std::string> names_vector;
151  MooseUtils::tokenize(names, names_vector, 1, " ");
152  assign(names_vector.begin(), names_vector.end(), true);
153 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
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 ...
Definition: MooseUtils.h:350
void MultiMooseEnum::push_back ( const std::vector< std::string > &  names)

Definition at line 156 of file MultiMooseEnum.C.

157 {
158  assign(names.begin(), names.end(), true);
159 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
void MultiMooseEnum::push_back ( const std::set< std::string > &  names)

Definition at line 162 of file MultiMooseEnum.C.

163 {
164  assign(names.begin(), names.end(), true);
165 }
MultiMooseEnum & assign(InputIterator first, InputIterator last, bool append)
Helper method for all inserts and assignment operators.
template<typename InputIterator >
void MultiMooseEnum::remove ( InputIterator  first,
InputIterator  last 
)
private

Helper method for un-assigning enumeration values.

Definition at line 222 of file MultiMooseEnum.C.

223 {
224  // Create a new list of enumerations by striping out the supplied values
225  for (InputIterator it = first; it != last; ++it)
226  {
227  // Values stored as upper case
228  std::string upper(MooseUtils::toUpper(*it));
229  std::vector<MooseEnumItem>::iterator iter =
230  std::find_if(_current.begin(), _current.end(), [&upper](const MooseEnumItem & item) {
231  return item.name() == upper;
232  });
233  if (iter != _current.end())
234  _current.erase(iter);
235  }
236 }
std::vector< MooseEnumItem > _current
The current id.
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:555
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
unsigned int MultiMooseEnum::size ( ) const

Friends And Related Function Documentation

friend class libMesh::Parameters
friend

Definition at line 165 of file MultiMooseEnum.h.

std::ostream& operator<< ( std::ostream &  out,
const MultiMooseEnum obj 
)
friend

Operator for printing to iostreams.

Definition at line 258 of file MultiMooseEnum.C.

259 {
260  out << Moose::stringify(obj._current, " ");
261  return out;
262 }
std::vector< MooseEnumItem > _current
The current id.
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:66

Member Data Documentation

std::vector<MooseEnumItem> MultiMooseEnum::_current
private

The current id.

Definition at line 199 of file MultiMooseEnum.h.

Referenced by assign(), checkDeprecated(), clear(), contains(), get(), operator<<(), operator==(), operator[](), remove(), and size().

std::map<std::string, std::string> MooseEnumBase::_deprecated_names
protectedinherited

The map of deprecated names and optional replacements.

Definition at line 116 of file MooseEnumBase.h.

Referenced by MooseEnumBase::checkDeprecatedBase(), and MooseEnumBase::deprecate().

std::set<MooseEnumItem> MooseEnumBase::_items
protectedinherited
int MooseEnumBase::_out_of_range_index
protectedinherited

The index of values assigned that are NOT values in this enum.

If this index is 0 (false) then out of range values are not allowed.

Definition at line 122 of file MooseEnumBase.h.

Referenced by assign(), MooseEnumBase::isOutOfRangeAllowed(), MooseEnum::operator=(), and MooseEnum::operator==().

const int MooseEnumBase::INVALID_ID = std::numeric_limits<int>::min()
staticprotectedinherited

Constants.

Definition at line 125 of file MooseEnumBase.h.

Referenced by MooseEnum::operator=().


The documentation for this class was generated from the following files: