char.hpp
Go to the documentation of this file.
00001 
00012 /*****************************************************************************
00013 ** Ifdefs
00014 *****************************************************************************/
00015 
00016 #ifndef ECL_CONVERTERS_CHAR_HPP_
00017 #define ECL_CONVERTERS_CHAR_HPP_
00018 
00019 /*****************************************************************************
00020 ** Includes
00021 *****************************************************************************/
00022 
00023 #include "converter.hpp"
00024 #include <ecl/exceptions/standard_exception.hpp>
00025 
00026 /*****************************************************************************
00027 ** Namespaces
00028 *****************************************************************************/
00029 
00030 namespace ecl {
00031 
00032 /*****************************************************************************
00033 ** Character Converter Interface
00034 *****************************************************************************/
00040 template <>
00041 class Converter<char,unsigned int> : public converters::ConverterBase {
00042 public:
00043         virtual ~Converter() {}
00044 
00057         char operator()(const unsigned int &input) ecl_debug_throw_decl(StandardException) {
00058                 if ( input > 9 ) {
00059                         ecl_debug_throw(StandardException(LOC,ConversionError));
00060                         error_handler = ConversionError;
00061                 }
00062                 return ('0'+ input%10);    // Copy the char back.
00063         }
00064 };
00070 template <>
00071 class Converter<char,int> : public converters::ConverterBase {
00072 public:
00073         virtual ~Converter() {}
00074 
00087         char operator()(const int &input) ecl_debug_throw_decl(StandardException) {
00088                 if ( ( input < 0 ) || (input > 9) ) {
00089                         ecl_debug_throw(StandardException(LOC,OutOfRangeError));
00090                         error_handler = OutOfRangeError;
00091                 }
00092                 return ('0'+ input%10);    // Copy the char back.
00093         }
00094 };
00095 
00096 /*****************************************************************************
00097  * Char Converter Family
00098  ****************************************************************************/
00107 template <>
00108 class Converter<char,void>  :
00109     public Converter<char,int>,
00110     public Converter<char,unsigned int>
00111 {
00112     public:
00113         virtual ~Converter() {}
00114 
00115         using Converter<char,int>::operator();
00116         using Converter<char,unsigned int>::operator();
00117 };
00118 
00119 }; // Namespace ecl
00120 
00121 
00122 #endif /*ECL_CONVERTERS_CHAR_HPP_*/


ecl_converters
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:10