Used to read/write data from/to a memory buffer stream. More...
#include <sbgCommon.h>
Go to the source code of this file.
Classes | |
struct | _SbgStreamBuffer |
Typedefs | |
typedef enum _SbgSBMode | SbgSBMode |
typedef enum _SbgSBSeekOrigin | SbgSBSeekOrigin |
typedef struct _SbgStreamBuffer | SbgStreamBuffer |
Enumerations | |
enum | _SbgSBMode { SB_MODE_READ, SB_MODE_WRITE } |
enum | _SbgSBSeekOrigin { SB_SEEK_SET, SB_SEEK_CUR_INC, SB_SEEK_CUR_DEC, SB_SEEK_END } |
Used to read/write data from/to a memory buffer stream.
Copyright (C) 2007-2013, SBG Systems SAS. All rights reserved.
This source code is intended for use only by SBG Systems SAS and those that have explicit written permission to use it from SBG Systems SAS.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
Definition in file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadBooleanBE sbgStreamBufferReadBoolean |
Definition at line 153 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadBooleanLE sbgStreamBufferReadBoolean |
Definition at line 143 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadBufferBE sbgStreamBufferReadBuffer |
Definition at line 154 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadBufferLE sbgStreamBufferReadBuffer |
Definition at line 144 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadDouble sbgStreamBufferReadDoubleLE |
Definition at line 113 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadFloat sbgStreamBufferReadFloatLE |
Definition at line 112 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt16 sbgStreamBufferReadInt16LE |
Definition at line 89 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt24 sbgStreamBufferReadInt24LE |
Definition at line 92 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt32 sbgStreamBufferReadInt32LE |
Definition at line 95 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt40 sbgStreamBufferReadInt40LE |
Definition at line 98 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt48 sbgStreamBufferReadInt48LE |
Definition at line 101 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt56 sbgStreamBufferReadInt56LE |
Definition at line 104 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt64 sbgStreamBufferReadInt64LE |
Definition at line 107 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt8BE sbgStreamBufferReadInt8 |
Definition at line 152 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt8LE sbgStreamBufferReadInt8 |
Definition at line 142 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadSizeT32 sbgStreamBufferReadSizeT32LE |
Definition at line 109 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadSizeT64 sbgStreamBufferReadSizeT64LE |
Definition at line 110 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadString sbgStreamBufferReadStringLE |
Definition at line 133 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint16 sbgStreamBufferReadUint16LE |
The default method should read and write using the platform endianness
The platform is a little endian one so default methods should use little endian byte order.
Definition at line 88 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint24 sbgStreamBufferReadUint24LE |
Definition at line 91 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint32 sbgStreamBufferReadUint32LE |
Definition at line 94 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint40 sbgStreamBufferReadUint40LE |
Definition at line 97 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint48 sbgStreamBufferReadUint48LE |
Definition at line 100 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint56 sbgStreamBufferReadUint56LE |
Definition at line 103 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint64 sbgStreamBufferReadUint64LE |
Definition at line 106 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint8BE sbgStreamBufferReadUint8 |
Definition at line 151 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint8LE sbgStreamBufferReadUint8 |
Some methods are common between big and little endian. This definitions just unify the API.
Definition at line 141 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteBooleanBE sbgStreamBufferWriteBoolean |
Definition at line 158 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteBooleanLE sbgStreamBufferWriteBoolean |
Definition at line 148 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteBufferBE sbgStreamBufferWriteBuffer |
Definition at line 159 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteBufferLE sbgStreamBufferWriteBuffer |
Definition at line 149 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteDouble sbgStreamBufferWriteDoubleLE |
Definition at line 131 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteFloat sbgStreamBufferWriteFloatLE |
Definition at line 130 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt16 sbgStreamBufferWriteInt16LE |
Definition at line 116 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt24 sbgStreamBufferWriteInt24LE |
Definition at line 119 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt32 sbgStreamBufferWriteInt32LE |
Definition at line 122 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt64 sbgStreamBufferWriteInt64LE |
Definition at line 125 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt8BE sbgStreamBufferWriteInt8 |
Definition at line 157 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt8LE sbgStreamBufferWriteInt8 |
Definition at line 147 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteSizeT32 sbgStreamBufferWriteSizeT32LE |
Definition at line 127 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteSizeT64 sbgStreamBufferWriteSizeT64LE |
Definition at line 128 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteString sbgStreamBufferWriteStringLE |
Definition at line 134 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint16 sbgStreamBufferWriteUint16LE |
Definition at line 115 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint24 sbgStreamBufferWriteUint24LE |
Definition at line 118 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint32 sbgStreamBufferWriteUint32LE |
Definition at line 121 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint64 sbgStreamBufferWriteUint64LE |
Definition at line 124 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint8BE sbgStreamBufferWriteUint8 |
Definition at line 156 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint8LE sbgStreamBufferWriteUint8 |
Definition at line 146 of file sbgStreamBufferCommon.h.
typedef enum _SbgSBMode SbgSBMode |
Stream buffer modes.
typedef enum _SbgSBSeekOrigin SbgSBSeekOrigin |
Enum used to define all seek modes
typedef struct _SbgStreamBuffer SbgStreamBuffer |
Defines a stream buffer.
enum _SbgSBMode |
Stream buffer modes.
Enumerator | |
---|---|
SB_MODE_READ | This stream buffer can perform read operations. |
SB_MODE_WRITE | This stream buffer can perform write operations. |
Definition at line 168 of file sbgStreamBufferCommon.h.
enum _SbgSBSeekOrigin |
Enum used to define all seek modes
Definition at line 177 of file sbgStreamBufferCommon.h.
SBG_INLINE void sbgStreamBufferClearLastError | ( | SbgStreamBuffer * | pHandle | ) |
Clear the last error code that has occurred on the last stream buffer operation.
[in] | pHandle | Pointer to a valid Stream Buffer handle |
Definition at line 291 of file sbgStreamBufferCommon.h.
SBG_INLINE void* sbgStreamBufferGetCursor | ( | SbgStreamBuffer * | pHandle | ) |
Returns a pointer on the internal buffer at the current cursor.
[in] | pHandle | Valid handle on a stream buffer. |
Definition at line 482 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError | ( | SbgStreamBuffer * | pHandle | ) |
Return the error code that has occurred on the last stream buffer operation.
[in] | pHandle | Pointer to a valid Stream Buffer handle |
Definition at line 274 of file sbgStreamBufferCommon.h.
SBG_INLINE size_t sbgStreamBufferGetLength | ( | SbgStreamBuffer * | pHandle | ) |
Returns the length in bytes of this stream. The length is computed using the current cursor position. If no data has been read or written, this method will return 0. If 4 uint32_t has been written, it should return 16.
[in] | pHandle | Valid handle on a stream buffer. |
Definition at line 333 of file sbgStreamBufferCommon.h.
SBG_INLINE void* sbgStreamBufferGetLinkedBuffer | ( | SbgStreamBuffer * | pHandle | ) |
Returns a pointer on the internal buffer.
[in] | pHandle | Valid handle on a stream buffer. |
Definition at line 467 of file sbgStreamBufferCommon.h.
SBG_INLINE size_t sbgStreamBufferGetSize | ( | SbgStreamBuffer * | pHandle | ) |
Returns the size in bytes of this stream. The size is the linked buffer total size in bytes. For example, for a SbgStreamBuffer linked with a buffer of 256 bytes, this method will always returns 256 even if no data has been written or read.
[in] | pHandle | Valid handle on a stream buffer. |
Definition at line 312 of file sbgStreamBufferCommon.h.
SBG_INLINE size_t sbgStreamBufferGetSpace | ( | SbgStreamBuffer * | pHandle | ) |
Returns the available space in this stream. The available space is just the delta between the linked buffer size and the current buffer length (cursor position).
[in] | pHandle | Valid handle on a stream buffer. |
Definition at line 353 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead | ( | SbgStreamBuffer * | pHandle, |
const void * | pLinkedBuffer, | ||
size_t | bufferSize | ||
) |
Initialize a stream buffer for both read and write operations and link it to a buffer.
[in] | pHandle | Handle on an allocated stream buffer. |
[in] | pLinkedBuffer | Pointer on an allocated buffer to link with this stream. |
[in] | bufferSize | Size in bytes of the linked buffer. |
Definition at line 242 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferInitForWrite | ( | SbgStreamBuffer * | pHandle, |
void * | pLinkedBuffer, | ||
size_t | bufferSize | ||
) |
Initialize a stream buffer for both read and write operations and link it to a buffer.
[in] | pHandle | Handle on an allocated stream buffer. |
[in] | pLinkedBuffer | Pointer on an allocated buffer to link with this stream. |
[in] | bufferSize | Size in bytes of the linked buffer. |
Definition at line 208 of file sbgStreamBufferCommon.h.
SBG_INLINE bool sbgStreamBufferReadBoolean | ( | SbgStreamBuffer * | pHandle | ) |
Read a boolean from a stream buffer.
[in] | pHandle | Valid stream buffer handle that supports read operations. |
Definition at line 585 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer | ( | SbgStreamBuffer * | pHandle, |
void * | pBuffer, | ||
size_t | numBytesToRead | ||
) |
Read a buffer from a stream buffer.
[in] | pHandle | Valid stream buffer handle that supports read operations. |
[out] | pBuffer | Allocated buffer used to hold read data. |
[in] | numBytesToRead | Number of bytes to read from the stream buffer and to store in pBuffer. |
Definition at line 636 of file sbgStreamBufferCommon.h.
SBG_INLINE int8_t sbgStreamBufferReadInt8 | ( | SbgStreamBuffer * | pHandle | ) |
Read an int8_t from a stream buffer.
[in] | pHandle | Valid stream buffer handle that supports read operations. |
Definition at line 501 of file sbgStreamBufferCommon.h.
SBG_INLINE uint8_t sbgStreamBufferReadUint8 | ( | SbgStreamBuffer * | pHandle | ) |
Read an uint8_t from a stream buffer.
[in] | pHandle | Valid stream buffer handle that supports read operations. |
Definition at line 543 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferSeek | ( | SbgStreamBuffer * | pHandle, |
size_t | offset, | ||
SbgSBSeekOrigin | origin | ||
) |
Move the current cursor position.
[in] | pHandle | Valid handle on a stream buffer. |
[in] | offset | Offset in bytes to apply (only positive). |
[in] | origin | Origin reference point to apply the offset from. |
Definition at line 373 of file sbgStreamBufferCommon.h.
SBG_INLINE size_t sbgStreamBufferTell | ( | SbgStreamBuffer * | pHandle | ) |
Returns the current offset in bytes from the beginning of the stream.
[in] | pHandle | Valid handle on a stream buffer. |
Definition at line 452 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBoolean | ( | SbgStreamBuffer * | pHandle, |
bool | value | ||
) |
Write a boolean into a stream buffer
[in] | pHandle | Valid stream buffer handle that supports write operations. |
[in] | value | The value to write. |
Definition at line 766 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer | ( | SbgStreamBuffer * | pHandle, |
const void * | pBuffer, | ||
size_t | numBytesToWrite | ||
) |
Write a buffer to a stream buffer.
[in] | pHandle | Valid stream buffer handle that supports write operations. |
[out] | pBuffer | Buffer to write into the stream buffer. |
[in] | numBytesToRead | Number of bytes to write to the stream buffer. |
Definition at line 814 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt8 | ( | SbgStreamBuffer * | pHandle, |
int8_t | value | ||
) |
Write an int8_t into a stream buffer
[in] | pHandle | Valid stream buffer handle that supports write operations. |
[in] | value | The value to write. |
Definition at line 686 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint8 | ( | SbgStreamBuffer * | pHandle, |
uint8_t | value | ||
) |
Write an uint8_t into a stream buffer
[in] | pHandle | Valid stream buffer handle that supports write operations. |
[in] | value | The value to write. |
Definition at line 726 of file sbgStreamBufferCommon.h.