byte_array.hpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Ifdefs
00010 *****************************************************************************/
00011 
00012 #ifndef ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_
00013 #define ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_
00014 
00015 /*****************************************************************************
00016 ** Includes
00017 *****************************************************************************/
00018 
00019 #include <ecl/config/portable_types.hpp>
00020 
00021 /*****************************************************************************
00022 ** Namespaces
00023 *****************************************************************************/
00024 
00025 namespace ecl {
00026 
00027 /*****************************************************************************
00028 ** From Byte Array
00029 *****************************************************************************/
00043 void from_byte_array(int32 &value, const char* byte_array) {
00044         value = 0;
00045         for (unsigned int i = 0; i < 4; ++i ) {
00046                 value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
00047         }
00048 }
00049 
00063 void from_byte_array(int32 &value, const unsigned char* byte_array) {
00064         value = 0;
00065         for (unsigned int i = 0; i < 4; ++i ) {
00066                 value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
00067         }
00068 }
00069 
00083 void from_byte_array(uint32 &value, const char* byte_array) {
00084         value = 0;
00085         for (unsigned int i = 0; i < 4; ++i ) {
00086                 value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
00087         }
00088 }
00089 
00103 void from_byte_array(uint32 &value, const unsigned char* byte_array) {
00104         value = 0;
00105         for (unsigned int i = 0; i < 4; ++i ) {
00106                 value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
00107         }
00108 }
00109 
00110 } // namespace ecl
00111 
00112 #endif /* ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_ */


ecl_converters_lite
Author(s): Daniel Stonier
autogenerated on Thu Jun 6 2019 18:53:22