byte_array.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_
13 #define ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_
14 
15 /*****************************************************************************
16 ** Includes
17 *****************************************************************************/
18 
20 
21 /*****************************************************************************
22 ** Namespaces
23 *****************************************************************************/
24 
25 namespace ecl {
26 
27 /*****************************************************************************
28 ** From Byte Array
29 *****************************************************************************/
43 void from_byte_array(int32 &value, const char* byte_array) {
44  value = 0;
45  for (unsigned int i = 0; i < 4; ++i ) {
46  value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
47  }
48 }
49 
63 void from_byte_array(int32 &value, const unsigned char* byte_array) {
64  value = 0;
65  for (unsigned int i = 0; i < 4; ++i ) {
66  value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
67  }
68 }
69 
83 void from_byte_array(uint32 &value, const char* byte_array) {
84  value = 0;
85  for (unsigned int i = 0; i < 4; ++i ) {
86  value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
87  }
88 }
89 
103 void from_byte_array(uint32 &value, const unsigned char* byte_array) {
104  value = 0;
105  for (unsigned int i = 0; i < 4; ++i ) {
106  value |= static_cast<unsigned char>(*(byte_array+i)) << 8*i;
107  }
108 }
109 
110 } // namespace ecl
111 
112 #endif /* ECL_CONVERTERS_LITE_BYTE_ARRAY_HPP_ */
portable_types.hpp
ecl::from_byte_array
void from_byte_array(int32 &value, const char *byte_array)
Converts an array of four char into a 32 bit integer.
Definition: byte_array.hpp:49
ecl


ecl_converters_lite
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:13:54