ome-xml  5.2.4
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 
73  {
74  public:
77  {
111  };
112 
119 
134  NamingConvention (const std::string& name, bool strict = true);
135 
141  NamingConvention (const NamingConvention& original);
142 
147  inline NamingConvention&
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&
206 
210  const std::string *name;
211  };
212 
220  inline bool
222  const NamingConvention& rhs)
223  {
224  return static_cast<NamingConvention::enum_value>(lhs) == static_cast<NamingConvention::enum_value>(rhs);
225  }
226 
234  inline bool
236  const NamingConvention::enum_value& rhs)
237  {
238  return static_cast<NamingConvention::enum_value>(lhs) == rhs;
239  }
240 
248  inline bool
250  const NamingConvention& rhs)
251  {
252  return lhs == static_cast<NamingConvention::enum_value>(rhs);
253  }
254 
262  inline bool
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
292  const NamingConvention& rhs)
293  {
294  return static_cast<NamingConvention::enum_value>(lhs) != static_cast<NamingConvention::enum_value>(rhs);
295  }
296 
304  inline bool
306  const NamingConvention::enum_value& rhs)
307  {
308  return static_cast<NamingConvention::enum_value>(lhs) != rhs;
309  }
310 
318  inline bool
320  const NamingConvention& rhs)
321  {
322  return lhs != static_cast<NamingConvention::enum_value>(rhs);
323  }
324 
332  inline bool
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  */
std::basic_istream< charT, traits > & operator>>(std::basic_istream< charT, traits > &is, AcquisitionMode &enumeration)
Set AcquisitionMode from input stream.
Definition: AcquisitionMode.h:390
bool operator!=(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for non-equality.
Definition: AcquisitionMode.h:304
NamingConvention & operator=(const NamingConvention &rhs)
Assignment operator.
Definition: NamingConvention.h:148
const std::string * name
Enumeration name.
Definition: NamingConvention.h:210
EnumerationException is thrown when an enumeration is invalid or not found.
Definition: EnumerationException.h:74
enum_value value
Enumeration value.
Definition: NamingConvention.h:208
std::map< std::string, NamingConvention::enum_value > string_map_type
String map type.
Definition: NamingConvention.h:178
NamingConvention enumeration.
Definition: NamingConvention.h:72
Open Microscopy Environment C++ implementation.
static const value_map_type & values()
Get a map of valid enum values and string names.
Definition: NamingConvention.cpp:153
std::map< NamingConvention::enum_value, std::string > value_map_type
Value map type.
Definition: NamingConvention.h:180
bool operator==(const AcquisitionMode &lhs, const AcquisitionMode &rhs)
Compare two AcquisitionMode objects for equality.
Definition: AcquisitionMode.h:234
While the label type &#39;number&#39; has a clear meaning the &#39;letter&#39; type is more complex.
Definition: NamingConvention.h:104
1, 2, 3, ...
Definition: NamingConvention.h:110
NamingConvention(enum_value value)
Construct a NamingConvention enumeration by an enumeration value.
Definition: NamingConvention.cpp:75
enum_value
Enumeration values.
Definition: NamingConvention.h:76
static const string_map_type & lowercase_strings()
Get a map of valid lowercased string names and enum values.
Definition: NamingConvention.cpp:168
static const string_map_type & strings()
Get a map of valid string names and enum values.
Definition: NamingConvention.cpp:138