CppCommon  1.0.4.1
C++ Common Library
endian.inl
Go to the documentation of this file.
1 
9 namespace CppCommon {
10 
11 inline bool Endian::IsBigEndian()
12 {
13  return false;
14 }
15 
17 {
18  return true;
19 }
20 
21 inline size_t Endian::ReadBigEndian(const void* buffer, int16_t& value)
22 {
23  if (IsBigEndian())
24  {
25  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
26  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
27  }
28  else
29  {
30  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[1];
31  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[0];
32  }
33 
34  return 2;
35 }
36 
37 inline size_t Endian::ReadBigEndian(const void* buffer, uint16_t& value)
38 {
39  if (IsBigEndian())
40  {
41  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
42  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
43  }
44  else
45  {
46  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[1];
47  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[0];
48  }
49 
50  return 2;
51 }
52 
53 inline size_t Endian::ReadBigEndian(const void* buffer, int32_t& value)
54 {
55  if (IsBigEndian())
56  {
57  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
58  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
59  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
60  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
61  }
62  else
63  {
64  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[3];
65  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[2];
66  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[1];
67  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[0];
68  }
69 
70  return 4;
71 }
72 
73 inline size_t Endian::ReadBigEndian(const void* buffer, uint32_t& value)
74 {
75  if (IsBigEndian())
76  {
77  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
78  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
79  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
80  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
81  }
82  else
83  {
84  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[3];
85  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[2];
86  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[1];
87  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[0];
88  }
89 
90  return 4;
91 }
92 
93 inline size_t Endian::ReadBigEndian(const void* buffer, int64_t& value)
94 {
95  if (IsBigEndian())
96  {
97  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
98  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
99  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
100  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
101  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[4];
102  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[5];
103  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[6];
104  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[7];
105  }
106  else
107  {
108  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[7];
109  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[6];
110  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[5];
111  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[4];
112  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[3];
113  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[2];
114  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[1];
115  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[0];
116  }
117 
118  return 8;
119 }
120 
121 inline size_t Endian::ReadBigEndian(const void* buffer, uint64_t& value)
122 {
123  if (IsBigEndian())
124  {
125  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
126  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
127  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
128  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
129  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[4];
130  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[5];
131  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[6];
132  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[7];
133  }
134  else
135  {
136  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[7];
137  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[6];
138  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[5];
139  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[4];
140  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[3];
141  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[2];
142  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[1];
143  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[0];
144  }
145 
146  return 8;
147 }
148 
149 inline size_t Endian::ReadLittleEndian(const void* buffer, int16_t& value)
150 {
151  if (IsBigEndian())
152  {
153  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[1];
154  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[0];
155  }
156  else
157  {
158  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
159  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
160  }
161 
162  return 2;
163 }
164 
165 inline size_t Endian::ReadLittleEndian(const void* buffer, uint16_t& value)
166 {
167  if (IsBigEndian())
168  {
169  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[1];
170  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[0];
171  }
172  else
173  {
174  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
175  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
176  }
177 
178  return 2;
179 }
180 
181 inline size_t Endian::ReadLittleEndian(const void* buffer, int32_t& value)
182 {
183  if (IsBigEndian())
184  {
185  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[3];
186  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[2];
187  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[1];
188  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[0];
189  }
190  else
191  {
192  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
193  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
194  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
195  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
196  }
197 
198  return 4;
199 }
200 
201 inline size_t Endian::ReadLittleEndian(const void* buffer, uint32_t& value)
202 {
203  if (IsBigEndian())
204  {
205  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[3];
206  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[2];
207  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[1];
208  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[0];
209  }
210  else
211  {
212  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
213  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
214  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
215  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
216  }
217 
218  return 4;
219 }
220 
221 inline size_t Endian::ReadLittleEndian(const void* buffer, int64_t& value)
222 {
223  if (IsBigEndian())
224  {
225  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[7];
226  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[6];
227  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[5];
228  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[4];
229  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[3];
230  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[2];
231  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[1];
232  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[0];
233  }
234  else
235  {
236  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
237  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
238  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
239  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
240  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[4];
241  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[5];
242  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[6];
243  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[7];
244  }
245 
246  return 8;
247 }
248 
249 inline size_t Endian::ReadLittleEndian(const void* buffer, uint64_t& value)
250 {
251  if (IsBigEndian())
252  {
253  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[7];
254  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[6];
255  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[5];
256  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[4];
257  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[3];
258  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[2];
259  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[1];
260  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[0];
261  }
262  else
263  {
264  ((uint8_t*)&value)[0] = ((const uint8_t*)buffer)[0];
265  ((uint8_t*)&value)[1] = ((const uint8_t*)buffer)[1];
266  ((uint8_t*)&value)[2] = ((const uint8_t*)buffer)[2];
267  ((uint8_t*)&value)[3] = ((const uint8_t*)buffer)[3];
268  ((uint8_t*)&value)[4] = ((const uint8_t*)buffer)[4];
269  ((uint8_t*)&value)[5] = ((const uint8_t*)buffer)[5];
270  ((uint8_t*)&value)[6] = ((const uint8_t*)buffer)[6];
271  ((uint8_t*)&value)[7] = ((const uint8_t*)buffer)[7];
272  }
273 
274  return 8;
275 }
276 
277 inline size_t Endian::WriteBigEndian(void* buffer, int16_t value)
278 {
279  if (IsBigEndian())
280  {
281  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
282  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
283  }
284  else
285  {
286  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[1];
287  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[0];
288  }
289 
290  return 2;
291 }
292 
293 inline size_t Endian::WriteBigEndian(void* buffer, uint16_t value)
294 {
295  if (IsBigEndian())
296  {
297  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
298  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
299  }
300  else
301  {
302  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[1];
303  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[0];
304  }
305 
306  return 2;
307 }
308 
309 inline size_t Endian::WriteBigEndian(void* buffer, int32_t value)
310 {
311  if (IsBigEndian())
312  {
313  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
314  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
315  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
316  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
317  }
318  else
319  {
320  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[3];
321  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[2];
322  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[1];
323  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[0];
324  }
325 
326  return 4;
327 }
328 
329 inline size_t Endian::WriteBigEndian(void* buffer, uint32_t value)
330 {
331  if (IsBigEndian())
332  {
333  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
334  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
335  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
336  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
337  }
338  else
339  {
340  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[3];
341  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[2];
342  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[1];
343  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[0];
344  }
345 
346  return 4;
347 }
348 
349 inline size_t Endian::WriteBigEndian(void* buffer, int64_t value)
350 {
351  if (IsBigEndian())
352  {
353  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
354  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
355  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
356  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
357  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[4];
358  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[5];
359  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[6];
360  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[7];
361  }
362  else
363  {
364  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[7];
365  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[6];
366  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[5];
367  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[4];
368  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[3];
369  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[2];
370  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[1];
371  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[0];
372  }
373 
374  return 8;
375 }
376 
377 inline size_t Endian::WriteBigEndian(void* buffer, uint64_t value)
378 {
379  if (IsBigEndian())
380  {
381  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
382  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
383  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
384  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
385  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[4];
386  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[5];
387  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[6];
388  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[7];
389  }
390  else
391  {
392  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[7];
393  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[6];
394  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[5];
395  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[4];
396  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[3];
397  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[2];
398  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[1];
399  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[0];
400  }
401 
402  return 8;
403 }
404 
405 inline size_t Endian::WriteLittleEndian(void* buffer, int16_t value)
406 {
407  if (IsBigEndian())
408  {
409  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[1];
410  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[0];
411  }
412  else
413  {
414  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
415  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
416  }
417 
418  return 2;
419 }
420 
421 inline size_t Endian::WriteLittleEndian(void* buffer, uint16_t value)
422 {
423  if (IsBigEndian())
424  {
425  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[1];
426  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[0];
427  }
428  else
429  {
430  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
431  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
432  }
433 
434  return 2;
435 }
436 
437 inline size_t Endian::WriteLittleEndian(void* buffer, int32_t value)
438 {
439  if (IsBigEndian())
440  {
441  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[3];
442  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[2];
443  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[1];
444  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[0];
445  }
446  else
447  {
448  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
449  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
450  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
451  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
452  }
453 
454  return 4;
455 }
456 
457 inline size_t Endian::WriteLittleEndian(void* buffer, uint32_t value)
458 {
459  if (IsBigEndian())
460  {
461  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[3];
462  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[2];
463  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[1];
464  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[0];
465  }
466  else
467  {
468  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
469  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
470  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
471  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
472  }
473 
474  return 4;
475 }
476 
477 inline size_t Endian::WriteLittleEndian(void* buffer, int64_t value)
478 {
479  if (IsBigEndian())
480  {
481  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[7];
482  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[6];
483  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[5];
484  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[4];
485  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[3];
486  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[2];
487  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[1];
488  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[0];
489  }
490  else
491  {
492  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
493  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
494  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
495  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
496  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[4];
497  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[5];
498  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[6];
499  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[7];
500  }
501 
502  return 8;
503 }
504 
505 inline size_t Endian::WriteLittleEndian(void* buffer, uint64_t value)
506 {
507  if (IsBigEndian())
508  {
509  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[7];
510  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[6];
511  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[5];
512  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[4];
513  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[3];
514  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[2];
515  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[1];
516  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[0];
517  }
518  else
519  {
520  ((uint8_t*)buffer)[0] = ((const uint8_t*)&value)[0];
521  ((uint8_t*)buffer)[1] = ((const uint8_t*)&value)[1];
522  ((uint8_t*)buffer)[2] = ((const uint8_t*)&value)[2];
523  ((uint8_t*)buffer)[3] = ((const uint8_t*)&value)[3];
524  ((uint8_t*)buffer)[4] = ((const uint8_t*)&value)[4];
525  ((uint8_t*)buffer)[5] = ((const uint8_t*)&value)[5];
526  ((uint8_t*)buffer)[6] = ((const uint8_t*)&value)[6];
527  ((uint8_t*)buffer)[7] = ((const uint8_t*)&value)[7];
528  }
529 
530  return 8;
531 }
532 
533 } // namespace CppCommon
static size_t ReadLittleEndian(const void *buffer, int16_t &value)
Read little-endian signed 16-bit integer value from the given buffer.
Definition: endian.inl:149
static size_t WriteBigEndian(void *buffer, int16_t value)
Write big-endian signed 16-bit integer value into the given buffer.
Definition: endian.inl:277
static bool IsLittleEndian()
Is little-endian system?
Definition: endian.inl:16
static size_t ReadBigEndian(const void *buffer, int16_t &value)
Read big-endian signed 16-bit integer value from the given buffer.
Definition: endian.inl:21
static size_t WriteLittleEndian(void *buffer, int16_t value)
Write little-endian signed 16-bit integer value into the given buffer.
Definition: endian.inl:405
static bool IsBigEndian()
Is big-endian system?
Definition: endian.inl:11
C++ Common project definitions.
Definition: token_bucket.h:15