Coconut Framework  beta
Classes | Functions
CNBuffer.h File Reference

Define CNBuffer data structure. More...

#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Classes

struct  CNBuffer
 Write buffer to store variable-sized continuous data. More...
 

Functions

static size_t CNCalcSizeOfBuffer (size_t size)
 Calc memory size of CNBuffer. More...
 
static void CNInitBuffer (struct CNBuffer *dst)
 Initialize CNBuffer object. More...
 
static void CNDestroyBuffer (struct CNBuffer *dst)
 Destroy the context of CNBuffer. More...
 
static void CNResetBuffer (struct CNBuffer *dst)
 Make the buffer empty. More...
 
static void * CNDetachDataFromBuffer (struct CNBuffer *dst)
 Detach context from the buffer. More...
 
static size_t CNSizeOfBuffer (const struct CNBuffer *src)
 Get the size of valid data in CNBuffer. More...
 
static const void * CNContextOfBuffer (const struct CNBuffer *src)
 Get the context of CNBuffer. More...
 
static void CNPutBytesToBuffer (struct CNBuffer *dst, size_t srcsize, const void *srcptr)
 Write byte data into the buffer. More...
 

Detailed Description

Define CNBuffer data structure.

Copyright
Copyright (C) 2012 Steel Wheels Project

Function Documentation

static size_t CNCalcSizeOfBuffer ( size_t  size)
inlinestatic

Calc memory size of CNBuffer.

Returns
Size of memory
Parameters
sizeSource data size
Note
This function is designed to be called by the other functions to operate CNBuffer. You don't have to call this directory.

Referenced by CNInitBuffer(), and CNPutBytesToBuffer().

static void CNInitBuffer ( struct CNBuffer dst)
inlinestatic

Initialize CNBuffer object.

Parameters
dstDestination buffer object

References CNCalcSizeOfBuffer(), CNBuffer::context, CNBuffer::currentSize, and CNBuffer::writePosition.

static void CNDestroyBuffer ( struct CNBuffer dst)
inlinestatic

Destroy the context of CNBuffer.

Parameters
dstDestination buffer object

References CNBuffer::context.

static void CNResetBuffer ( struct CNBuffer dst)
inlinestatic

Make the buffer empty.

Parameters
dstDestination buffer object

References CNBuffer::writePosition.

static void* CNDetachDataFromBuffer ( struct CNBuffer dst)
inlinestatic

Detach context from the buffer.

Returns
Detached data. You have to free() this data after calling this function.
Parameters
dstDestination buffer
Warning
After calling this routine, do NOT USE the destination buffer because it will have no values.

References CNBuffer::context, CNBuffer::currentSize, and CNBuffer::writePosition.

static size_t CNSizeOfBuffer ( const struct CNBuffer src)
inlinestatic

Get the size of valid data in CNBuffer.

Returns
Size of valid data
Parameters
srcSource buffer

References CNBuffer::writePosition.

static const void* CNContextOfBuffer ( const struct CNBuffer src)
inlinestatic

Get the context of CNBuffer.

Returns
Pointer for the context
Parameters
srcSource buffer

References CNBuffer::context.

static void CNPutBytesToBuffer ( struct CNBuffer dst,
size_t  srcsize,
const void *  srcptr 
)
inlinestatic

Write byte data into the buffer.

Parameters
dstDestination buffer
srcsizeSize of source data
srcptrPointer of source data

References CNCalcSizeOfBuffer(), CNBuffer::context, CNBuffer::currentSize, and CNBuffer::writePosition.

Referenced by CNPutFixedStringToText(), and CNPutUTF8StringToText().