All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kzc_byte_buffer.h File Reference

Byte buffer provides functionality for reading/writing arbitrary data from/to a chunk of memory. More...

Classes

struct  KzcByteBufferState_private
 State of both read and write byte buffers. More...
 
struct  KzcByteReadBuffer
 Structure for a readable byte buffer. More...
 
struct  KzcByteReadBackwardsBuffer
 Structure for a readable byte buffer in backwards direction. More...
 
struct  KzcByteWriteBuffer
 Structure for a writable byte buffer. More...
 
struct  KzcByteWriteBackwardsBuffer
 Structure for a writable byte buffer in backwards direction. More...
 

Macros

#define kzcByteBufferRead(buffer_param, value_param)
 Read arbitrary type from the given buffer. More...
 
#define kzcByteBufferBackwardsRead(buffer_param, value_param)
 Read arbitrary type from the given backwards buffer. More...
 
#define kzcByteBufferWrite(buffer_param, value_param)
 Write arbitrary type to the given buffer. More...
 
#define kzcByteBufferBackwardsWrite(buffer_param, value_param)
 Write arbitrary type to the given backwards buffer. More...
 
#define kzcByteBufferReset(buffer_param)
 Reset the buffer offset back to zero. More...
 
#define kzcByteBufferSkip(buffer_param, offset_param)
 Skip given amount of bytes in the buffer. More...
 
#define kzcByteBufferGetOffset(buffer_param)
 Get the current offset in the buffer. More...
 
#define kzcByteBufferSetOffset(buffer_param, offset_param)
 Set the current offset in the buffer. More...
 
#define kzcByteBufferIsFinished(buffer_param)
 Check if the buffer has been read or written completely. More...
 

Functions

KZ_INLINE void kzcByteBufferInitialize_private (struct KzcByteBufferState_private *buffer, kzSizeT size)
 Initializes a byte buffer with given parameters. More...
 
KZ_INLINE void kzcByteBufferInitializeRead (struct KzcByteReadBuffer *buffer, const void *pointer, kzSizeT size)
 Initializes a readable byte buffer pointing to the given buffer of given size. More...
 
KZ_INLINE void kzcByteBufferInitializeBackwardsRead (struct KzcByteReadBackwardsBuffer *buffer, const void *pointer, kzSizeT size)
 Initializes a readable byte buffer for backwards direction ending at the given pointer. More...
 
KZ_INLINE void kzcByteBufferInitializeWrite (struct KzcByteWriteBuffer *buffer, void *pointer, kzSizeT size)
 Initializes a writable byte buffer pointing to the given buffer of given size. More...
 
KZ_INLINE void kzcByteBufferInitializeBackwardsWrite (struct KzcByteWriteBackwardsBuffer *buffer, void *pointer, kzSizeT size)
 Initializes a reverse ordered writable byte buffer ending at the given pointer. More...
 
KZ_INLINE void kzcByteBufferRead_private (struct KzcByteReadBuffer *buffer, kzSizeT size, void *out_value)
 
KZ_INLINE void kzcByteBufferBackwardsRead_private (struct KzcByteReadBackwardsBuffer *buffer, kzSizeT size, void *out_value)
 
KZ_INLINE void kzcByteBufferWrite_private (struct KzcByteWriteBuffer *buffer, kzSizeT size, const void *value)
 
KZ_INLINE void kzcByteBufferBackwardsWrite_private (struct KzcByteWriteBackwardsBuffer *buffer, kzSizeT size, const void *value)
 
KZ_INLINE const void * kzcByteBufferAllocateReadPointer (struct KzcByteReadBuffer *buffer, kzSizeT size)
 Allocate a chunk of read-only memory of given size from the given buffer. More...
 
KZ_INLINE const void * kzcByteBufferBackwardsAllocateReadPointer (struct KzcByteReadBackwardsBuffer *buffer, kzSizeT size)
 Allocate a chunk of read-only memory of given size from the given buffer. More...
 
KZ_INLINE void * kzcByteBufferAllocateWritePointer (struct KzcByteWriteBuffer *buffer, kzSizeT size)
 Allocate a chunk of memory of given size from the given buffer. More...
 
KZ_INLINE void * kzcByteBufferBackwardsAllocateWritePointer (struct KzcByteWriteBackwardsBuffer *buffer, kzSizeT size)
 Allocate a chunk of memory of given size from the given buffer. More...
 
KZ_INLINE void kzcByteBufferReset_private (struct KzcByteBufferState_private *buffer)
 
KZ_INLINE void kzcByteBufferSkip_private (struct KzcByteBufferState_private *buffer, kzSizeT offset)
 
KZ_INLINE kzUint kzcByteBufferGetOffset_private (const struct KzcByteBufferState_private *buffer)
 
KZ_INLINE void kzcByteBufferSetOffset_private (struct KzcByteBufferState_private *buffer, kzSizeT offset)
 
