TrueReality  v0.1.1912
EnumerationString.cpp
Go to the documentation of this file.
1 /*
2 * True Reality Open Source Game and Simulation Engine
3 * Copyright © 2021 Acid Rain Studios LLC
4 *
5 * The Base of this class has been adopted from the Delta3D engine
6 *
7 * This library is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Lesser General Public License as published by the Free
9 * Software Foundation; either version 3.0 of the License, or (at your option)
10 * any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this library; if not, write to the Free Software Foundation, Inc.,
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 * @author Matthew W. Campbell
22 * @author David Guthrie
23 * @author Maxim Serebrennik
24 */
26 
27 namespace trUtil
28 {
30  bool EnumerationString::operator==(const std::string& rhs) const
31  {
32  return Compare(rhs) == 0;
33  }
34 
36  bool EnumerationString::operator!=(const std::string& rhs) const
37  {
38  return Compare(rhs) != 0;
39  }
40 
42  bool EnumerationString::operator<(const std::string& rhs) const
43  {
44  return Compare(rhs) < 0;
45  }
46 
48  bool EnumerationString::operator>(const std::string& rhs) const
49  {
50  return Compare(rhs) > 0;
51  }
52 
54  int EnumerationString::Compare(const std::string& nameString) const
55  {
56  return mName.compare(nameString);
57  }
58 
61  {
62  }
63 
65  EnumerationString::EnumerationString(const std::string& name)
66  : mName(name)
67  {
68  }
69 
72  {
73  return *this;
74  }
75 
78  {
79  }
80 
82  std::ostream& operator<<(std::ostream& os, const EnumerationString& e)
83  {
84  os << e.GetName();
85  return os;
86  }
87 }
bool operator<(const std::string &rhs) const
Overloaded less than test for this EnumerationString&#39;s string value.
virtual ~EnumerationString()
Private virtual destructor to get rid of compile warning.
const std::string & GetName() const
Inlined because it&#39;s called frequently.
bool operator>(const std::string &rhs) const
Overloaded greater than test for this EnumerationString&#39;s string value.
EnumerationString(const std::string &name)
Construct the EnumerationString.
bool operator!=(const EnumerationString &rhs) const
Inequality test for an EnumerationString.
std::string mName
String representation of the EnumerationString.
TR_UTIL_EXPORT std::ostream & operator<<(std::ostream &os, const EnumerationString &e)
Helper method to print EnumerationNumeric to an output stream.
virtual int Compare(const std::string &nameString) const
Virtual string compare method to used by the operators that take a string.
This class represents a type-safe EnumerationString pattern.
EnumerationString & operator=(const EnumerationString &)
Private assignment operator to enforce EnumerationString storage by reference.
Namespace that holds various utility classes for the engine.
Definition: SmrtPtr.h:208
bool operator==(const EnumerationString &rhs) const
Equality test for an EnumerationString.