Classes | Macros | Typedefs | Enumerations | Functions
sbgStreamBufferCommon.h File Reference

Used to read/write data from/to a memory buffer stream. More...

#include <sbgCommon.h>
Include dependency graph for sbgStreamBufferCommon.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SbgStreamBuffer
 

Macros

#define sbgStreamBufferReadBufferBE   sbgStreamBufferReadBuffer
 
#define sbgStreamBufferReadBufferLE   sbgStreamBufferReadBuffer
 
#define sbgStreamBufferReadDouble   sbgStreamBufferReadDoubleLE
 
#define sbgStreamBufferReadFloat   sbgStreamBufferReadFloatLE
 
#define sbgStreamBufferReadInt16   sbgStreamBufferReadInt16LE
 
#define sbgStreamBufferReadInt24   sbgStreamBufferReadInt24LE
 
#define sbgStreamBufferReadInt32   sbgStreamBufferReadInt32LE
 
#define sbgStreamBufferReadInt64   sbgStreamBufferReadInt64LE
 
#define sbgStreamBufferReadInt8BE   sbgStreamBufferReadInt8
 
#define sbgStreamBufferReadInt8LE   sbgStreamBufferReadInt8
 
#define sbgStreamBufferReadSizeT32   sbgStreamBufferReadSizeT32LE
 
#define sbgStreamBufferReadSizeT64   sbgStreamBufferReadSizeT64LE
 
#define sbgStreamBufferReadUint16   sbgStreamBufferReadUint16LE
 
#define sbgStreamBufferReadUint24   sbgStreamBufferReadUint24LE
 
#define sbgStreamBufferReadUint32   sbgStreamBufferReadUint32LE
 
#define sbgStreamBufferReadUint64   sbgStreamBufferReadUint64LE
 
#define sbgStreamBufferReadUint8BE   sbgStreamBufferReadUint8
 
#define sbgStreamBufferReadUint8LE   sbgStreamBufferReadUint8
 
#define sbgStreamBufferWriteBufferBE   sbgStreamBufferWriteBuffer
 
#define sbgStreamBufferWriteBufferLE   sbgStreamBufferWriteBuffer
 
#define sbgStreamBufferWriteDouble   sbgStreamBufferWriteDoubleLE
 
#define sbgStreamBufferWriteFloat   sbgStreamBufferWriteFloatLE
 
#define sbgStreamBufferWriteInt16   sbgStreamBufferWriteInt16LE
 
#define sbgStreamBufferWriteInt24   sbgStreamBufferWriteInt24LE
 
#define sbgStreamBufferWriteInt32   sbgStreamBufferWriteInt32LE
 
#define sbgStreamBufferWriteInt64   sbgStreamBufferWriteInt64LE
 
#define sbgStreamBufferWriteInt8BE   sbgStreamBufferWriteInt8
 
#define sbgStreamBufferWriteInt8LE   sbgStreamBufferWriteInt8
 
#define sbgStreamBufferWriteSizeT32   sbgStreamBufferWriteSizeT32LE
 
#define sbgStreamBufferWriteSizeT64   sbgStreamBufferWriteSizeT64LE
 
#define sbgStreamBufferWriteUint16   sbgStreamBufferWriteUint16LE
 
#define sbgStreamBufferWriteUint24   sbgStreamBufferWriteUint24LE
 
#define sbgStreamBufferWriteUint32   sbgStreamBufferWriteUint32LE
 
#define sbgStreamBufferWriteUint64   sbgStreamBufferWriteUint64LE
 
#define sbgStreamBufferWriteUint8BE   sbgStreamBufferWriteUint8
 
#define sbgStreamBufferWriteUint8LE   sbgStreamBufferWriteUint8
 

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 }
 

Functions

SBG_INLINE void sbgStreamBufferClearLastError (SbgStreamBuffer *pHandle)
 
SBG_INLINE void * sbgStreamBufferGetCursor (SbgStreamBuffer *pHandle)
 
SBG_INLINE SbgErrorCode sbgStreamBufferGetLastError (SbgStreamBuffer *pHandle)
 
SBG_INLINE size_t sbgStreamBufferGetLength (SbgStreamBuffer *pHandle)
 
SBG_INLINE void * sbgStreamBufferGetLinkedBuffer (SbgStreamBuffer *pHandle)
 
SBG_INLINE size_t sbgStreamBufferGetSize (SbgStreamBuffer *pHandle)
 
SBG_INLINE size_t sbgStreamBufferGetSpace (SbgStreamBuffer *pHandle)
 
SBG_INLINE SbgErrorCode sbgStreamBufferInitForRead (SbgStreamBuffer *pHandle, const void *pLinkedBuffer, size_t bufferSize)
 
SBG_INLINE SbgErrorCode sbgStreamBufferInitForWrite (SbgStreamBuffer *pHandle, void *pLinkedBuffer, size_t bufferSize)
 
SBG_INLINE SbgErrorCode sbgStreamBufferReadBuffer (SbgStreamBuffer *pHandle, void *pBuffer, size_t numBytesToRead)
 
SBG_INLINE int8 sbgStreamBufferReadInt8 (SbgStreamBuffer *pHandle)
 
SBG_INLINE uint8 sbgStreamBufferReadUint8 (SbgStreamBuffer *pHandle)
 
SBG_INLINE SbgErrorCode sbgStreamBufferSeek (SbgStreamBuffer *pHandle, size_t offset, SbgSBSeekOrigin origin)
 
SBG_INLINE size_t sbgStreamBufferTell (SbgStreamBuffer *pHandle)
 