KZ_INLINE kzBool kzcByteBufferIsFinished_private (const struct KzcByteBufferState_private *buffer)
 

Detailed Description

Byte buffer provides functionality for reading/writing arbitrary data from/to a chunk of memory.

Every function is guarded with bounds checking to prevent accidental out of bounds access. Read buffer differs from write buffer in that the memory for it is write-protected (const). Bounds checking is done with assertions.

Copyright 2008-2020 by Rightware. All rights reserved.

Macro Definition Documentation

#define kzcByteBufferRead (   buffer_param,
  value_param 
)

Read arbitrary type from the given buffer.

The size of the type is taken automatically.

#define kzcByteBufferBackwardsRead (   buffer_param,
  value_param 
)

Read arbitrary type from the given backwards buffer.

The size of the type is taken automatically.

#define kzcByteBufferWrite (   buffer_param,
  value_param 
)

Write arbitrary type to the given buffer.

The size of the type is taken automatically.

#define kzcByteBufferBackwardsWrite (   buffer_param,
  value_param 
)

Write arbitrary type to the given backwards buffer.

The size of the type is taken automatically.

#define kzcByteBufferReset (   buffer_param)

Reset the buffer offset back to zero.

#define kzcByteBufferSkip (   buffer_param,
  offset_param 
)

Skip given amount of bytes in the buffer.

#define kzcByteBufferGetOffset (   buffer_param)

Get the current offset in the buffer.

#define kzcByteBufferSetOffset (   buffer_param,
  offset_param 
)

Set the current offset in the buffer.

#define kzcByteBufferIsFinished (   buffer_param)

Check if the buffer has been read or written completely.

Function Documentation

KZ_INLINE void kzcByteBufferInitialize_private ( struct KzcByteBufferState_private buffer,
kzSizeT  size 
)

Initializes a byte buffer with given parameters.

KZ_INLINE void kzcByteBufferInitializeRead ( struct KzcByteReadBuffer buffer,
const void *  pointer,
kzSizeT  size 
)

Initializes a readable byte buffer pointing to the given buffer of given size.

KZ_INLINE void kzcByteBufferInitializeBackwardsRead ( struct KzcByteReadBackwardsBuffer buffer,
const void *  pointer,
kzSizeT  size 
)

Initializes a readable byte buffer for backwards direction ending at the given pointer.

KZ_INLINE void kzcByteBufferInitializeWrite ( struct KzcByteWriteBuffer buffer,
void *  pointer,
kzSizeT  size 
)

Initializes a writable byte buffer pointing to the given buffer of given size.

KZ_INLINE void kzcByteBufferInitializeBackwardsWrite ( struct KzcByteWriteBackwardsBuffer buffer,
void *  pointer,
kzSizeT  size 
)

Initializes a reverse ordered writable byte buffer ending at the given pointer.

KZ_INLINE void kzcByteBufferRead_private ( struct KzcByteReadBuffer buffer,
kzSizeT  size,
void *  out_value 
)
KZ_INLINE void kzcByteBufferBackwardsRead_private ( struct KzcByteReadBackwardsBuffer buffer,
kzSizeT  size,
void *  out_value 
)
KZ_INLINE void kzcByteBufferWrite_private ( struct KzcByteWriteBuffer buffer,
kzSizeT  size,
const void *  value 
)
KZ_INLINE void kzcByteBufferBackwardsWrite_private ( struct KzcByteWriteBackwardsBuffer buffer,
kzSizeT  size,
const void *  value 
)
KZ_INLINE const void* kzcByteBufferAllocateReadPointer ( struct KzcByteReadBuffer buffer,
kzSizeT  size 
)

Allocate a chunk of read-only memory of given size from the given buffer.

KZ_INLINE const void* kzcByteBufferBackwardsAllocateReadPointer ( struct KzcByteReadBackwardsBuffer buffer,
kzSizeT  size 
)

Allocate a chunk of read-only memory of given size from the given buffer.

KZ_INLINE void* kzcByteBufferAllocateWritePointer ( struct KzcByteWriteBuffer buffer,
kzSizeT  size 
)

Allocate a chunk of memory of given size from the given buffer.

KZ_INLINE void* kzcByteBufferBackwardsAllocateWritePointer ( struct KzcByteWriteBackwardsBuffer buffer,
kzSizeT  size 
)

Allocate a chunk of memory of given size from the given buffer.

KZ_INLINE void kzcByteBufferReset_private ( struct KzcByteBufferState_private buffer)
KZ_INLINE void kzcByteBufferSkip_private ( struct KzcByteBufferState_private buffer,
kzSizeT  offset 
)
KZ_INLINE kzUint kzcByteBufferGetOffset_private ( const struct KzcByteBufferState_private buffer)
KZ_INLINE void kzcByteBufferSetOffset_private ( struct KzcByteBufferState_private buffer,
kzSizeT  offset 
)
KZ_INLINE kzBool kzcByteBufferIsFinished_private ( const struct KzcByteBufferState_private buffer)