12 #ifndef ECL_CONVERTERS_CONVERTERS_FROM_BYTE_ARRAY_HPP_ 13 #define ECL_CONVERTERS_CONVERTERS_FROM_BYTE_ARRAY_HPP_ 20 #include <ecl/config/macros.hpp> 21 #include <ecl/concepts/containers.hpp> 22 #include <ecl/errors/compile_time_assert.hpp> 23 #include <ecl/exceptions/standard_exception.hpp> 24 #include <ecl/mpl/converters.hpp> 25 #include <ecl/type_traits/fundamental_types.hpp> 26 #include <ecl/type_traits/numeric_limits.hpp> 55 template<
typename Integral,
typename ByteArray>
56 class ECL_PUBLIC FromByteArray :
public ConverterBase
86 StandardException(
LOC,
ConversionError,
"The byte array is too long for the integral type specified."));
93 for (
unsigned int i = 0; i < byte_array.size(); ++i)
95 unsigned_value |=
static_cast<unsigned char>(byte_array[i]) << 8 * i;
99 Integral value =
static_cast<Integral
>(unsigned_value);
104 return unsigned_value;
110 virtual ~FromByteArray() {}
122 template<
typename Integral>
124 public converters::FromByteArray<Integral, std::vector<char> >
130 template<
typename Integral>
131 class ECL_PUBLIC Converter<Integral, std::vector<unsigned char> > :
public converters::FromByteArray<Integral,
132 std::vector<unsigned char> >
138 template<
typename Integral>
139 class ECL_PUBLIC Converter<Integral, std::vector<signed char> > :
public converters::FromByteArray<Integral,
140 std::vector<signed char> >
Primary template for signed to unsigned type metafunctions.
#define ecl_compile_time_assert(logical_expression)
#define LOC
Stringify the line of code you are at.
Standard exception type, provides code location and error string.
Expands the std numeric_limits class.
static bool const value
The value for this integral constant wrapper.
Array< char, 3 > ByteArray
#define ecl_compile_time_concept_check(Model)
Compile time concept checking assertion.
#define ecl_debug_throw_decl(exception)
Debug mode throw exception declaration.
#define ecl_debug_throw(exception)
Debug mode exception throw.
Default action for detection of a signed integral type (false).