https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MooseEnumItem.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12// STL includes
13#include <string>
14
19{
20public:
21 static const int INVALID_ID;
23 MooseEnumItem(const std::string & name, const int & id = INVALID_ID);
24 ~MooseEnumItem() = default;
25 MooseEnumItem(const MooseEnumItem & other);
26 MooseEnumItem(MooseEnumItem && /*other*/) = default;
27 MooseEnumItem & operator=(const MooseEnumItem & other);
28 MooseEnumItem & operator=(MooseEnumItem && /*other*/) = default;
29
31
34 const int & id() const { return _id; }
35 const std::string & name() const { return _name; }
36 const std::string & rawName() const { return _raw_name; }
38
40
43 operator int() const { return _id; }
44 operator std::string() const { return _name; }
46
48
53 bool operator==(const char * value) const;
54 bool operator!=(const char * value) const;
55
56 bool operator==(const std::string & value) const;
57 bool operator!=(const std::string & value) const;
58
59 bool operator==(int value) const { return _id == value; }
60 bool operator!=(int value) const { return _id != value; }
61
62 bool operator==(unsigned short value) const { return _id == value; }
63 bool operator!=(unsigned short value) const { return _id != value; }
64
65 bool operator==(const MooseEnumItem &) const;
66 bool operator!=(const MooseEnumItem &) const;
68
72 bool operator<(const MooseEnumItem & other) const
73 {
74 return _id != other._id ? _id < other._id : _name < other._name;
75 }
76
80 friend std::ostream & operator<<(std::ostream & out, const MooseEnumItem & item);
81
89 void setID(const int & id);
90
91private:
93 std::string _raw_name;
94
96 std::string _name;
97
99 int _id;
100};
void ErrorVector unsigned int
Class for containing MooseEnum item information.
MooseEnumItem & operator=(const MooseEnumItem &other)
std::string _name
Upper case name.
const std::string & name() const
friend std::ostream & operator<<(std::ostream &out, const MooseEnumItem &item)
ostream operator for string printing.
bool operator<(const MooseEnumItem &other) const
Less than operator.
const int & id() const
Return the numeric, name, or raw name.
bool operator!=(const char *value) const
void setID(const int &id)
Method to change the ID of the item, but only if it is an INVALID_ID.
int _id
The numeric value for item.
bool operator==(int value) const
bool operator==(const char *value) const
Comparison operators.
MooseEnumItem & operator=(MooseEnumItem &&)=default
~MooseEnumItem()=default
std::string _raw_name
The name as provided in constructor.
MooseEnumItem(MooseEnumItem &&)=default
bool operator==(unsigned short value) const
bool operator!=(unsigned short value) const
bool operator!=(int value) const
const std::string & rawName() const
static const int INVALID_ID