www.mooseframework.org
MooseEnumItem.h
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 #ifndef MOOSEENUMITEM_H
16 #define MOOSEENUMITEM_H
17 
18 // STL includes
19 #include <string>
20 
25 {
26 public:
27  MooseEnumItem(const std::string & name, const int & id);
28  ~MooseEnumItem() = default;
29  MooseEnumItem(const MooseEnumItem & other);
30  MooseEnumItem(MooseEnumItem && other) = default;
31  MooseEnumItem & operator=(const MooseEnumItem & other);
32  MooseEnumItem & operator=(MooseEnumItem && other) = default;
33 
35 
38  const int & id() const { return _id; }
39  const std::string & name() const { return _name; }
40  const std::string & rawName() const { return _raw_name; }
42 
44 
47  operator int() const { return _id; }
48  operator std::string() const { return _name; }
50 
52 
57  bool operator==(const char * value) const;
58  bool operator!=(const char * value) const;
59 
60  bool operator==(const std::string & value) const;
61  bool operator!=(const std::string & value) const;
62 
63  bool operator==(int value) const { return _id == value; }
64  bool operator!=(int value) const { return _id != value; }
65 
66  bool operator==(unsigned short value) const { return _id == value; }
67  bool operator!=(unsigned short value) const { return _id != value; }
68 
69  bool operator==(const MooseEnumItem &) const;
70  bool operator!=(const MooseEnumItem &) const;
72 
76  bool operator<(const MooseEnumItem & other) const { return _id < other._id; }
77 
81  friend std::ostream & operator<<(std::ostream & out, const MooseEnumItem & item);
82 
83 private:
85  std::string _raw_name;
86 
88  std::string _name;
89 
91  int _id;
92 };
93 
94 #endif
friend std::ostream & operator<<(std::ostream &out, const MooseEnumItem &item)
ostream operator for string printing.
Definition: MooseEnumItem.C:79
int _id
The numeric value for item.
Definition: MooseEnumItem.h:91
bool operator!=(int value) const
Definition: MooseEnumItem.h:64
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:38
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
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
bool operator!=(unsigned short value) const
Definition: MooseEnumItem.h:67
bool operator==(unsigned short value) const
Definition: MooseEnumItem.h:66
MooseEnumItem(const std::string &name, const int &id)
Definition: MooseEnumItem.C:19
Class for containing MooseEnum item information.
Definition: MooseEnumItem.h:24
~MooseEnumItem()=default
bool operator==(const char *value) const
Comparison operators.
Definition: MooseEnumItem.C:39
bool operator<(const MooseEnumItem &other) const
Less than operator.
Definition: MooseEnumItem.h:76
bool operator==(int value) const
Definition: MooseEnumItem.h:63