Boron 2.1.0
Datatype Binary

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

◆ ur_binAppendArray()

void ur_binAppendArray ( UBuffer * buf,
const USeriesIter * si )

Append array slice to binary buffer.

Parameters
bufInitialized binary buffer.
siData to append. si.buf->elemSize must be valid.

◆ ur_binAppendBase()

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

Append encoded ASCII string to binary buffer.

Parameters
bufInitialized binary buffer.
itStart of string
endEnd of string
encEncoding of string.
Returns
End of string or position where non-hex or non-whitespace character was found.

◆ ur_binAppendData()

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

Append data to binary buffer.

Parameters
bufInitialized binary buffer.
dataData to append.
lenNumber of bytes from data to append.

◆ ur_binErase()

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

Remove bytes from the binary.

Parameters
bufInitialized binary buffer.
startStart index of erase.
countNumber of bytes to remove.

◆ ur_binExpand()

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
bufInitialized binary buffer.
indexPosition to expand at.
countNumber of bytes to expand.

◆ ur_binFree()

void ur_binFree ( UBuffer * buf)

Free binary data.

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

◆ ur_binInit()

void ur_binInit ( UBuffer * buf,
int size )

Initialize buffer to type UT_BINARY.

Parameters
sizeNumber of bytes to reserve.

◆ ur_binReserve()

void ur_binReserve ( UBuffer * buf,
int size )

Allocates enough memory to hold size bytes.

buf->used is not changed.

Parameters
bufInitialized binary buffer.
sizeTotal number of bytes.

◆ ur_binSlice()

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

Set UBinaryIter to binary slice.

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

◆ ur_binSliceM()

UStatus 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
biIterator struct to fill.
cellPointer to a valid binary cell.
Returns
UR_OK/UR_THROW

◆ ur_binToStr()

void ur_binToStr ( UBuffer * buf,
int encoding )

Convert binary buffer to string buffer.

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

Parameters
bufInitialized binary buffer.
encodingEncoding

◆ ur_makeBinary()

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
sizeNumber of bytes to reserve.
Returns
Buffer id of binary.

◆ ur_makeBinaryCell()

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
sizeNumber of bytes to reserve.
cellCell to initialize.
Returns
Pointer to binary buffer.