ome-xml 5.2.3

NamingConvention.h
1 /*
2 * #%L
3 * OME-XML C++ library for working with OME-XML metadata structures.
4 * %%
5 * Copyright © 2006 - 2016 Open Microscopy Environment:
6 * - Massachusetts Institute of Technology
7 * - National Institutes of Health
8 * - University of Dundee
9 * - Board of Regents of the University of Wisconsin-Madison
10 * - Glencoe Software, Inc.
11 * %%
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * The views and conclusions contained in the software and documentation are
34 * those of the authors and should not be interpreted as representing official
35 * policies, either expressed or implied, of any organization.
36 * #L%
37 */
38
39 /*─────────────────────────────────────────────────────────────────────────────
40 *
41 * THIS IS AUTOMATICALLY GENERATED CODE. DO NOT MODIFY.
42 *
43 *─────────────────────────────────────────────────────────────────────────────
44 */
45
46 #ifndef OME_XML_MODEL_ENUMS_NAMINGCONVENTION_H
47 #define OME_XML_MODEL_ENUMS_NAMINGCONVENTION_H
48
49 #include <ostream>
50 #include <map>
51 #include <string>
52
53 #include <ome/common/log.h>
54
55 #include <ome/xml/model/enums/EnumerationException.h>
56
57 // All values in the NamingConvention enumeration.
58 #define OME_XML_MODEL_ENUMS_NAMINGCONVENTION_VALUES (LETTER)(NUMBER)
59
60 namespace ome
61 {
62 namespace xml
63 {
64 namespace model
65 {
66 namespace enums
67 {
68
72 class NamingConvention
73 {
74 public:
76 enum enum_value
77 {
104 LETTER,
110 NUMBER
111 };
112
118 NamingConvention (enum_value value);
119
134 NamingConvention (const std::string& name, bool strict = true);
135
141 NamingConvention (const NamingConvention& original);
142
147 inline NamingConvention&
148 operator= (const NamingConvention& rhs)
149 {
150 this->value = rhs.value;
151 this->name = rhs.name;
152 return *this;
153 }
154
160 inline
161 operator enum_value () const
162 {
163 return this->value;
164 }
165
171 inline
172 operator const std::string& () const
173 {
174 return *this->name;
175 }
176
178 typedef std::map<std::string, NamingConvention::enum_value> string_map_type;
180 typedef std::map<NamingConvention::enum_value, std::string> value_map_type;
181
187 static const string_map_type&
188 strings();
189
195 static const value_map_type&
196 values();
197
198 private:
204 static const string_map_type&
205 lowercase_strings();
206
208 enum_value value;
210 const std::string *name;
211 };
212
220 inline bool
221 operator== (const NamingConvention& lhs,
222 const NamingConvention& rhs)
223 {
224 return static_cast<NamingConvention::enum_value>(lhs) == static_cast<NamingConvention::enum_value>(rhs);
225 }
226
234 inline bool
235 operator== (const NamingConvention& lhs,
236 const NamingConvention::enum_value& rhs)
237 {
238 return static_cast<NamingConvention::enum_value>(lhs) == rhs;
239 }
240
248 inline bool
249 operator== (const NamingConvention::enum_value& lhs,
250 const NamingConvention& rhs)
251 {
252 return lhs == static_cast<NamingConvention::enum_value>(rhs);
253 }
254
262 inline bool
263 operator== (const NamingConvention& lhs,
264 const std::string& rhs)
265 {
266 return static_cast<const std::string&>(lhs) == rhs;
267 }
268
276 inline bool
277 operator== (const std::string& lhs,
278 const NamingConvention& rhs)
279 {
280 return lhs == static_cast<const std::string&>(rhs);
281 }
282
290 inline bool
291 operator!= (const NamingConvention& lhs,
292 const NamingConvention& rhs)
293 {
294 return static_cast<NamingConvention::enum_value>(lhs) != static_cast<NamingConvention::enum_value>(rhs);
295 }
296
304 inline bool
305 operator!= (const NamingConvention& lhs,
306 const NamingConvention::enum_value& rhs)
307 {
308 return static_cast<NamingConvention::enum_value>(lhs) != rhs;
309 }
310
318 inline bool
319 operator!= (const NamingConvention::enum_value& lhs,
320 const NamingConvention& rhs)
321 {
322 return lhs != static_cast<NamingConvention::enum_value>(rhs);
323 }
324
332 inline bool
333 operator!= (const NamingConvention& lhs,
334 const std::string& rhs)
335 {
336 return static_cast<const std::string&>(lhs) != rhs;
337 }
338
346 inline bool
347 operator!= (const std::string& lhs,
348 const NamingConvention& rhs)
349 {
350 return lhs != static_cast<const std::string&>(rhs);
351 }
352
360 template<class charT, class traits>
361 inline std::basic_ostream<charT,traits>&
362 operator<< (std::basic_ostream<charT,traits>& os,
363 const NamingConvention& enumeration)
364 {
365 return os << static_cast<const std::string&>(enumeration);
366 }
367
375 template<class charT, class traits>
376 inline std::basic_istream<charT,traits>&
377 operator>> (std::basic_istream<charT,traits>& is,
378 NamingConvention& enumeration)
379 {
380 std::string value;
381 is >> value;
382 if (is)
383 {
384 try
385 {
386 enumeration = NamingConvention(value, false);
387 }
388 catch (const EnumerationException&)
389 {
390 is.setstate(std::ios::failbit);
391 }
392 }
393
394 return is;
395 }
396
397 }
398 }
399 }
400 }
401
402 #endif // OME_XML_MODEL_ENUMS_NAMINGCONVENTION_H
403
404 /*
405 * Local Variables:
406 * mode:C++
407 * End:
408 */
ome::xml::model::enums::operator>>
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &is, AcquisitionMode &enumeration)
Set AcquisitionMode from input stream.
Definition: AcquisitionMode.h:390
ome::xml::model::enums::operator!=
bool operator!=(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for non-equality.
Definition: AcquisitionMode.h:304
ome::xml::model::enums::NamingConvention::operator=
NamingConvention & operator=(const NamingConvention &rhs)
Assignment operator.
Definition: NamingConvention.h:148
ome::xml::model::enums::NamingConvention::name
const std::string * name
Enumeration name.
Definition: NamingConvention.h:210
ome::xml::model::enums::EnumerationException
EnumerationException is thrown when an enumeration is invalid or not found.
Definition: EnumerationException.h:74
ome::xml::model::enums::NamingConvention::value
enum_value value
Enumeration value.
Definition: NamingConvention.h:208
ome::xml::model::enums::NamingConvention::string_map_type
std::map< std::string, NamingConvention::enum_value > string_map_type
String map type.
Definition: NamingConvention.h:178
ome::xml::model::enums::NamingConvention
NamingConvention enumeration.
Definition: NamingConvention.h:72
ome
Open Microscopy Environment C++ implementation.
ome::xml::model::enums::NamingConvention::values
static const value_map_type & values()
Get a map of valid enum values and string names.
Definition: NamingConvention.cpp:153
ome::xml::model::enums::NamingConvention::value_map_type
std::map< NamingConvention::enum_value, std::string > value_map_type
Value map type.
Definition: NamingConvention.h:180
ome::xml::model::enums::operator==
bool operator==(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for equality.
Definition: AcquisitionMode.h:234
ome::xml::model::enums::NamingConvention::LETTER
While the label type &#39;number&#39; has a clear meaning the &#39;letter&#39; type is more complex.
Definition: NamingConvention.h:104
ome::xml::model::enums::NamingConvention::NUMBER
1, 2, 3, ...
Definition: NamingConvention.h:110
ome::xml::model::enums::NamingConvention::NamingConvention
NamingConvention(enum_value value)
Construct a NamingConvention enumeration by an enumeration value.
Definition: NamingConvention.cpp:75
ome::xml::model::enums::NamingConvention::enum_value
enum_value
Enumeration values.
Definition: NamingConvention.h:76
log.h
ome::xml::model::enums::NamingConvention::lowercase_strings
static const string_map_type & lowercase_strings()
Get a map of valid lowercased string names and enum values.
Definition: NamingConvention.cpp:168
ome::xml::model::enums::NamingConvention::strings
static const string_map_type & strings()
Get a map of valid string names and enum values.
Definition: NamingConvention.cpp:138