char.hpp
Go to the documentation of this file.
1 
12 /*****************************************************************************
13 ** Ifdefs
14 *****************************************************************************/
15 
16 #ifndef ECL_CONVERTERS_CHAR_HPP_
17 #define ECL_CONVERTERS_CHAR_HPP_
18 
19 /*****************************************************************************
20 ** Includes
21 *****************************************************************************/
22 
23 #include "converter.hpp"
25 
26 /*****************************************************************************
27 ** Namespaces
28 *****************************************************************************/
29 
30 namespace ecl {
31 
32 /*****************************************************************************
33 ** Character Converter Interface
34 *****************************************************************************/
40 template <>
41 class Converter<char,unsigned int> : public converters::ConverterBase {
42 public:
43  virtual ~Converter() {}
44 
57  char operator()(const unsigned int &input) ecl_debug_throw_decl(StandardException) {
58  if ( input > 9 ) {
60  error_handler = ConversionError;
61  }
62  return ('0'+ input%10); // Copy the char back.
63  }
64 };
70 template <>
71 class Converter<char,int> : public converters::ConverterBase {
72 public:
73  virtual ~Converter() {}
74 
88  if ( ( input < 0 ) || (input > 9) ) {
90  error_handler = OutOfRangeError;
91  }
92  return ('0'+ input%10); // Copy the char back.
93  }
94 };
95 
96 /*****************************************************************************
97  * Char Converter Family
98  ****************************************************************************/
107 template <>
108 class Converter<char,void> :
109  public Converter<char,int>,
110  public Converter<char,unsigned int>
111 {
112  public:
113  virtual ~Converter() {}
114 
117 };
118 
119 }; // Namespace ecl
120 
121 
122 #endif /*ECL_CONVERTERS_CHAR_HPP_*/
#define LOC
ConversionError
Primary templates for the family of converter classes.
char operator()(const int &input) ecl_debug_throw_decl(StandardException)
Definition: char.hpp:87
OutOfRangeError
Primary template and general fallback for converter classes.
Definition: converter.hpp:56
char operator()(const unsigned int &input) ecl_debug_throw_decl(StandardException)
Definition: char.hpp:57
#define ecl_debug_throw_decl(exception)
#define ecl_debug_throw(exception)


ecl_converters
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:21