Sierra Toolkit  Version of the Day
Identifier.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef STK_UTIL_UTIL_IDENTIFIER_H
10 #define STK_UTIL_UTIL_IDENTIFIER_H
11 
12 #include <string>
13 #include <stk_util/util/ci_string.hpp>
14 
15 #include <boost/unordered_set.hpp> // boost 1.36.0 unordered_set not in the tr1
16 
17 namespace std {
18 namespace tr1 {
19  using ::boost::unordered_set;
20 }
21 }
22 
23 namespace stk_classic {
24 
25 class IdentifierA
26 {
27 public:
28  static int compare(const char *s1, const size_t s1_length, const char *s2, const size_t s2_length);
29 
30  IdentifierA()
31  {}
32 
33  IdentifierA(const IdentifierA &identifier)
34  : m_string(identifier.m_string)
35  {}
36 
37  explicit IdentifierA(const std::string &string)
38  : m_string(string)
39  {}
40 
41  explicit IdentifierA(const char *string)
42  : m_string(string)
43  {}
44 
45  IdentifierA &operator=(const IdentifierA &identifier) {
46  if (&identifier != this)
47  m_string = identifier.m_string;
48  return *this;
49  }
50 
51  IdentifierA &operator=(const std::string &string) {
52  m_string = string;
53  return *this;
54  }
55 
56  IdentifierA &operator+=(const IdentifierA &identifier) {
57  m_string.append(identifier.m_string);
58  return *this;
59  }
60 
61  IdentifierA &operator+=(const std::string &string) {
62  m_string.append(string);
63  return *this;
64  }
65 
66  const char *c_str() const {
67  return m_string.c_str();
68  }
69 
70  const size_t length() const {
71  return m_string.length();
72  }
73 
74  operator const std::string &() const {
75  return m_string;
76  }
77 
78 private:
79  std::string m_string;
80 };
81 
82 
83 IdentifierA operator+(const IdentifierA &identifier1, const IdentifierA &identifier2);
84 
85 IdentifierA operator+(const IdentifierA &identifier1, const std::string &string2);
86 
87 std::string operator+(const std::string &string1, const IdentifierA &identifier2);
88 
89 std::ostream &operator<<(std::ostream &os, const IdentifierA &identifier);
90 
91 std::istream &operator>>(std::istream &is, IdentifierA &identifier);
92 
93 bool operator<(const std::string &s1, const IdentifierA &s2);
94 
95 bool operator<(const IdentifierA &s1, const std::string &s2);
96 
97 bool operator<(const IdentifierA &s1, const IdentifierA &s2);
98 
99 bool operator<(const IdentifierA &s1, const char *s2);
100 
101 bool operator==(const std::string &s1, const IdentifierA &s2);
102 
103 bool operator==(const IdentifierA &s1, const std::string &s2);
104 
105 bool operator==(const IdentifierA &s1, const IdentifierA &s2);
106 
107 bool operator==(const IdentifierA &s1, const char *s2);
108 
109 bool operator<=(const std::string &s1, const IdentifierA &s2);
110 
111 bool operator<=(const IdentifierA &s1, const std::string &s2);
112 
113 bool operator<=(const IdentifierA &s1, const IdentifierA &s2);
114 
115 bool operator<=(const IdentifierA &s1, const char *s2);
116 
117 bool operator>(const std::string &s1, const IdentifierA &s2);
118 
119 bool operator>(const IdentifierA &s1, const std::string &s2);
120 
121 bool operator>(const IdentifierA &s1, const IdentifierA &s2);
122 
123 bool operator>(const IdentifierA &s1, const char *s2);
124 
125 bool operator>=(const std::string &s1, const IdentifierA &s2);
126 
127 bool operator>=(const IdentifierA &s1, const std::string &s2);
128 
129 bool operator>=(const IdentifierA &s1, const IdentifierA &s2);
130 
131 bool operator>=(const IdentifierA &s1, const char *s2);
132 
133 bool operator!=(const std::string &s1, const IdentifierA &s2);
134 
135 bool operator!=(const IdentifierA &s1, const std::string &s2);
136 
137 bool operator!=(const IdentifierA &s1, const IdentifierA &s2);
138 
139 bool operator!=(const IdentifierA &s1, const char *s2);
140 
141 
142 
143 
144 class IdentifierB : public std::string
145 {
146 public:
147  static int compare(const char *s1, const size_t s1_length, const char *s2, const size_t s2_length);
148 
149  IdentifierB()
150  {}
151 
152  IdentifierB(const IdentifierB &identifier)
153  : std::string(static_cast<std::string>(identifier))
154  {}
155 
156  explicit IdentifierB(const std::string &string)
157  : std::string(string)
158  {}
159 
160  explicit IdentifierB(const char *string)
161  : std::string(string)
162  {}
163 
164  IdentifierB &operator=(const IdentifierB &identifier) {
165  std::string::operator=(identifier);
166  return *this;
167  }
168 
169  IdentifierB &operator=(const std::string &string) {
170  std::string::operator=(string);
171  return *this;
172  }
173 
174  IdentifierB &operator=(const char *string) {
175  std::string::operator=(string);
176  return *this;
177  }
178 };
179 
180 IdentifierB operator+(const IdentifierB &identifier1, const IdentifierB &identifier2);
181 
182 IdentifierB operator+(const IdentifierB &identifier1, const std::string &string2);
183 
184 IdentifierB operator+(const IdentifierB &identifier1, const char *string2);
185 
186 std::string operator+(const std::string &string1, const IdentifierB &identifier2);
187 
188 std::ostream &operator<<(std::ostream &os, const IdentifierB &identifier);
189 
190 std::istream &operator>>(std::istream &is, IdentifierB &identifier);
191 
192 bool operator<(const std::string &s1, const IdentifierB &s2);
193 
194 bool operator<(const IdentifierB &s1, const std::string &s2);
195 
196 bool operator<(const IdentifierB &s1, const IdentifierB &s2);
197 
198 bool operator<(const IdentifierB &s1, const char *s2);
199 
200 bool operator==(const std::string &s1, const IdentifierB &s2);
201 
202 bool operator==(const IdentifierB &s1, const std::string &s2);
203 
204 bool operator==(const IdentifierB &s1, const IdentifierB &s2);
205 
206 bool operator==(const IdentifierB &s1, const char *s2);
207 
208 bool operator<=(const std::string &s1, const IdentifierB &s2);
209 
210 bool operator<=(const IdentifierB &s1, const std::string &s2);
211 
212 bool operator<=(const IdentifierB &s1, const IdentifierB &s2);
213 
214 bool operator<=(const IdentifierB &s1, const char *s2);
215 
216 bool operator>(const std::string &s1, const IdentifierB &s2);
217 
218 bool operator>(const IdentifierB &s1, const std::string &s2);
219 
220 bool operator>(const IdentifierB &s1, const IdentifierB &s2);
221 
222 bool operator>(const IdentifierB &s1, const char *s2);
223 
224 bool operator>=(const std::string &s1, const IdentifierB &s2);
225 
226 bool operator>=(const IdentifierB &s1, const std::string &s2);
227 
228 bool operator>=(const IdentifierB &s1, const IdentifierB &s2);
229 
230 bool operator>=(const IdentifierB &s1, const char *s2);
231 
232 bool operator!=(const std::string &s1, const IdentifierB &s2);
233 
234 bool operator!=(const IdentifierB &s1, const std::string &s2);
235 
236 bool operator!=(const IdentifierB &s1, const IdentifierB &s2);
237 
238 bool operator!=(const IdentifierB &s1, const char *s2);
239 
240 } // namespace stk_classic
241 
242 namespace boost {
243 
244 template <>
245 struct hash<stk_classic::IdentifierA>
246 {
247  std::size_t operator()(const stk_classic::IdentifierA &s) const;
248 };
249 
250 template <>
251 struct hash<stk_classic::IdentifierB>
252 {
253  std::size_t operator()(const stk_classic::IdentifierB &s) const;
254 };
255 
256 } // namespace boost
257 
258 #endif // STK_UTIL_UTIL_IDENTIFIER_H
std::ostream & operator<<(std::ostream &s, const Bucket &k)
Print the part names for which this bucket is a subset.
Definition: Bucket.cpp:239
basic_string< char > string
string / wstring
Sierra Toolkit.