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

Class for containing MooseEnum item information. More...

#include <MooseEnumItem.h>

Inheritance diagram for MooseEnumItem:
[legend]

Public Member Functions

 MooseEnumItem ()
 
 MooseEnumItem (const std::string &name, const int &id=INVALID_ID)
 
 ~MooseEnumItem ()=default
 
 MooseEnumItem (const MooseEnumItem &other)
 
 MooseEnumItem (MooseEnumItem &&)=default
 
MooseEnumItemoperator= (const MooseEnumItem &other)
 
MooseEnumItemoperator= (MooseEnumItem &&)=default
 
bool operator< (const MooseEnumItem &other) const
 Less than operator. More...
 
void setID (const int &id)
 Method to change the ID of the item, but only if it is an INVALID_ID. More...
 
const intid () const
 Return the numeric, name, or raw name. More...
 
const std::string & name () const
 
const std::string & rawName () const
 
 operator int () const
 Operator to allow this class to be used directly as a string for int. More...
 
 operator std::string () const
 
bool operator== (const char *value) const
 Comparison operators. More...
 
bool operator!= (const char *value) const
 
bool operator== (const std::string &value) const
 
bool operator!= (const std::string &value) const
 
bool operator== (int value) const
 
bool operator!= (int value) const
 
bool operator== (unsigned short value) const
 
bool operator!= (unsigned short value) const
 
bool operator== (const MooseEnumItem &) const
 
bool operator!= (const MooseEnumItem &) const
 

Static Public Attributes

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

Private Attributes

std::string _raw_name
 The name as provided in constructor. More...
 
std::string _name
 Upper case name. More...
 
int _id
 The numeric value for item. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const MooseEnumItem &item)
 ostream operator for string printing. More...
 

Detailed Description

Class for containing MooseEnum item information.

Definition at line 18 of file MooseEnumItem.h.

Constructor & Destructor Documentation

◆ MooseEnumItem() [1/4]

MooseEnumItem::MooseEnumItem ( )

Definition at line 14 of file MooseEnumItem.C.

14 : _raw_name("INVALID"), _name("INVALID"), _id(INVALID_ID) {}
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
static const int INVALID_ID
Definition: MooseEnumItem.h:21
std::string _raw_name
The name as provided in constructor.
Definition: MooseEnumItem.h:93

◆ MooseEnumItem() [2/4]

MooseEnumItem::MooseEnumItem ( const std::string &  name,
const int id = INVALID_ID 
)

Definition at line 16 of file MooseEnumItem.C.

