include
ecl
converters
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
"
24
#include <
ecl/exceptions/standard_exception.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 ) {
59
ecl_debug_throw
(
StandardException
(
LOC
,
ConversionError
));
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) ) {
89
ecl_debug_throw
(
StandardException
(
LOC
,
OutOfRangeError
));
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
115
using
Converter<char,int>::operator
();
116
using
Converter<char,unsigned int>::operator
();
117
};
118
119
};
// Namespace ecl
120
121
122
#endif
/*ECL_CONVERTERS_CHAR_HPP_*/
ecl::Converter::operator()
Output operator()(const Input &input)
Definition:
converter.hpp:97
converter.hpp
Primary templates for the family of converter classes.
LOC
#define LOC
ecl::StandardException
ecl::Converter::~Converter
virtual ~Converter()
Definition:
converter.hpp:72
standard_exception.hpp
ecl::ConversionError
ConversionError
ecl::OutOfRangeError
OutOfRangeError
ecl
ecl::Converter
Primary template and general fallback for converter classes.
Definition:
converter.hpp:62
ecl_debug_throw
#define ecl_debug_throw(exception)
ecl_converters
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:25