www.mooseframework.org
MooseEnumItem.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
16 #include "MooseEnumItem.h"
17 #include "MooseUtils.h"
18 
19 MooseEnumItem::MooseEnumItem(const std::string & name, const int & id)
20  : _raw_name(MooseUtils::trim(name)), _name(MooseUtils::toUpper(_raw_name)), _id(id)
21 {
22 }
23 
25  : _raw_name(other._raw_name), _name(other._name), _id(other._id)
26 {
27 }
28 
31 {
32  _raw_name = other._raw_name;
33  _name = other._name;
34  _id = other._id;
35  return *this;
36 }
37 
38 bool
39 MooseEnumItem::operator==(const char * value) const
40 {
41  std::string name(MooseUtils::toUpper(value));
42  return _name == name;
43 }
44 
45 bool
46 MooseEnumItem::operator!=(const char * value) const
47 {
48  std::string name(MooseUtils::toUpper(value));
49  return _name != name;
50 }
51 
52 bool
53 MooseEnumItem::operator==(const std::string & value) const
54 {
55  std::string name(MooseUtils::toUpper(value));
56  return _name == name;
57 }
58 
59 bool
60 MooseEnumItem::operator!=(const std::string & value) const
61 {
62  std::string name(MooseUtils::toUpper(value));
63  return _name != name;
64 }
65 
66 bool
68 {
69  mooseError("Direct comparison between MooseEnumItems is not supported.");
70 }
71 
72 bool
74 {
75  mooseError("Direct comparison between MooseEnumItems is not supported.");
76 }
77 
78 std::ostream &
79 operator<<(std::ostream & out, const MooseEnumItem & item)
80 {
81  out << item.rawName();
82  return out;
83 }
friend std::ostream & operator<<(std::ostream &out, const MooseEnumItem &item)
ostream operator for string printing.
Definition: MooseEnumItem.C:79
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:555
int _id
The numeric value for item.
Definition: MooseEnumItem.h:91
std::string _name
Upper case name.
Definition: MooseEnumItem.h:88
const std::string & rawName() const
Definition: MooseEnumItem.h:40
MooseEnumItem & operator=(const MooseEnumItem &other)
Definition: MooseEnumItem.C:30
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
bool operator!=(const char *value) const
Definition: MooseEnumItem.C:46
std::string _raw_name
The name as provided in constructor.
Definition: MooseEnumItem.h:85
const std::string & name() const
Definition: MooseEnumItem.h:39
MooseEnumItem(const std::string &name, const int &id)
Definition: MooseEnumItem.C:19
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
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
bool operator==(const char *value) const
Comparison operators.
Definition: MooseEnumItem.C:39