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 sbgStreamBufferReadBufferBE sbgStreamBufferReadBuffer |
Definition at line 107 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadBufferLE sbgStreamBufferReadBuffer |
Definition at line 99 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadDouble sbgStreamBufferReadDoubleLE |
Definition at line 77 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadFloat sbgStreamBufferReadFloatLE |
Definition at line 76 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt16 sbgStreamBufferReadInt16LE |
Definition at line 67 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt24 sbgStreamBufferReadInt24LE |
Definition at line 69 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt32 sbgStreamBufferReadInt32LE |
Definition at line 71 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt64 sbgStreamBufferReadInt64LE |
Definition at line 73 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt8BE sbgStreamBufferReadInt8 |
Definition at line 106 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadInt8LE sbgStreamBufferReadInt8 |
Definition at line 98 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadSizeT32 sbgStreamBufferReadSizeT32LE |
Definition at line 74 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadSizeT64 sbgStreamBufferReadSizeT64LE |
Definition at line 75 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 66 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint24 sbgStreamBufferReadUint24LE |
Definition at line 68 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint32 sbgStreamBufferReadUint32LE |
Definition at line 70 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint64 sbgStreamBufferReadUint64LE |
Definition at line 72 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferReadUint8BE sbgStreamBufferReadUint8 |
Definition at line 105 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 97 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteBufferBE sbgStreamBufferWriteBuffer |
Definition at line 111 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteBufferLE sbgStreamBufferWriteBuffer |
Definition at line 103 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteDouble sbgStreamBufferWriteDoubleLE |
Definition at line 90 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteFloat sbgStreamBufferWriteFloatLE |
Definition at line 89 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt16 sbgStreamBufferWriteInt16LE |
Definition at line 80 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt24 sbgStreamBufferWriteInt24LE |
Definition at line 82 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt32 sbgStreamBufferWriteInt32LE |
Definition at line 84 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt64 sbgStreamBufferWriteInt64LE |
Definition at line 86 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt8BE sbgStreamBufferWriteInt8 |
Definition at line 110 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteInt8LE sbgStreamBufferWriteInt8 |
Definition at line 102 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteSizeT32 sbgStreamBufferWriteSizeT32LE |
Definition at line 87 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteSizeT64 sbgStreamBufferWriteSizeT64LE |
Definition at line 88 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint16 sbgStreamBufferWriteUint16LE |
Definition at line 79 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint24 sbgStreamBufferWriteUint24LE |
Definition at line 81 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint32 sbgStreamBufferWriteUint32LE |
Definition at line 83 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint64 sbgStreamBufferWriteUint64LE |
Definition at line 85 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint8BE sbgStreamBufferWriteUint8 |
Definition at line 109 of file sbgStreamBufferCommon.h.
#define sbgStreamBufferWriteUint8LE sbgStreamBufferWriteUint8 |
Definition at line 101 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 120 of file sbgStreamBufferCommon.h.
enum _SbgSBSeekOrigin |
Enum used to define all seek modes
Definition at line 129 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 245 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 436 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 228 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 has been written, it should return 16.
[in] | pHandle | Valid handle on a stream buffer. |
Definition at line 287 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 421 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 266 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 307 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 195 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 160 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 541 of file sbgStreamBufferCommon.h.
SBG_INLINE int8 sbgStreamBufferReadInt8 | ( | SbgStreamBuffer * | pHandle | ) |
Read an int8 from a stream buffer.
[in] | pHandle | Valid stream buffer handle that supports read operations. |
Definition at line 455 of file sbgStreamBufferCommon.h.
SBG_INLINE uint8 sbgStreamBufferReadUint8 | ( | SbgStreamBuffer * | pHandle | ) |
Read an uint8 from a stream buffer.
[in] | pHandle | Valid stream buffer handle that supports read operations. |
Definition at line 497 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 327 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 406 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 672 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt8 | ( | SbgStreamBuffer * | pHandle, |
int8 | value | ||
) |
Write an int8 into a stream buffer
[in] | pHandle | Valid stream buffer handle that supports write operations. |
[in] | value | The value to write. |
Definition at line 591 of file sbgStreamBufferCommon.h.
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint8 | ( | SbgStreamBuffer * | pHandle, |
uint8 | value | ||
) |
Write an uint8 into a stream buffer
[in] | pHandle | Valid stream buffer handle that supports write operations. |
[in] | value | The value to write. |
Definition at line 631 of file sbgStreamBufferCommon.h.