ReadWriteHelper.hpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
35 #ifndef SICK_SAFETYSCANNERS_DATA_PROCESSING_READWRITEHELPER_HPP
36 #define SICK_SAFETYSCANNERS_DATA_PROCESSING_READWRITEHELPER_HPP
37 
38 #include <stdint.h>
39 
40 namespace sick {
41 namespace read_write_helper {
42 
53 inline void writeUint8(std::vector<uint8_t>::iterator it, const uint8_t v)
54 {
55  *(it + 0) = v;
56 }
57 
65 inline void writeUint8BigEndian(std::vector<uint8_t>::iterator it, const uint8_t v)
66 {
67  writeUint8(it, v);
68 }
69 
77 inline void writeUint8LittleEndian(std::vector<uint8_t>::iterator it, const uint8_t v)
78 {
79  writeUint8(it, v);
80 }
81 
89 inline void writeInt8(std::vector<uint8_t>::iterator it, const uint8_t v)
90 {
91  writeUint8(it, v);
92 }
93 
101 inline void writeInt8BigEndian(std::vector<uint8_t>::iterator it, const uint8_t v)
102 {
103  writeInt8(it, v);
104 }
105 
113 inline void writeInt8LittleEndian(std::vector<uint8_t>::iterator it, const uint8_t v)
114 {
115  writeInt8(it, v);
116 }
117 
125 inline void writeUint16BigEndian(std::vector<uint8_t>::iterator it, const uint16_t v)
126 {
127  *(it + 0) = (v & 0xff00) >> 8;
128  *(it + 1) = v & 0xff;
129 }
130 
138 inline void writeUint16LittleEndian(std::vector<uint8_t>::iterator it, const uint16_t v)
139 {
140  *(it + 0) = v & 0xff;
141  *(it + 1) = (v & 0xff00) >> 8;
142 }
143 
144 
152 inline void writeUint32BigEndian(std::vector<uint8_t>::iterator it, const uint32_t v)
153 {
154  *(it + 0) = (v & 0xff000000) >> 24;
155  *(it + 1) = (v & 0xff0000) >> 16;
156  *(it + 2) = (v & 0xff00) >> 8;
157  *(it + 3) = v & 0xff;
158 }
159 
167 inline void writeUint32LittleEndian(std::vector<uint8_t>::iterator it, const uint32_t v)
168 {
169  *(it + 3) = (v & 0xff000000) >> 24;
170  *(it + 2) = (v & 0xff0000) >> 16;
171  *(it + 1) = (v & 0xff00) >> 8;
172  *(it + 0) = v & 0xff;
173 }
174 
183 inline uint8_t readUint8(std::vector<uint8_t>::const_iterator it)
184 {
185  return *(it + 0);
186 }
187 
196 inline uint8_t readUint8BigEndian(std::vector<uint8_t>::const_iterator it)
197 {
198  return readUint8(it);
199 }
200 
209 inline uint8_t readUint8LittleEndian(std::vector<uint8_t>::const_iterator it)
210 {
211  return readUint8(it);
212 }
213 
222 inline int8_t readInt8(std::vector<uint8_t>::const_iterator it)
223 {
224  return readUint8(it);
225 }
226 
235 inline int8_t readInt8BigEndian(std::vector<uint8_t>::const_iterator it)
236 {
237  return readInt8(it);
238 }
239 
248 inline int8_t readInt8LittleEndian(std::vector<uint8_t>::const_iterator it)
249 {
250  return readInt8(it);
251 }
252 
261 inline uint16_t readUint16BigEndian(std::vector<uint8_t>::const_iterator it)
262 {
263  return (*(it + 0) << 8) + *(it + 1);
264 }
265 
274 inline uint16_t readUint16LittleEndian(std::vector<uint8_t>::const_iterator it)
275 {
276  return (*(it + 1) << 8) + *(it + 0);
277 }
278 
287 inline int16_t readInt16BigEndian(std::vector<uint8_t>::const_iterator it)
288 {
289  return readUint16BigEndian(it);
290 }
291 
300 inline int16_t readInt16LittleEndian(std::vector<uint8_t>::const_iterator it)
301 {
302  return readUint16LittleEndian(it);
303 }
304 
313 inline uint32_t readUint32BigEndian(std::vector<uint8_t>::const_iterator it)
314 {
315  return (*(it + 0) << 24) + (*(it + 1) << 16) + (*(it + 2) << 8) + *(it + 3);
316 }
317 
326 inline uint32_t readUint32LittleEndian(std::vector<uint8_t>::const_iterator it)
327 {
328  return (*(it + 3) << 24) + (*(it + 2) << 16) + (*(it + 1) << 8) + *(it + 0);
329 }
330 
339 inline int32_t readInt32BigEndian(std::vector<uint8_t>::const_iterator it)
340 {
341  return (*(it + 0) << 24) + (*(it + 1) << 16) + (*(it + 2) << 8) + *(it + 3);
342 }
343 
344 
353 inline int32_t readInt32LittleEndian(std::vector<uint8_t>::const_iterator it)
354 {
355  return (*(it + 3) << 24) + (*(it + 2) << 16) + (*(it + 1) << 8) + *(it + 0);
356 }
357 
358 } // namespace read_write_helper
359 } // namespace sick
360 
361 #endif // SICK_SAFETYSCANNERS_DATA_PROCESSING_READWRITEHELPER_HPP
void writeUint32BigEndian(std::vector< uint8_t >::iterator it, const uint32_t v)
Writes an unsigned 32-bit integer to a buffer at offset in big endian encoding.
int8_t readInt8BigEndian(std::vector< uint8_t >::const_iterator it)
Read a signed 8-bit integer at offset in big endian encoding.
void writeUint8BigEndian(std::vector< uint8_t >::iterator it, const uint8_t v)
Writes an unsigned 8-bit integer to a buffer at offset in big endian encoding.
void writeInt8(std::vector< uint8_t >::iterator it, const uint8_t v)
Writes a signed 8-bit integer to a buffer at offset.
uint8_t readUint8BigEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset in big endian encoding.
int8_t readInt8(std::vector< uint8_t >::const_iterator it)
Read a signed 8-bit integer at offset.
int8_t readInt8LittleEndian(std::vector< uint8_t >::const_iterator it)
Read a signed 8-bit integer at offset in little endian encoding.
uint8_t readUint8LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset in big little encoding.
uint32_t readUint32BigEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in big endian encoding.
void writeUint8(std::vector< uint8_t >::iterator it, const uint8_t v)
Helper Functions read and write data at a certain place in a buffer.
uint32_t readUint32LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in little endian encoding.
int32_t readInt32LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in little endian encoding.
void writeInt8BigEndian(std::vector< uint8_t >::iterator it, const uint8_t v)
Writes a signed 8-bit integer to a buffer at offset in big endian encoding.
void writeUint16BigEndian(std::vector< uint8_t >::iterator it, const uint16_t v)
Writes an unsigned 16-bit integer to a buffer at offset in big endian encoding.
int16_t readInt16BigEndian(std::vector< uint8_t >::const_iterator it)
Read a signed 16-bit integer at offset in big endian encoding.
uint16_t readUint16BigEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 16-bit integer at offset in big endian encoding.
void writeUint32LittleEndian(std::vector< uint8_t >::iterator it, const uint32_t v)
Writes an unsigned 32-bit integer to a buffer at offset in little endian encoding.
int32_t readInt32BigEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in big endian encoding.
void writeUint8LittleEndian(std::vector< uint8_t >::iterator it, const uint8_t v)
Writes an unsigned 8-bit integer to a buffer at offset in little endian encoding. ...
void writeInt8LittleEndian(std::vector< uint8_t >::iterator it, const uint8_t v)
Writes a signed 8-bit integer to a buffer at offset in little endian encoding.
void writeUint16LittleEndian(std::vector< uint8_t >::iterator it, const uint16_t v)
Writes an unsigned 16-bit integer to a buffer at offset in little endian encoding.
uint8_t readUint8(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset.
uint16_t readUint16LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 16-bit integer at offset in little endian encoding.
int16_t readInt16LittleEndian(std::vector< uint8_t >::const_iterator it)
Read a signed 16-bit integer at offset in little endian encoding.


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Apr 2 2021 02:45:41