Program Listing for File byte_array.hpp
↰ Return to documentation for file (include/ecl/converters_lite/byte_array.hpp
)
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_
#define ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_
/*****************************************************************************
** Includes
*****************************************************************************/
#include <ecl/config/portable_types.hpp>
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace ecl {
/*****************************************************************************
** From Byte Array
*****************************************************************************/
void from_byte_array(int32 &value, const signed char* byte_array) {
value = 0;
for (unsigned int i = 0; i < 4; ++i ) {
value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
}
}
void from_byte_array(int32 &value, const char* byte_array) {
value = 0;
for (unsigned int i = 0; i < 4; ++i ) {
value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
}
}
void from_byte_array(int32 &value, const unsigned char* byte_array) {
value = 0;
for (unsigned int i = 0; i < 4; ++i ) {
value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
}
}
void from_byte_array(uint32 &value, const signed char* byte_array) {
value = 0;
for (unsigned int i = 0; i < 4; ++i ) {
value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
}
}
void from_byte_array(uint32 &value, const char* byte_array) {
value = 0;
for (unsigned int i = 0; i < 4; ++i ) {
value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
}
}
void from_byte_array(uint32 &value, const unsigned char* byte_array) {
value = 0;
for (unsigned int i = 0; i < 4; ++i ) {
value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
}
}
} // namespace ecl
#endif /* ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_ */