sbgECom Library  5.2.590-stable
Interface SBG Systems IMU/AHRS/INS
Loading...
Searching...
No Matches
sbgStreamBufferBE.h
Go to the documentation of this file.
1
32
33#ifndef SBG_STREAM_BUFFER_BE_H
34#define SBG_STREAM_BUFFER_BE_H
35
37
38//----------------------------------------------------------------------//
39//- Read operations methods -//
40//----------------------------------------------------------------------//
41
49{
50 int16_t bytesValues[2];
51
52 assert(pHandle);
53
54 //
55 // Test if we haven't already an error
56 //
57 if (pHandle->errorCode == SBG_NO_ERROR)
58 {
59 //
60 // Test if we can access this item
61 //
62 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(int16_t))
63 {
64 //
65 // Test if the platform supports un-aligned access and if the endianness is the same
66 //
67 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
68 //
69 // Read the current value
70 //
71 bytesValues[0] = *((int16_t*)pHandle->pCurrentPtr);
72
73 //
74 // Increment the current pointer
75 //
76 pHandle->pCurrentPtr += sizeof(int16_t);
77
78 return bytesValues[0];
79 #else
80 //
81 // Read the each bytes
82 //
83 bytesValues[1] = *(pHandle->pCurrentPtr++);
84 bytesValues[0] = *(pHandle->pCurrentPtr++);
85
86 //
87 // Store data according to platform endianness
88 //
89 #if (SBG_CONFIG_BIG_ENDIAN == 1)
90 return bytesValues[1] | (bytesValues[0] << 8);
91 #else
92 return bytesValues[0] | (bytesValues[1] << 8);
93 #endif
94 #endif
95 }
96 else
97 {
98 //
99 // We have a buffer overflow so return 0
100 //
102 }
103 }
104
105 //
106 // If we are here, it means we have an error so return 0
107 //
108 return 0;
109}
110
118{
119 uint16_t bytesValues[2];
120
121 assert(pHandle);
122
123 //
124 // Test if we haven't already an error
125 //
126 if (pHandle->errorCode == SBG_NO_ERROR)
127 {
128 //
129 // Test if we can access this item
130 //
131 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(uint16_t))
132 {
133 //
134 // Test if the platform supports un-aligned access and if the endianness is the same
135 //
136 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
137 //
138 // Read the current value
139 //
140 bytesValues[0] = *((uint16_t*)pHandle->pCurrentPtr);
141
142 //
143 // Increment the current pointer
144 //
145 pHandle->pCurrentPtr += sizeof(uint16_t);
146
147 return bytesValues[0];
148 #else
149 //
150 // Read the each bytes
151 //
152 bytesValues[1] = *(pHandle->pCurrentPtr++);
153 bytesValues[0] = *(pHandle->pCurrentPtr++);
154
155 //
156 // Store data according to platform endianness
157 //
158 #if (SBG_CONFIG_BIG_ENDIAN == 1)
159 return bytesValues[1] | (bytesValues[0] << 8);
160 #else
161 return bytesValues[0] | (bytesValues[1] << 8);
162 #endif
163 #endif
164 }
165 else
166 {
167 //
168 // We have a buffer overflow so return 0
169 //
171 }
172 }
173
174 //
175 // If we are here, it means we have an error so return 0
176 //
177 return 0;
178}
179
187{
188 SbgUint8ToInt32 value;
189
190 assert(pHandle);
191
192 //
193 // Test if we haven't already an error
194 //
195 if (pHandle->errorCode == SBG_NO_ERROR)
196 {
197 //
198 // Test if we can access this item
199 //
200 if (sbgStreamBufferGetSpace(pHandle) >= 3*sizeof(uint8_t))
201 {
202 //
203 // Make sure the value is zero init
204 //
205 value.value = 0;
206
207 //
208 // Store data according to platform endianness
209 //
210 #if (SBG_CONFIG_BIG_ENDIAN == 1)
211 //
212 // Read the each bytes
213 //
214 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
215 value.buffer[1] = *(pHandle->pCurrentPtr++);
216 value.buffer[2] = *(pHandle->pCurrentPtr++); // LSB
217 #else
218 //
219 // Read the each bytes
220 //
221 value.buffer[3] = *(pHandle->pCurrentPtr++); // MSB
222 value.buffer[2] = *(pHandle->pCurrentPtr++);
223 value.buffer[1] = *(pHandle->pCurrentPtr++); // LSB
224 #endif
225
226 //
227 // Shift the value to handle the sign correctly for a 24 bits
228 //
229 return value.value >> (32-24);
230 }
231 else
232 {
233 //
234 // We have a buffer overflow so return 0
235 //
237 }
238 }
239
240 //
241 // If we are here, it means we have an error so return 0
242 //
243 return 0;
244}
245
253{
254 SbgUint8ToUint32 value;
255
256 assert(pHandle);
257
258 //
259 // Test if we haven't already an error
260 //
261 if (pHandle->errorCode == SBG_NO_ERROR)
262 {
263 //
264 // Test if we can access this item
265 //
266 if (sbgStreamBufferGetSpace(pHandle) >= 3*sizeof(uint8_t))
267 {
268 //
269 // Make sure the value is zero init
270 //
271 value.value = 0;
272
273 //
274 // Store data according to platform endianness
275 //
276 #if (SBG_CONFIG_BIG_ENDIAN == 1)
277 //
278 // Read the each bytes
279 //
280 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
281 value.buffer[1] = *(pHandle->pCurrentPtr++);
282 value.buffer[2] = *(pHandle->pCurrentPtr++); // LSB
283 #else
284 //
285 // Read the each bytes
286 //
287 value.buffer[3] = *(pHandle->pCurrentPtr++); // MSB
288 value.buffer[2] = *(pHandle->pCurrentPtr++);
289 value.buffer[1] = *(pHandle->pCurrentPtr++); // LSB
290 #endif
291
292 //
293 // Shift the value to handle the sign correctly for a 24 bits
294 //
295 return value.value >> (32-24);
296 }
297 else
298 {
299 //
300 // We have a buffer overflow so return 0
301 //
303 }
304 }
305
306 //
307 // If we are here, it means we have an error so return 0
308 //
309 return 0;
310}
311
319{
320 int32_t bytesValues[4];
321
322 assert(pHandle);
323
324 //
325 // Test if we haven't already an error
326 //
327 if (pHandle->errorCode == SBG_NO_ERROR)
328 {
329 //
330 // Test if we can access this item
331 //
332 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(int32_t))
333 {
334 //
335 // Test if the platform supports un-aligned access and if the endianness is the same
336 //
337 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
338 //
339 // Read the current value
340 //
341 bytesValues[0] = *((int32_t*)pHandle->pCurrentPtr);
342
343 //
344 // Increment the current pointer
345 //
346 pHandle->pCurrentPtr += sizeof(int32_t);
347
348 return bytesValues[0];
349 #else
350 //
351 // Read the each bytes
352 //
353 bytesValues[3] = *(pHandle->pCurrentPtr++);
354 bytesValues[2] = *(pHandle->pCurrentPtr++);
355 bytesValues[1] = *(pHandle->pCurrentPtr++);
356 bytesValues[0] = *(pHandle->pCurrentPtr++);
357
358 //
359 // Store data according to platform endianness
360 //
361 #if (SBG_CONFIG_BIG_ENDIAN == 1)
362 return bytesValues[3] | (bytesValues[2] << 8) | (bytesValues[1] << 16) | (bytesValues[0] << 24);
363 #else
364 return bytesValues[0] | (bytesValues[1] << 8) | (bytesValues[2] << 16) | (bytesValues[3] << 24);
365 #endif
366 #endif
367 }
368 else
369 {
370 //
371 // We have a buffer overflow so return 0
372 //
374 }
375 }
376
377 //
378 // If we are here, it means we have an error so return 0
379 //
380 return 0;
381}
382
390{
391 uint32_t bytesValues[4];
392
393 assert(pHandle);
394
395 //
396 // Test if we haven't already an error
397 //
398 if (pHandle->errorCode == SBG_NO_ERROR)
399 {
400 //
401 // Test if we can access this item
402 //
403 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(uint32_t))
404 {
405 //
406 // Test if the platform supports un-aligned access and if the endianness is the same
407 //
408 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
409 //
410 // Read the current value
411 //
412 bytesValues[0] = *((uint32_t*)pHandle->pCurrentPtr);
413
414 //
415 // Increment the current pointer
416 //
417 pHandle->pCurrentPtr += sizeof(uint32_t);
418
419 return bytesValues[0];
420 #else
421 //
422 // Read the each bytes
423 //
424 bytesValues[3] = *(pHandle->pCurrentPtr++);
425 bytesValues[2] = *(pHandle->pCurrentPtr++);
426 bytesValues[1] = *(pHandle->pCurrentPtr++);
427 bytesValues[0] = *(pHandle->pCurrentPtr++);
428
429 //
430 // Store data according to platform endianness
431 //
432 #if (SBG_CONFIG_BIG_ENDIAN == 1)
433 return bytesValues[3] | (bytesValues[2] << 8) | (bytesValues[1] << 16) | (bytesValues[0] << 24);
434 #else
435 return bytesValues[0] | (bytesValues[1] << 8) | (bytesValues[2] << 16) | (bytesValues[3] << 24);
436 #endif
437 #endif
438 }
439 else
440 {
441 //
442 // We have a buffer overflow so return 0
443 //
445 }
446 }
447
448 //
449 // If we are here, it means we have an error so return 0
450 //
451 return 0;
452}
453
461{
462 SbgUint8ToInt64 value;
463
464 assert(pHandle);
465
466 //
467 // Test if we haven't already an error
468 //
469 if (pHandle->errorCode == SBG_NO_ERROR)
470 {
471 //
472 // Test if we can access this item
473 //
474 if (sbgStreamBufferGetSpace(pHandle) >= 5*sizeof(uint8_t))
475 {
476 //
477 // Make sure the value is zero init
478 //
479 value.value = 0;
480
481 //
482 // Store data according to platform endianness
483 //
484 #if (SBG_CONFIG_BIG_ENDIAN == 1)
485 //
486 // Read the each bytes
487 //
488 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
489 value.buffer[1] = *(pHandle->pCurrentPtr++);
490 value.buffer[2] = *(pHandle->pCurrentPtr++);
491 value.buffer[3] = *(pHandle->pCurrentPtr++);
492 value.buffer[4] = *(pHandle->pCurrentPtr++); // LSB
493 #else
494 //
495 // Read the each bytes
496 //
497 value.buffer[7] = *(pHandle->pCurrentPtr++); // MSB
498 value.buffer[6] = *(pHandle->pCurrentPtr++);
499 value.buffer[5] = *(pHandle->pCurrentPtr++);
500 value.buffer[4] = *(pHandle->pCurrentPtr++);
501 value.buffer[3] = *(pHandle->pCurrentPtr++); // LSB
502 #endif
503
504 //
505 // Shift the value to handle the sign correctly for a 40 bits
506 //
507 return value.value >> (64-40);
508 }
509 else
510 {
511 //
512 // We have a buffer overflow so return 0
513 //
515 }
516 }
517
518 //
519 // If we are here, it means we have an error so return 0
520 //
521 return 0;
522}
523
531{
532 SbgUint8ToUint64 value;
533
534 assert(pHandle);
535
536 //
537 // Test if we haven't already an error
538 //
539 if (pHandle->errorCode == SBG_NO_ERROR)
540 {
541 //
542 // Test if we can access this item
543 //
544 if (sbgStreamBufferGetSpace(pHandle) >= 5*sizeof(uint8_t))
545 {
546 //
547 // Make sure the value is zero init
548 //
549 value.value = 0;
550
551 //
552 // Store data according to platform endianness
553 //
554 #if (SBG_CONFIG_BIG_ENDIAN == 1)
555 //
556 // Read the each bytes
557 //
558 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
559 value.buffer[1] = *(pHandle->pCurrentPtr++);
560 value.buffer[2] = *(pHandle->pCurrentPtr++);
561 value.buffer[3] = *(pHandle->pCurrentPtr++);
562 value.buffer[4] = *(pHandle->pCurrentPtr++); // LSB
563 #else
564 //
565 // Read the each bytes
566 //
567 value.buffer[7] = *(pHandle->pCurrentPtr++); // MSB
568 value.buffer[6] = *(pHandle->pCurrentPtr++);
569 value.buffer[5] = *(pHandle->pCurrentPtr++);
570 value.buffer[4] = *(pHandle->pCurrentPtr++);
571 value.buffer[3] = *(pHandle->pCurrentPtr++); // LSB
572 #endif
573
574 //
575 // Shift the value to handle the sign correctly for a 40 bits
576 //
577 return value.value >> (64-40);
578 }
579 else
580 {
581 //
582 // We have a buffer overflow so return 0
583 //
585 }
586 }
587
588 //
589 // If we are here, it means we have an error so return 0
590 //
591 return 0;
592}
593
601{
602 SbgUint8ToInt64 value;
603
604 assert(pHandle);
605
606 //
607 // Test if we haven't already an error
608 //
609 if (pHandle->errorCode == SBG_NO_ERROR)
610 {
611 //
612 // Test if we can access this item
613 //
614 if (sbgStreamBufferGetSpace(pHandle) >= 6*sizeof(uint8_t))
615 {
616 //
617 // Make sure the value is zero init
618 //
619 value.value = 0;
620
621 //
622 // Store data according to platform endianness
623 //
624 #if (SBG_CONFIG_BIG_ENDIAN == 1)
625 //
626 // Read the each bytes
627 //
628 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
629 value.buffer[1] = *(pHandle->pCurrentPtr++);
630 value.buffer[2] = *(pHandle->pCurrentPtr++);
631 value.buffer[3] = *(pHandle->pCurrentPtr++);
632 value.buffer[4] = *(pHandle->pCurrentPtr++);
633 value.buffer[5] = *(pHandle->pCurrentPtr++); // LSB
634 #else
635 //
636 // Read the each bytes
637 //
638 value.buffer[7] = *(pHandle->pCurrentPtr++); // MSB
639 value.buffer[6] = *(pHandle->pCurrentPtr++);
640 value.buffer[5] = *(pHandle->pCurrentPtr++);
641 value.buffer[4] = *(pHandle->pCurrentPtr++);
642 value.buffer[3] = *(pHandle->pCurrentPtr++);
643 value.buffer[2] = *(pHandle->pCurrentPtr++); // LSB
644 #endif
645
646 //
647 // Shift the value to handle the sign correctly for a 48 bits
648 //
649 return value.value >> (64-48);
650 }
651 else
652 {
653 //
654 // We have a buffer overflow so return 0
655 //
657 }
658 }
659
660 //
661 // If we are here, it means we have an error so return 0
662 //
663 return 0;
664}
665
673{
674 SbgUint8ToUint64 value;
675
676 assert(pHandle);
677
678 //
679 // Test if we haven't already an error
680 //
681 if (pHandle->errorCode == SBG_NO_ERROR)
682 {
683 //
684 // Test if we can access this item
685 //
686 if (sbgStreamBufferGetSpace(pHandle) >= 6*sizeof(uint8_t))
687 {
688 //
689 // Make sure the value is zero init
690 //
691 value.value = 0;
692
693 //
694 // Store data according to platform endianness
695 //
696 #if (SBG_CONFIG_BIG_ENDIAN == 1)
697 //
698 // Read the each bytes
699 //
700 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
701 value.buffer[1] = *(pHandle->pCurrentPtr++);
702 value.buffer[2] = *(pHandle->pCurrentPtr++);
703 value.buffer[3] = *(pHandle->pCurrentPtr++);
704 value.buffer[4] = *(pHandle->pCurrentPtr++);
705 value.buffer[5] = *(pHandle->pCurrentPtr++); // LSB
706 #else
707 //
708 // Read the each bytes
709 //
710 value.buffer[7] = *(pHandle->pCurrentPtr++); // MSB
711 value.buffer[6] = *(pHandle->pCurrentPtr++);
712 value.buffer[5] = *(pHandle->pCurrentPtr++);
713 value.buffer[4] = *(pHandle->pCurrentPtr++);
714 value.buffer[3] = *(pHandle->pCurrentPtr++);
715 value.buffer[2] = *(pHandle->pCurrentPtr++); // LSB
716 #endif
717
718 //
719 // Shift the value to handle the sign correctly for a 48 bits
720 //
721 return value.value >> (64-48);
722 }
723 else
724 {
725 //
726 // We have a buffer overflow so return 0
727 //
729 }
730 }
731
732 //
733 // If we are here, it means we have an error so return 0
734 //
735 return 0;
736}
737
745{
746 SbgUint8ToInt64 value;
747
748 assert(pHandle);
749
750 //
751 // Test if we haven't already an error
752 //
753 if (pHandle->errorCode == SBG_NO_ERROR)
754 {
755 //
756 // Test if we can access this item
757 //
758 if (sbgStreamBufferGetSpace(pHandle) >= 7*sizeof(uint8_t))
759 {
760 //
761 // Make sure the value is zero init
762 //
763 value.value = 0;
764
765 //
766 // Store data according to platform endianness
767 //
768 #if (SBG_CONFIG_BIG_ENDIAN == 1)
769 //
770 // Read the each bytes
771 //
772 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
773 value.buffer[1] = *(pHandle->pCurrentPtr++);
774 value.buffer[2] = *(pHandle->pCurrentPtr++);
775 value.buffer[3] = *(pHandle->pCurrentPtr++);
776 value.buffer[4] = *(pHandle->pCurrentPtr++);
777 value.buffer[5] = *(pHandle->pCurrentPtr++);
778 value.buffer[6] = *(pHandle->pCurrentPtr++); // LSB
779 #else
780 //
781 // Read the each bytes
782 //
783 value.buffer[7] = *(pHandle->pCurrentPtr++); // MSB
784 value.buffer[6] = *(pHandle->pCurrentPtr++);
785 value.buffer[5] = *(pHandle->pCurrentPtr++);
786 value.buffer[4] = *(pHandle->pCurrentPtr++);
787 value.buffer[3] = *(pHandle->pCurrentPtr++);
788 value.buffer[2] = *(pHandle->pCurrentPtr++);
789 value.buffer[1] = *(pHandle->pCurrentPtr++); // LSB
790 #endif
791
792 //
793 // Shift the value to handle the sign correctly for a 56 bits
794 //
795 return value.value >> (64-56);
796 }
797 else
798 {
799 //
800 // We have a buffer overflow so return 0
801 //
803 }
804 }
805
806 //
807 // If we are here, it means we have an error so return 0
808 //
809 return 0;
810}
811
819{
820 SbgUint8ToUint64 value;
821
822 assert(pHandle);
823
824 //
825 // Test if we haven't already an error
826 //
827 if (pHandle->errorCode == SBG_NO_ERROR)
828 {
829 //
830 // Test if we can access this item
831 //
832 if (sbgStreamBufferGetSpace(pHandle) >= 7*sizeof(uint8_t))
833 {
834 //
835 // Make sure the value is zero init
836 //
837 value.value = 0;
838
839 //
840 // Store data according to platform endianness
841 //
842 #if (SBG_CONFIG_BIG_ENDIAN == 1)
843 //
844 // Read the each bytes
845 //
846 value.buffer[0] = *(pHandle->pCurrentPtr++); // MSB
847 value.buffer[1] = *(pHandle->pCurrentPtr++);
848 value.buffer[2] = *(pHandle->pCurrentPtr++);
849 value.buffer[3] = *(pHandle->pCurrentPtr++);
850 value.buffer[4] = *(pHandle->pCurrentPtr++);
851 value.buffer[5] = *(pHandle->pCurrentPtr++);
852 value.buffer[6] = *(pHandle->pCurrentPtr++); // LSB
853 #else
854 //
855 // Read the each bytes
856 //
857 value.buffer[7] = *(pHandle->pCurrentPtr++); // MSB
858 value.buffer[6] = *(pHandle->pCurrentPtr++);
859 value.buffer[5] = *(pHandle->pCurrentPtr++);
860 value.buffer[4] = *(pHandle->pCurrentPtr++);
861 value.buffer[3] = *(pHandle->pCurrentPtr++);
862 value.buffer[2] = *(pHandle->pCurrentPtr++);
863 value.buffer[1] = *(pHandle->pCurrentPtr++); // LSB
864 #endif
865
866 //
867 // Shift the value to handle the sign correctly for a 56 bits
868 //
869 return value.value >> (64-56);
870 }
871 else
872 {
873 //
874 // We have a buffer overflow so return 0
875 //
877 }
878 }
879
880 //
881 // If we are here, it means we have an error so return 0
882 //
883 return 0;
884}
885
893{
894 int64_t lowPart;
895 int64_t highPart;
896
897 assert(pHandle);
898
899 //
900 // Test if we haven't already an error
901 //
902 if (pHandle->errorCode == SBG_NO_ERROR)
903 {
904 //
905 // Test if we can access this item
906 //
907 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(int64_t))
908 {
909 //
910 // Test if the platform supports un-aligned access and if the endianness is the same
911 //
912 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
913 //
914 // Read the current value
915 //
916 lowPart = *((int64_t*)pHandle->pCurrentPtr);
917
918 //
919 // Increment the current pointer
920 //
921 pHandle->pCurrentPtr += sizeof(int64_t);
922
923 return lowPart;
924 #else
925 //
926 // Read 64 bit value using two 32 bits read to avoid too much 64 bits operations
927 //
928 highPart = sbgStreamBufferReadUint32BE(pHandle);
929 lowPart = sbgStreamBufferReadUint32BE(pHandle);
930
931 //
932 // Store data according to platform endianness
933 //
934 #if (SBG_CONFIG_BIG_ENDIAN == 1)
935 return (lowPart << 32) | highPart;
936 #else
937 return lowPart | (highPart << 32);
938 #endif
939 #endif
940 }
941 else
942 {
943 //
944 // We have a buffer overflow so return 0
945 //
947 }
948 }
949
950 //
951 // If we are here, it means we have an error so return 0
952 //
953 return 0ll;
954}
955
963{
964 uint64_t lowPart;
965 uint64_t highPart;
966
967 assert(pHandle);
968
969 //
970 // Test if we haven't already an error
971 //
972 if (pHandle->errorCode == SBG_NO_ERROR)
973 {
974 //
975 // Test if we can access this item
976 //
977 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(uint64_t))
978 {
979 //
980 // Test if the platform supports un-aligned access and if the endianness is the same
981 //
982 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
983 //
984 // Read the current value
985 //
986 lowPart = *((uint64_t*)pHandle->pCurrentPtr);
987
988 //
989 // Increment the current pointer
990 //
991 pHandle->pCurrentPtr += sizeof(uint64_t);
992
993 return lowPart;
994 #else
995 //
996 // Read 64 bit value using two 32 bits read to avoid too much 64 bits operations
997 //
998 highPart = sbgStreamBufferReadUint32BE(pHandle);
999 lowPart = sbgStreamBufferReadUint32BE(pHandle);
1000
1001 //
1002 // Store data according to platform endianness
1003 //
1004 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1005 return (lowPart << 32) | highPart;
1006 #else
1007 return lowPart | (highPart << 32);
1008 #endif
1009 #endif
1010 }
1011 else
1012 {
1013 //
1014 // We have a buffer overflow so return 0
1015 //
1016 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1017 }
1018 }
1019
1020 //
1021 // If we are here, it means we have an error so return 0
1022 //
1023 return 0ll;
1024}
1025
1033{
1034 assert(pHandle);
1035
1036 //
1037 // Just call the read method for uint32_t
1038 // We assume that a size_t is at least 32 bits on all platforms
1039 //
1040 return (size_t)sbgStreamBufferReadUint32BE(pHandle);
1041}
1042
1050{
1051 uint64_t size;
1052
1053 assert(pHandle);
1054
1055 //
1056 // Just call the read method for uint64_t
1057 //
1058 size = sbgStreamBufferReadUint64BE(pHandle);
1059
1060 //
1061 // Make sure the read size can fit in the size_t in size_t is 32 bits
1062 //
1063 assert((sizeof(size_t) == 8) || ((sizeof(size_t) == 4) && (size <= UINT32_MAX)));
1064
1065 //
1066 // Return the read value
1067 //
1068 return (size_t)size;
1069}
1070
1078{
1079 SbgFloatNint floatInt;
1080
1081 assert(pHandle);
1082
1083 //
1084 // Test if we haven't already an error
1085 //
1086 if (pHandle->errorCode == SBG_NO_ERROR)
1087 {
1088 //
1089 // Test if we can access this item
1090 //
1091 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(float))
1092 {
1093 //
1094 // Read the float as an uint32_t
1095 //
1096 floatInt.valU = sbgStreamBufferReadUint32BE(pHandle);
1097
1098 //
1099 // Return the float using an union to avoid compiller cast
1100 //
1101 return floatInt.valF;
1102 }
1103 else
1104 {
1105 //
1106 // We have a buffer overflow so return 0
1107 //
1108 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1109 }
1110 }
1111
1112 //
1113 // If we are here, it means we have an error so return 0
1114 //
1115 return 0.0f;
1116}
1117
1125{
1126 SbgDoubleNint doubleInt;
1127
1128 assert(pHandle);
1129
1130 //
1131 // Test if we haven't already an error
1132 //
1133 if (pHandle->errorCode == SBG_NO_ERROR)
1134 {
1135 //
1136 // Test if we can access this item
1137 //
1138 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(double))
1139 {
1140 //
1141 // Read the float as an uint64_t
1142 //
1143 doubleInt.valU = sbgStreamBufferReadUint64BE(pHandle);
1144
1145 //
1146 // Return the double using an union to avoid compiller cast
1147 //
1148 return doubleInt.valF;
1149 }
1150 else
1151 {
1152 //
1153 // We have a buffer overflow so return 0
1154 //
1155 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1156 }
1157 }
1158
1159 //
1160 // If we are here, it means we have an error so return 0
1161 //
1162 return 0.0;
1163}
1164
1165//----------------------------------------------------------------------//
1166//- Write operations methods -//
1167//----------------------------------------------------------------------//
1168
1177{
1178 assert(pHandle);
1179
1180 //
1181 // Test if we haven't already an error
1182 //
1183 if (pHandle->errorCode == SBG_NO_ERROR)
1184 {
1185 //
1186 // Test if we can access this item
1187 //
1188 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(int16_t))
1189 {
1190 //
1191 // Test if the platform supports un-aligned access and if the endianness is the same
1192 //
1193 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
1194 //
1195 // Write the value
1196 //
1197 *((int16_t*)(pHandle->pCurrentPtr)) = value;
1198
1199 //
1200 // Increment the current pointer
1201 //
1202 pHandle->pCurrentPtr += sizeof(int16_t);
1203 #else
1204 //
1205 // Store data according to platform endianness
1206 //
1207 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1208 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1209 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1210 #else
1211 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1212 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1213 #endif
1214 #endif
1215 }
1216 else
1217 {
1218 //
1219 // We are accessing a data that is outside the stream buffer
1220 //
1221 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1222 }
1223 }
1224
1225 return pHandle->errorCode;
1226}
1227
1236{
1237 assert(pHandle);
1238
1239 //
1240 // Test if we haven't already an error
1241 //
1242 if (pHandle->errorCode == SBG_NO_ERROR)
1243 {
1244 //
1245 // Test if we can access this item
1246 //
1247 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(uint16_t))
1248 {
1249 //
1250 // Test if the platform supports un-aligned access and if the endianness is the same
1251 //
1252 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
1253 //
1254 // Write the value
1255 //
1256 *((uint16_t*)(pHandle->pCurrentPtr)) = value;
1257
1258 //
1259 // Increment the current pointer
1260 //
1261 pHandle->pCurrentPtr += sizeof(uint16_t);
1262 #else
1263 //
1264 // Store data according to platform endianness
1265 //
1266 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1267 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1268 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1269 #else
1270 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1271 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1272 #endif
1273 #endif
1274 }
1275 else
1276 {
1277 //
1278 // We are accessing a data that is outside the stream buffer
1279 //
1280 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1281 }
1282 }
1283
1284 return pHandle->errorCode;
1285}
1286
1295{
1296 assert(pHandle);
1297
1298 //
1299 // Test if we haven't already an error
1300 //
1301 if (pHandle->errorCode == SBG_NO_ERROR)
1302 {
1303 //
1304 // Make sure that the value is within 24 bit bonds
1305 //
1306 if ( (value >= SBG_MIN_INT_24) && (value <= SBG_MAX_INT_24) )
1307 {
1308 //
1309 // Test if we can access this item
1310 //
1311 if (sbgStreamBufferGetSpace(pHandle) >= 3*sizeof(int8_t))
1312 {
1313 //
1314 // Store data according to platform endianness
1315 //
1316 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1317 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1318 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1319 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1320 #else
1321 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1322 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1323 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1324 #endif
1325 }
1326 else
1327 {
1328 //
1329 // We are accessing a data that is outside the stream buffer
1330 //
1331 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1332 }
1333 }
1334 else
1335 {
1336 //
1337 // The input value is not within a 24 bit integer bounds
1338 //
1340 }
1341 }
1342
1343 return pHandle->errorCode;
1344}
1345
1354{
1355 assert(pHandle);
1356
1357 //
1358 // Test if we haven't already an error
1359 //
1360 if (pHandle->errorCode == SBG_NO_ERROR)
1361 {
1362 //
1363 // Make sure that the value is within 24 bit bonds
1364 //
1365 if (value <= SBG_MAX_UINT_24)
1366 {
1367 //
1368 // Test if we can access this item
1369 //
1370 if (sbgStreamBufferGetSpace(pHandle) >= 3*sizeof(uint8_t))
1371 {
1372 //
1373 // Store data according to platform endianness
1374 //
1375 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1376 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1377 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1378 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1379 #else
1380 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1381 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1382 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1383 #endif
1384 }
1385 else
1386 {
1387 //
1388 // We are accessing a data that is outside the stream buffer
1389 //
1390 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1391 }
1392 }
1393 else
1394 {
1395 //
1396 // The input value is not within a 24 bit integer bounds
1397 //
1399 }
1400 }
1401
1402 return pHandle->errorCode;
1403}
1404
1413{
1414 assert(pHandle);
1415
1416 //
1417 // Test if we haven't already an error
1418 //
1419 if (pHandle->errorCode == SBG_NO_ERROR)
1420 {
1421 //
1422 // Test if we can access this item
1423 //
1424 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(int32_t))
1425 {
1426 //
1427 // Test if the platform supports un-aligned access and if the endianness is the same
1428 //
1429 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
1430 //
1431 // Write the value
1432 //
1433 *((int32_t*)(pHandle->pCurrentPtr)) = value;
1434
1435 //
1436 // Increment the current pointer
1437 //
1438 pHandle->pCurrentPtr += sizeof(int32_t);
1439 #else
1440 //
1441 // Store data according to platform endianness
1442 //
1443 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1444 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1445 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1446 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1447 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1448 #else
1449 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1450 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1451 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1452 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1453 #endif
1454 #endif
1455 }
1456 else
1457 {
1458 //
1459 // We are accessing a data that is outside the stream buffer
1460 //
1461 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1462 }
1463 }
1464
1465 return pHandle->errorCode;
1466}
1467
1476{
1477 assert(pHandle);
1478
1479 //
1480 // Test if we haven't already an error
1481 //
1482 if (pHandle->errorCode == SBG_NO_ERROR)
1483 {
1484 //
1485 // Test if we can access this item
1486 //
1487 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(uint32_t))
1488 {
1489 //
1490 // Test if the platform supports un-aligned access and if the endianness is the same
1491 //
1492 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
1493 //
1494 // Write the value
1495 //
1496 *((uint32_t*)(pHandle->pCurrentPtr)) = value;
1497
1498 //
1499 // Increment the current pointer
1500 //
1501 pHandle->pCurrentPtr += sizeof(uint32_t);
1502 #else
1503 //
1504 // Store data according to platform endianness
1505 //
1506 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1507 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1508 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1509 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1510 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1511 #else
1512 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1513 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1514 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1515 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1516 #endif
1517 #endif
1518 }
1519 else
1520 {
1521 //
1522 // We are accessing a data that is outside the stream buffer
1523 //
1524 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1525 }
1526 }
1527
1528 return pHandle->errorCode;
1529}
1530
1539{
1540 assert(pHandle);
1541 assert(value < ((uint64_t)1 << 48));
1542
1543 //
1544 // Test if we haven't already an error
1545 //
1546 if (pHandle->errorCode == SBG_NO_ERROR)
1547 {
1548 //
1549 // Test if we can access this item
1550 //
1551 if (sbgStreamBufferGetSpace(pHandle) >= 6 * sizeof(uint8_t))
1552 {
1553 //
1554 // Store data according to platform endianness
1555 //
1556 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1557 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1558 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1559 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1560 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1561 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 32);
1562 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 40);
1563 #else
1564 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 40);
1565 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 32);
1566 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1567 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1568 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1569 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1570 #endif
1571 }
1572 else
1573 {
1574 //
1575 // We are accessing a data that is outside the stream buffer
1576 //
1577 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1578 }
1579 }
1580
1581 return pHandle->errorCode;
1582}
1583
1592{
1593 assert(pHandle);
1594
1595 //
1596 // Test if we haven't already an error
1597 //
1598 if (pHandle->errorCode == SBG_NO_ERROR)
1599 {
1600 //
1601 // Test if we can access this item
1602 //
1603 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(int64_t))
1604 {
1605 //
1606 // Test if the platform supports un-aligned access and if the endianness is the same
1607 //
1608 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
1609 //
1610 // Write the value
1611 //
1612 *((int64_t*)(pHandle->pCurrentPtr)) = value;
1613
1614 //
1615 // Increment the current pointer
1616 //
1617 pHandle->pCurrentPtr += sizeof(int64_t);
1618 #else
1619 //
1620 // Store data according to platform endianness
1621 //
1622 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1623 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1624 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1625 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1626 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1627 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 32);
1628 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 40);
1629 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 48);
1630 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 56);
1631 #else
1632 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 56);
1633 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 48);
1634 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 40);
1635 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 32);
1636 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1637 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1638 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1639 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1640 #endif
1641 #endif
1642 }
1643 else
1644 {
1645 //
1646 // We are accessing a data that is outside the stream buffer
1647 //
1648 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1649 }
1650 }
1651
1652 return pHandle->errorCode;
1653}
1654
1663{
1664 assert(pHandle);
1665
1666 //
1667 // Test if we haven't already an error
1668 //
1669 if (pHandle->errorCode == SBG_NO_ERROR)
1670 {
1671 //
1672 // Test if we can access this item
1673 //
1674 if (sbgStreamBufferGetSpace(pHandle) >= sizeof(uint64_t))
1675 {
1676 //
1677 // Test if the platform supports un-aligned access and if the endianness is the same
1678 //
1679 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1)
1680 //
1681 // Write the value
1682 //
1683 *((uint64_t*)(pHandle->pCurrentPtr)) = value;
1684
1685 //
1686 // Increment the current pointer
1687 //
1688 pHandle->pCurrentPtr += sizeof(uint64_t);
1689 #else
1690 //
1691 // Store data according to platform endianness
1692 //
1693 #if (SBG_CONFIG_BIG_ENDIAN == 1)
1694 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1695 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1696 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1697 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1698 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 32);
1699 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 40);
1700 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 48);
1701 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 56);
1702 #else
1703 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 56);
1704 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 48);
1705 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 40);
1706 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 32);
1707 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 24);
1708 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 16);
1709 *(pHandle->pCurrentPtr++) = (uint8_t)(value >> 8);
1710 *(pHandle->pCurrentPtr++) = (uint8_t)(value);
1711 #endif
1712 #endif
1713 }
1714 else
1715 {
1716 //
1717 // We are accessing a data that is outside the stream buffer
1718 //
1719 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1720 }
1721 }
1722
1723 return pHandle->errorCode;
1724}
1725
1734{
1735 assert(pHandle);
1736
1737 //
1738 // Make sure the provided size_t value doesn't exceed a uint32_t storage
1739 //
1740 assert(value <= UINT32_MAX);
1741
1742 //
1743 // Call the write method to store a uint32_t
1744 //
1745 return sbgStreamBufferWriteUint32BE(pHandle, (uint32_t)value);
1746}
1747
1756{
1757 //
1758 // Check input parameters
1759 //
1760 assert(pHandle);
1761
1762 //
1763 // Call the write method to store a uint64_t
1764 //
1765 return sbgStreamBufferWriteUint64BE(pHandle, (uint64_t)value);
1766}
1767
1776{
1777 SbgFloatNint floatInt;
1778
1779 assert(pHandle);
1780
1781 //
1782 // Test if we haven't already an error
1783 //
1784 if (pHandle->errorCode == SBG_NO_ERROR)
1785 {
1786 //
1787 // We use an union to avoid compiler cast
1788 //
1789 floatInt.valF = value;
1790
1791 //
1792 // Write this float as an uint32_t
1793 //
1794 return sbgStreamBufferWriteUint32BE(pHandle, floatInt.valU);
1795 }
1796
1797 return pHandle->errorCode;
1798}
1799
1808{
1809 SbgDoubleNint doubleInt;
1810
1811 assert(pHandle);
1812
1813 //
1814 // Test if we haven't already an error
1815 //
1816 if (pHandle->errorCode == SBG_NO_ERROR)
1817 {
1818 //
1819 // We use an union to avoid compiler cast
1820 //
1821 doubleInt.valF = value;
1822
1823 //
1824 // Write this float as an uint64_t
1825 //
1826 return sbgStreamBufferWriteUint64BE(pHandle, doubleInt.valU);
1827 }
1828
1829 return pHandle->errorCode;
1830}
1831
1842{
1843 size_t stringLength;
1844
1845 assert(pHandle);
1846 assert(pString);
1847 assert(maxSize > 0);
1848
1849 //
1850 // Test if we haven't already an error
1851 //
1852 if (pHandle->errorCode == SBG_NO_ERROR)
1853 {
1854 //
1855 // The C string are stored in a stream buffer with a 32 bit size length and then the buffer itself
1856 //
1857 stringLength = sbgStreamBufferReadSizeT32BE(pHandle);
1858
1859 if (stringLength <= maxSize)
1860 {
1861 //
1862 // Read the string buffer itself
1863 //
1864 sbgStreamBufferReadBuffer(pHandle, pString, stringLength);
1865 }
1866 else
1867 {
1868 pHandle->errorCode = SBG_BUFFER_OVERFLOW;
1869 SBG_LOG_ERROR(pHandle->errorCode, "Trying to store a string of %zu bytes into a buffer of %zu bytes.", stringLength, maxSize);
1870 }
1871 }
1872
1873 return pHandle->errorCode;
1874}
1875
1884{
1885 size_t stringLength;
1886
1887 assert(pHandle);
1888 assert(pString);
1889
1890 //
1891 // Test if we haven't already an error
1892 //
1893 if (pHandle->errorCode == SBG_NO_ERROR)
1894 {
1895 //
1896 // We write C string using a 32 bit size_t as the string length including the NULL char
1897 // We should thus make sure the provided string isn't too big to fit in a 32 bits size_t
1898 //
1899 stringLength = strlen(pString)+1;
1900
1901 if (stringLength <= UINT32_MAX)
1902 {
1903 //
1904 // Write the string length
1905 //
1906 if (sbgStreamBufferWriteSizeT32BE(pHandle, stringLength) == SBG_NO_ERROR)
1907 {
1908 //
1909 // Write the string buffer itself
1910 //
1911 sbgStreamBufferWriteBuffer(pHandle, pString, stringLength);
1912 }
1913 }
1914 else
1915 {
1917 SBG_LOG_ERROR(pHandle->errorCode, "The provided string is too big to fit in a 32 bit size_t");
1918 }
1919 }
1920
1921 return pHandle->errorCode;
1922}
1923
1924#endif // SBG_STREAM_BUFFER_BE_H
#define SBG_INLINE
Definition sbgDefines.h:227
enum _SbgErrorCode SbgErrorCode
@ SBG_BUFFER_OVERFLOW
Definition sbgErrorCodes.h:63
@ SBG_NO_ERROR
Definition sbgErrorCodes.h:52
@ SBG_INVALID_PARAMETER
Definition sbgErrorCodes.h:64
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt16BE(SbgStreamBuffer *pHandle, int16_t value)
Definition sbgStreamBufferBE.h:1176
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt24BE(SbgStreamBuffer *pHandle, int32_t value)
Definition sbgStreamBufferBE.h:1294
SBG_INLINE int64_t sbgStreamBufferReadInt48BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:600
SBG_INLINE double sbgStreamBufferReadDoubleBE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:1124
SBG_INLINE SbgErrorCode sbgStreamBufferReadStringBE(SbgStreamBuffer *pHandle, char *pString, size_t maxSize)
Definition sbgStreamBufferBE.h:1841
SBG_INLINE int64_t sbgStreamBufferReadInt56BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:744
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt32BE(SbgStreamBuffer *pHandle, int32_t value)
Definition sbgStreamBufferBE.h:1412
SBG_INLINE uint64_t sbgStreamBufferReadUint64BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:962
SBG_INLINE int32_t sbgStreamBufferReadInt32BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:318
SBG_INLINE size_t sbgStreamBufferReadSizeT64BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:1049
SBG_INLINE int64_t sbgStreamBufferReadInt64BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:892
SBG_INLINE uint16_t sbgStreamBufferReadUint16BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:117
SBG_INLINE int64_t sbgStreamBufferReadInt40BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:460
SBG_INLINE int64_t sbgStreamBufferReadUint56BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:818
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint48BE(SbgStreamBuffer *pHandle, uint64_t value)
Definition sbgStreamBufferBE.h:1538
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt64BE(SbgStreamBuffer *pHandle, int64_t value)
Definition sbgStreamBufferBE.h:1591
SBG_INLINE uint32_t sbgStreamBufferReadUint24BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:252
SBG_INLINE SbgErrorCode sbgStreamBufferWriteSizeT32BE(SbgStreamBuffer *pHandle, size_t value)
Definition sbgStreamBufferBE.h:1733
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32BE(SbgStreamBuffer *pHandle, uint32_t value)
Definition sbgStreamBufferBE.h:1475
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatBE(SbgStreamBuffer *pHandle, float value)
Definition sbgStreamBufferBE.h:1775
SBG_INLINE int16_t sbgStreamBufferReadInt16BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:48
SBG_INLINE size_t sbgStreamBufferReadSizeT32BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:1032
SBG_INLINE SbgErrorCode sbgStreamBufferWriteStringBE(SbgStreamBuffer *pHandle, const char *pString)
Definition sbgStreamBufferBE.h:1883
SBG_INLINE uint64_t sbgStreamBufferReadUint40BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:530
SBG_INLINE float sbgStreamBufferReadFloatBE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:1077
SBG_INLINE SbgErrorCode sbgStreamBufferWriteSizeT64BE(SbgStreamBuffer *pHandle, size_t value)
Definition sbgStreamBufferBE.h:1755
SBG_INLINE uint32_t sbgStreamBufferReadUint32BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:389
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint24BE(SbgStreamBuffer *pHandle, uint32_t value)
Definition sbgStreamBufferBE.h:1353
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint64BE(SbgStreamBuffer *pHandle, uint64_t value)
Definition sbgStreamBufferBE.h:1662
SBG_INLINE int32_t sbgStreamBufferReadInt24BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:186
SBG_INLINE SbgErrorCode sbgStreamBufferWriteDoubleBE(SbgStreamBuffer *pHandle, double value)
Definition sbgStreamBufferBE.h:1807
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16BE(SbgStreamBuffer *pHandle, uint16_t value)
Definition sbgStreamBufferBE.h:1235
SBG_INLINE uint64_t sbgStreamBufferReadUint48BE(SbgStreamBuffer *pHandle)
Definition sbgStreamBufferBE.h:672
Used to read/write data from/to a memory buffer stream.
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
Definition sbgStreamBufferCommon.h:614
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer(SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
Definition sbgStreamBufferCommon.h:784
SBG_INLINE size_t sbgStreamBufferGetSpace(const SbgStreamBuffer *pHandle)
Definition sbgStreamBufferCommon.h:357
struct _SbgStreamBuffer SbgStreamBuffer
union _SbgUint8ToInt64 SbgUint8ToInt64
union _SbgDoubleNint SbgDoubleNint
union _SbgFloatNint SbgFloatNint
union _SbgUint8ToUint32 SbgUint8ToUint32
union _SbgUint8ToInt32 SbgUint8ToInt32
union _SbgUint8ToUint64 SbgUint8ToUint64
SbgErrorCode errorCode
Definition sbgStreamBufferCommon.h:206
uint8_t * pCurrentPtr
Definition sbgStreamBufferCommon.h:205