Boron 0.1.0

Datatype Binary
[Urlan Datatype System]

The binary datatype is a series of bytes. More...

Functions

UIndex ur_makeBinary (UThread *ut, int size)
 Generate and initialize a single binary buffer.
UBufferur_makeBinaryCell (UThread *ut, int size, UCell *cell)
 Generate a single binary and set cell to reference it.
void ur_binInit (UBuffer *buf, int size)
 Initialize buffer to type UT_BINARY.
void ur_binFree (UBuffer *buf)
 Free binary data.
void ur_binReserve (UBuffer *buf, int size)
 Allocates enough memory to hold size bytes.
void ur_binErase (UBuffer *buf, int start, int count)
 Remove bytes from the binary.
void ur_binExpand (UBuffer *buf, int index, int count)
 Create space in the binary for count bytes starting at index.
void ur_binAppendData (UBuffer *buf, const uint8_t *data, int len)
 Append data to binary buffer.
void ur_binAppendArray (UBuffer *buf, const USeriesIter *si)
 Append array slice to binary buffer.
const char * ur_binAppendBase (UBuffer *buf, const char *it, const char *end, enum UrlanBinaryEncoding enc)
 Append encoded ASCII string to binary buffer.
void ur_binSlice (UThread *ut, UBinaryIter *bi, const UCell *cell)
 Set UBinaryIter to binary slice.
int ur_binSliceM (UThread *ut, UBinaryIterM *bi, const UCell *cell)
 Set UBinaryIterM to binary slice.
void ur_binToStr (UBuffer *buf, int encoding)
 Convert binary buffer to string buffer.

Detailed Description

The binary datatype is a series of bytes.


Function Documentation

void ur_binAppendArray ( UBuffer buf,
const USeriesIter *  si 
)

Append array slice to binary buffer.

Parameters:
buf Initialized binary buffer.
si Data to append. si.buf->elemSize must be valid.

const char* ur_binAppendBase ( UBuffer buf,
const char *  it,
const char *  end,
enum UrlanBinaryEncoding  enc 
)

Append encoded ASCII string to binary buffer.

Parameters:
buf Initialized binary buffer.
it Start of string
end End of string
enc Encoding of string.
Returns:
End of string or position where non-hex or non-whitespace character was found.

void ur_binAppendData ( UBuffer buf,
const uint8_t *  data,
int  len 
)

Append data to binary buffer.

Parameters:
buf Initialized binary buffer.
data Data to append.
len Number of bytes from data to append.

void ur_binErase ( UBuffer buf,
int  start,
int  count 
)

Remove bytes from the binary.

Parameters:
buf Initialized binary buffer.
start Start index of erase.
count Number of bytes to remove.

void ur_binExpand ( UBuffer buf,
int  index,
int  count 
)

Create space in the binary for count bytes starting at index.

The memory in the new space is uninitialized.

Parameters:
buf Initialized binary buffer.
index Position to expand at.
count Number of bytes to expand.

void ur_binFree ( UBuffer buf  ) 

Free binary data.

buf->ptr and buf->used are set to zero.

void ur_binInit ( UBuffer buf,
int  size 
)

Initialize buffer to type UT_BINARY.

Parameters:
size Number of bytes to reserve.

void ur_binReserve ( UBuffer buf,
int  size 
)

Allocates enough memory to hold size bytes.

buf->used is not changed.

Parameters:
buf Initialized binary buffer.
size Total number of bytes.

void ur_binSlice ( UThread ut,
UBinaryIter *  bi,
const UCell cell 
)

Set UBinaryIter to binary slice.

Parameters:
bi Iterator struct to fill.
cell Pointer to a valid binary cell.
Returns:
Initializes bi. If slice is empty then bi->it and bi->end are set to zero.

int ur_binSliceM ( UThread ut,
UBinaryIterM *  bi,
const UCell cell 
)

Set UBinaryIterM to binary slice.

If cell references a binary in shared storage then an error is generated and UR_THROW is returned. Otherwise, bi is initialized. If the slice is empty then bi->it and bi->end are set to zero.

Parameters:
bi Iterator struct to fill.
cell Pointer to a valid binary cell.
Returns:
UR_OK/UR_THROW

void ur_binToStr ( UBuffer buf,
int  encoding 
)

Convert binary buffer to string buffer.

The data that buf->ptr points to is not touched.

Parameters:
buf Initialized binary buffer.
encoding Encoding

UIndex ur_makeBinary ( UThread ut,
int  size 
)

Generate and initialize a single binary buffer.

If you need multiple buffers then ur_genBuffers() should be used.

The caller must create a UCell for this block in a held block before the next ur_recycle() or else it will be garbage collected.

Parameters:
size Number of bytes to reserve.
Returns:
Buffer id of binary.

UBuffer* ur_makeBinaryCell ( UThread ut,
int  size,
UCell cell 
)

Generate a single binary and set cell to reference it.

If you need multiple buffers then ur_genBuffers() should be used.

Parameters:
size Number of bytes to reserve.
cell Cell to initialize.
Returns:
Pointer to binary buffer.


Generated on 27 Jan 2012 by Doxygen 1.5.1