SBG_INLINE SbgErrorCode sbgStreamBufferWriteBuffer (SbgStreamBuffer *pHandle, const void *pBuffer, size_t numBytesToWrite)
 
SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt8 (SbgStreamBuffer *pHandle, int8 value)
 
SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint8 (SbgStreamBuffer *pHandle, uint8 value)
 

Detailed Description

Used to read/write data from/to a memory buffer stream.

Author
SBG Systems (Raphael Siryani)
Date
02 January 2013

Copyright Notice

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.

Macro Definition Documentation

#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 Documentation

typedef enum _SbgSBMode SbgSBMode

Stream buffer modes.

Enum used to define all seek modes

Defines a stream buffer.

Enumeration Type Documentation

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 used to define all seek modes

Enumerator
SB_SEEK_SET 

The offset is referenced to the begining of the stream.

SB_SEEK_CUR_INC 

The offset is referenced to the current cursor position and increment the current cursor.

SB_SEEK_CUR_DEC 

The offset is referenced to the current cursor position and decrement the current cursor.

SB_SEEK_END 

The offset is referenced to the end of the stream.

Definition at line 129 of file sbgStreamBufferCommon.h.

Function Documentation

SBG_INLINE void sbgStreamBufferClearLastError ( SbgStreamBuffer pHandle)

Clear the last error code that has occurred on the last stream buffer operation.

Parameters
[in]pHandlePointer 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.

Parameters
[in]pHandleValid handle on a stream buffer.
Returns
Pointer on the current cursor of the internal 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.

Parameters
[in]pHandlePointer to a valid Stream Buffer handle
Returns
Last stream buffer error code

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.

Parameters
[in]pHandleValid handle on a stream buffer.
Returns
The current cursor position in bytes.

Definition at line 287 of file sbgStreamBufferCommon.h.

SBG_INLINE void* sbgStreamBufferGetLinkedBuffer ( SbgStreamBuffer pHandle)

Returns a pointer on the internal buffer.

Parameters
[in]pHandleValid handle on a stream buffer.
Returns
Pointer on the begining of the internal 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.

Parameters
[in]pHandleValid handle on a stream buffer.
Returns
The allocated size of the linked buffer in bytes.

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).

Parameters
[in]pHandleValid handle on a stream buffer.
Returns
The space available in this stream buffer in bytes.

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.

Parameters
[in]pHandleHandle on an allocated stream buffer.
[in]pLinkedBufferPointer on an allocated buffer to link with this stream.
[in]bufferSizeSize in bytes of the linked buffer.
Returns
SBG_NO_ERROR if the stream buffer has been initialized successfully.

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.

Parameters
[in]pHandleHandle on an allocated stream buffer.
[in]pLinkedBufferPointer on an allocated buffer to link with this stream.
[in]bufferSizeSize in bytes of the linked buffer.
Returns
SBG_NO_ERROR if the stream buffer has been initialized successfully.

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.

Parameters
[in]pHandleValid stream buffer handle that supports read operations.
[out]pBufferAllocated buffer used to hold read data.
[in]numBytesToReadNumber of bytes to read from the stream buffer and to store in pBuffer.
Returns
SBG_NO_ERROR if the data has been read.

Definition at line 541 of file sbgStreamBufferCommon.h.

SBG_INLINE int8 sbgStreamBufferReadInt8 ( SbgStreamBuffer pHandle)

Read an int8 from a stream buffer.

Parameters
[in]pHandleValid stream buffer handle that supports read operations.
Returns
The read value or 0 if we have an error.

Definition at line 455 of file sbgStreamBufferCommon.h.

SBG_INLINE uint8 sbgStreamBufferReadUint8 ( SbgStreamBuffer pHandle)

Read an uint8 from a stream buffer.

Parameters
[in]pHandleValid stream buffer handle that supports read operations.
Returns
The read value or 0 if we have an error.

Definition at line 497 of file sbgStreamBufferCommon.h.

SBG_INLINE SbgErrorCode sbgStreamBufferSeek ( SbgStreamBuffer pHandle,
size_t  offset,
SbgSBSeekOrigin  origin 
)

Move the current cursor position.

Parameters
[in]pHandleValid handle on a stream buffer.
[in]offsetOffset in bytes to apply (only positive).
[in]originOrigin reference point to apply the offset from.
Returns
SBG_NO_ERROR if the stream current cursor position has been moved.

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.

Parameters
[in]pHandleValid handle on a stream buffer.
Returns
Current offset in bytes from the beginning.

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.

Parameters
[in]pHandleValid stream buffer handle that supports write operations.
[out]pBufferBuffer to write into the stream buffer.
[in]numBytesToReadNumber of bytes to write to the stream buffer.
Returns
SBG_NO_ERROR if the data has been written.

Definition at line 672 of file sbgStreamBufferCommon.h.

SBG_INLINE SbgErrorCode sbgStreamBufferWriteInt8 ( SbgStreamBuffer pHandle,
int8  value 
)

Write an int8 into a stream buffer

Parameters
[in]pHandleValid stream buffer handle that supports write operations.
[in]valueThe value to write.
Returns
SBG_NO_ERROR if the value has been successfully written.

Definition at line 591 of file sbgStreamBufferCommon.h.

SBG_INLINE SbgErrorCode sbgStreamBufferWriteUint8 ( SbgStreamBuffer pHandle,
uint8  value 
)

Write an uint8 into a stream buffer

Parameters
[in]pHandleValid stream buffer handle that supports write operations.
[in]valueThe value to write.
Returns
SBG_NO_ERROR if the value has been successfully written.

Definition at line 631 of file sbgStreamBufferCommon.h.



sbg_driver
Author(s):
autogenerated on Sun Jan 27 2019 03:42:20