18 {
19 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
std::string _raw_name
The name as provided in constructor.
Definition: MooseEnumItem.h:93
std::string trim(const std::string &str, const std::string &white_space=" \\\)
Standard scripting language trim function.
Definition: MooseUtils.C:214

◆ ~MooseEnumItem()

MooseEnumItem::~MooseEnumItem ( )
default

◆ MooseEnumItem() [3/4]

MooseEnumItem::MooseEnumItem ( const MooseEnumItem other)

Definition at line 21 of file MooseEnumItem.C.

22  : _raw_name(other._raw_name), _name(other._name), _id(other._id)
23 {
24 }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
std::string _raw_name
The name as provided in constructor.
Definition: MooseEnumItem.h:93

◆ MooseEnumItem() [4/4]

MooseEnumItem::MooseEnumItem ( MooseEnumItem &&  )
default

Member Function Documentation

◆ id()

const int& MooseEnumItem::id ( ) const
inline

◆ name()

const std::string& MooseEnumItem::name ( ) const
inline

◆ operator int()

MooseEnumItem::operator int ( ) const
inline

Operator to allow this class to be used directly as a string for int.

Definition at line 43 of file MooseEnumItem.h.

43 { return _id; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99

◆ operator std::string()

MooseEnumItem::operator std::string ( ) const
inline

Definition at line 44 of file MooseEnumItem.h.

44 { return _name; }
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator!=() [1/5]

bool MooseEnumItem::operator!= ( const char *  value) const

Definition at line 43 of file MooseEnumItem.C.

44 {
45  std::string name(MooseUtils::toUpper(value));
46  return _name != name;
47 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator!=() [2/5]

bool MooseEnumItem::operator!= ( const std::string &  value) const

Definition at line 57 of file MooseEnumItem.C.

58 {
59  std::string name(MooseUtils::toUpper(value));
60  return _name != name;
61 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator!=() [3/5]

bool MooseEnumItem::operator!= ( int  value) const
inline

Definition at line 60 of file MooseEnumItem.h.

60 { return _id != value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator!=() [4/5]

bool MooseEnumItem::operator!= ( unsigned short  value) const
inline

Definition at line 63 of file MooseEnumItem.h.

63 { return _id != value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator!=() [5/5]

bool MooseEnumItem::operator!= ( const MooseEnumItem item) const

Definition at line 70 of file MooseEnumItem.C.

71 {
72  return _id != item.id() && _name != MooseUtils::toUpper(item.name());
73 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:34

◆ operator<()

bool MooseEnumItem::operator< ( const MooseEnumItem other) const
inline

Less than operator.

This is required for this class to work in maps and sets.

Definition at line 72 of file MooseEnumItem.h.

73  {
74  return _id != other._id ? _id < other._id : _name < other._name;
75  }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator=() [1/2]

MooseEnumItem & MooseEnumItem::operator= ( const MooseEnumItem other)

Definition at line 27 of file MooseEnumItem.C.

28 {
29  _raw_name = other._raw_name;
30  _name = other._name;
31  _id = other._id;
32  return *this;
33 }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
std::string _raw_name
The name as provided in constructor.
Definition: MooseEnumItem.h:93

◆ operator=() [2/2]

MooseEnumItem& MooseEnumItem::operator= ( MooseEnumItem &&  )
default

◆ operator==() [1/5]

bool MooseEnumItem::operator== ( const char *  value) const

Comparison operators.

The comparison operators using the char * and string are case sensitive.

Definition at line 36 of file MooseEnumItem.C.

37 {
38  std::string name(MooseUtils::toUpper(value));
39  return _name == name;
40 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator==() [2/5]

bool MooseEnumItem::operator== ( const std::string &  value) const

Definition at line 50 of file MooseEnumItem.C.

51 {
52  std::string name(MooseUtils::toUpper(value));
53  return _name == name;
54 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96

◆ operator==() [3/5]

bool MooseEnumItem::operator== ( int  value) const
inline

Definition at line 59 of file MooseEnumItem.h.

59 { return _id == value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator==() [4/5]

bool MooseEnumItem::operator== ( unsigned short  value) const
inline

Definition at line 62 of file MooseEnumItem.h.

62 { return _id == value; }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)

◆ operator==() [5/5]

bool MooseEnumItem::operator== ( const MooseEnumItem item) const

Definition at line 64 of file MooseEnumItem.C.

65 {
66  return _id == item.id() && _name == MooseUtils::toUpper(item.name());
67 }
const std::string & name() const
Definition: MooseEnumItem.h:35
std::string toUpper(const std::string &name)
Convert supplied string to upper case.
Definition: MooseUtils.C:1040
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:34

◆ rawName()

const std::string& MooseEnumItem::rawName ( ) const
inline

Definition at line 36 of file MooseEnumItem.h.

Referenced by MooseEnum::operator std::string(), and operator<<().

36 { return _raw_name; }
std::string _raw_name
The name as provided in constructor.
Definition: MooseEnumItem.h:93

◆ setID()

void MooseEnumItem::setID ( const int id)

Method to change the ID of the item, but only if it is an INVALID_ID.

An error is produced if the ID is valid and this method is called.

This is needed to allow ExecFlagType objects to be created without an ID being provided, the ID is assigned when ExecFlagEnum::addAvailableFlags is called.

Definition at line 83 of file MooseEnumItem.C.

84 {
85  if (_id != INVALID_ID)
86  mooseError("The ID of a MooseEnumItem can not be changed if it is valid, the item ",
87  _name,
88  " has a valid id of ",
89  _id,
90  ".");
91  _id = id;
92 }
int _id
The numeric value for item.
Definition: MooseEnumItem.h:99
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:299
std::string _name
Upper case name.
Definition: MooseEnumItem.h:96
static const int INVALID_ID
Definition: MooseEnumItem.h:21
const int & id() const
Return the numeric, name, or raw name.
Definition: MooseEnumItem.h:34

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const MooseEnumItem item 
)
friend

ostream operator for string printing.

Definition at line 76 of file MooseEnumItem.C.

77 {
78  out << item.rawName();
79  return out;
80 }
const std::string & rawName() const
Definition: MooseEnumItem.h:36
OStreamProxy out

Member Data Documentation

◆ _id

int MooseEnumItem::_id
private

The numeric value for item.

Definition at line 99 of file MooseEnumItem.h.

Referenced by id(), operator int(), operator!=(), operator<(), operator=(), operator==(), and setID().

◆ _name

std::string MooseEnumItem::_name
private

Upper case name.

Definition at line 96 of file MooseEnumItem.h.

Referenced by name(), operator std::string(), operator!=(), operator<(), operator=(), operator==(), and setID().

◆ _raw_name

std::string MooseEnumItem::_raw_name
private

The name as provided in constructor.

Definition at line 93 of file MooseEnumItem.h.

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

◆ INVALID_ID

const int MooseEnumItem::INVALID_ID = std::numeric_limits<int>::min()
static

Definition at line 21 of file MooseEnumItem.h.

Referenced by MooseEnum::assign(), MooseEnum::isValid(), and setID().


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