21 #ifndef SBG_STREAM_BUFFER_BE_H 22 #define SBG_STREAM_BUFFER_BE_H 37 int16_t bytesValues[2];
57 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 68 return bytesValues[0];
79 #if (SBG_CONFIG_BIG_ENDIAN == 1) 80 return bytesValues[1] | (bytesValues[0] << 8);
82 return bytesValues[0] | (bytesValues[1] << 8);
108 uint16_t bytesValues[2];
128 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 132 bytesValues[0] = *((uint16_t*)pHandle->
pCurrentPtr);
139 return bytesValues[0];
150 #if (SBG_CONFIG_BIG_ENDIAN == 1) 151 return bytesValues[1] | (bytesValues[0] << 8);
153 return bytesValues[0] | (bytesValues[1] << 8);
204 #if (SBG_CONFIG_BIG_ENDIAN == 1) 223 return value.
value >> (32-24);
272 #if (SBG_CONFIG_BIG_ENDIAN == 1) 291 return value.
value >> (32-24);
315 int32_t bytesValues[4];
335 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 339 bytesValues[0] = *((int32_t*)pHandle->
pCurrentPtr);
346 return bytesValues[0];
359 #if (SBG_CONFIG_BIG_ENDIAN == 1) 360 return bytesValues[3] | (bytesValues[2] << 8) | (bytesValues[1] << 16) | (bytesValues[0] << 24);
362 return bytesValues[0] | (bytesValues[1] << 8) | (bytesValues[2] << 16) | (bytesValues[3] << 24);
388 uint32_t bytesValues[4];
408 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 412 bytesValues[0] = *((uint32_t*)pHandle->
pCurrentPtr);
419 return bytesValues[0];
432 #if (SBG_CONFIG_BIG_ENDIAN == 1) 433 return bytesValues[3] | (bytesValues[2] << 8) | (bytesValues[1] << 16) | (bytesValues[0] << 24);
435 return bytesValues[0] | (bytesValues[1] << 8) | (bytesValues[2] << 16) | (bytesValues[3] << 24);
486 #if (SBG_CONFIG_BIG_ENDIAN == 1) 509 return value.
value >> (64-40);
558 #if (SBG_CONFIG_BIG_ENDIAN == 1) 581 return value.
value >> (64-40);
630 #if (SBG_CONFIG_BIG_ENDIAN == 1) 655 return value.
value >> (64-48);
704 #if (SBG_CONFIG_BIG_ENDIAN == 1) 729 return value.
value >> (64-48);
778 #if (SBG_CONFIG_BIG_ENDIAN == 1) 805 return value.
value >> (64-56);
854 #if (SBG_CONFIG_BIG_ENDIAN == 1) 881 return value.
value >> (64-56);
926 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 948 #if (SBG_CONFIG_BIG_ENDIAN == 1) 949 return (lowPart << 32) | highPart;
951 return lowPart | (highPart << 32);
998 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 1020 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1021 return (lowPart << 32) | highPart;
1023 return lowPart | (highPart << 32);
1073 assert((
sizeof(
size_t) == 8) || ((
sizeof(
size_t) == 4) && (size <= UINT32_MAX)));
1078 return (
size_t)size;
1113 return floatInt.
valF;
1162 return doubleInt.
valF;
1209 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 1223 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1225 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1227 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1270 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 1284 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1286 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1288 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1336 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1338 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1339 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1341 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1342 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1397 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1399 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1400 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1402 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1403 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1453 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 1467 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1469 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1470 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1471 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1473 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1474 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1475 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1518 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 1532 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1534 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1535 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1536 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1538 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1539 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1540 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1583 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 1597 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1599 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1600 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1601 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1602 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 32);
1603 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 40);
1604 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 48);
1605 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 56);
1607 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 56);
1608 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 48);
1609 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 40);
1610 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 32);
1611 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1612 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1613 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1656 #if (SBG_CONFIG_UNALIGNED_ACCESS_AUTH == 1) && (SBG_CONFIG_BIG_ENDIAN == 1) 1670 #if (SBG_CONFIG_BIG_ENDIAN == 1) 1672 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1673 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1674 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1675 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 32);
1676 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 40);
1677 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 48);
1678 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 56);
1680 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 56);
1681 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 48);
1682 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 40);
1683 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 32);
1684 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 24);
1685 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 16);
1686 *(pHandle->
pCurrentPtr++) = (uint8_t)(value >> 8);
1719 assert(value <= UINT32_MAX);
1769 floatInt.
valF = value;
1803 doubleInt.
valF = value;
1825 size_t stringLength;
1832 assert(maxSize > 0);
1844 if (stringLength <= maxSize)
1854 SBG_LOG_ERROR(pHandle->
errorCode,
"Trying to store a string of %u bytes into a buffer of %u bytes.", stringLength, maxSize);
1869 size_t stringLength;
1886 stringLength = strlen(pString)+1;
1888 if (stringLength <= UINT32_MAX)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint24BE(SbgStreamBuffer *pHandle, uint32_t value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteFloatBE(SbgStreamBuffer *pHandle, float value)
SBG_INLINE int32_t sbgStreamBufferReadInt24BE(SbgStreamBuffer *pHandle)
SBG_INLINE float sbgStreamBufferReadFloatBE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferReadStringBE(SbgStreamBuffer *pHandle, char *pString, size_t maxSize)
SBG_INLINE uint64_t sbgStreamBufferReadUint64BE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt64BE(SbgStreamBuffer *pHandle, int64_t value)
Used to read/write data from/to a memory buffer stream.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteSizeT64BE(SbgStreamBuffer *pHandle, size_t value)
SBG_INLINE uint32_t sbgStreamBufferReadUint32BE(SbgStreamBuffer *pHandle)
SBG_INLINE int64_t sbgStreamBufferReadInt56BE(SbgStreamBuffer *pHandle)
SBG_INLINE int64_t sbgStreamBufferReadUint56BE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint64BE(SbgStreamBuffer *pHandle, uint64_t value)
SBG_INLINE int64_t sbgStreamBufferReadInt48BE(SbgStreamBuffer *pHandle)
SBG_INLINE size_t sbgStreamBufferReadSizeT32BE(SbgStreamBuffer *pHandle)
SBG_INLINE double sbgStreamBufferReadDoubleBE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteDoubleBE(SbgStreamBuffer *pHandle, double value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt32BE(SbgStreamBuffer *pHandle, int32_t value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteSizeT32BE(SbgStreamBuffer *pHandle, size_t value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint16BE(SbgStreamBuffer *pHandle, uint16_t value)
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer(SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
SBG_INLINE size_t sbgStreamBufferGetSpace(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt24BE(SbgStreamBuffer *pHandle, int32_t value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer(SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
SBG_INLINE uint64_t sbgStreamBufferReadUint48BE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt16BE(SbgStreamBuffer *pHandle, int16_t value)
SBG_INLINE int64_t sbgStreamBufferReadInt40BE(SbgStreamBuffer *pHandle)
SBG_INLINE int64_t sbgStreamBufferReadInt64BE(SbgStreamBuffer *pHandle)
#define SBG_LOG_ERROR(format,...)
SBG_INLINE uint64_t sbgStreamBufferReadUint40BE(SbgStreamBuffer *pHandle)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint32BE(SbgStreamBuffer *pHandle, uint32_t value)
SBG_INLINE SbgErrorCode sbgStreamBufferWriteStringBE(SbgStreamBuffer *pHandle, const char *pString)
SBG_INLINE int32_t sbgStreamBufferReadInt32BE(SbgStreamBuffer *pHandle)
SBG_INLINE int16_t sbgStreamBufferReadInt16BE(SbgStreamBuffer *pHandle)
SBG_INLINE size_t sbgStreamBufferReadSizeT64BE(SbgStreamBuffer *pHandle)
SBG_INLINE uint32_t sbgStreamBufferReadUint24BE(SbgStreamBuffer *pHandle)
SBG_INLINE uint16_t sbgStreamBufferReadUint16BE(SbgStreamBuffer *pHandle)
enum _SbgErrorCode SbgErrorCode