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) {
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 
87  char operator()(const int &input) {
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.
OutOfRangeError
Primary template and general fallback for converter classes.
Definition: converter.hpp:56
char operator()(const int &input)
Definition: char.hpp:87
#define ecl_debug_throw(exception)
char operator()(const unsigned int &input)
Definition: char.hpp:57


ecl_converters
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:34