Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

WBXML Buffers
[WBXML Library]


Files

file  wbxml_buffers.c
 Generic Buffers Functions.

file  wbxml_buffers.h
 Generic Buffers Functions.


Defines

#define wbxml_buffer_create(a, b, c)   wbxml_mem_cleam(wbxml_buffer_create_real((const WB_UTINY *)a,b,c))
#define wbxml_buffer_create_from_cstr(a)   wbxml_buffer_create((const WB_UTINY *)a,WBXML_STRLEN(a),WBXML_STRLEN(a))
#define wbxml_buffer_append_data(a, b, c)   wbxml_buffer_append_data_real(a,(const WB_UTINY *)b,c)
#define wbxml_buffer_append_cstr(a, b)   wbxml_buffer_append_cstr_real(a,(const WB_UTINY *)b)
#define wbxml_buffer_split_words(a)   wbxml_mem_cleam(wbxml_buffer_split_words_real(a))

Functions

WBXMLBufferwbxml_buffer_create_real (const WB_UTINY *data, WB_ULONG len, WB_ULONG malloc_block)
 Create a Buffer.

void wbxml_buffer_destroy (WBXMLBuffer *buffer)
 Destroy a Buffer.

void wbxml_buffer_destroy_item (void *buff)
 Destroy a Buffer.

WBXMLBufferwbxml_buffer_duplicate (WBXMLBuffer *buff)
 Duplicate a Buffer.

unsigned int wbxml_buffer_len (WBXMLBuffer *buffer)
 Get data length of a buffer.

WB_BOOL wbxml_buffer_get_char (WBXMLBuffer *buff, WB_ULONG pos, WB_UTINY *result)
 Get a byte from a Buffer.

void wbxml_buffer_set_char (WBXMLBuffer *buff, WB_ULONG pos, WB_UTINY ch)
 Set a byte in a Buffer.

unsigned char * wbxml_buffer_get_cstr (WBXMLBuffer *buffer)
 Get pointer to internal buffer data.

WB_BOOL wbxml_buffer_insert (WBXMLBuffer *to, WBXMLBuffer *buff, WB_ULONG pos)
 Append a Buffer into another one.

WB_BOOL wbxml_buffer_insert_cstr (WBXMLBuffer *to, WB_UTINY *str, WB_ULONG pos)
 Append a C String into a WBXMLBuffer.

unsigned char wbxml_buffer_append (WBXMLBuffer *dest, WBXMLBuffer *buff)
 Append a Buffer to another Buffer.

WB_BOOL wbxml_buffer_append_data_real (WBXMLBuffer *buff, const WB_UTINY *data, WB_ULONG len)
 Append data to a Buffer.

WB_BOOL wbxml_buffer_append_cstr_real (WBXMLBuffer *buff, const WB_UTINY *data)
 Append a C String (NULL terminated) to a Buffer.

WB_BOOL wbxml_buffer_append_char (WBXMLBuffer *buff, WB_UTINY ch)
 Append a byte to a Buffer.

WB_BOOL wbxml_buffer_append_mb_uint_32 (WBXMLBuffer *buff, WB_ULONG value)
 Append a Multibyte Integer.

void wbxml_buffer_delete (WBXMLBuffer *buff, WB_ULONG pos, WB_ULONG len)
 Delete a range of Bytes in a Buffer.

void wbxml_buffer_shrink_blanks (WBXMLBuffer *buffer)
 Shrink all spaces in a Buffer.

void wbxml_buffer_strip_blanks (WBXMLBuffer *buffer)
 Remove whitespaces at beginning and end of a Buffer.

int wbxml_buffer_compare (WBXMLBuffer *buff1, WBXMLBuffer *buff2)
 Compare two Buffers.

WB_LONG wbxml_buffer_compare_cstr (WBXMLBuffer *buff, const WB_TINY *str)
 Compare a WBXML Buffer with a C String.

WBXMLListwbxml_buffer_split_words_real (WBXMLBuffer *buff)
 Split a Buffer into words at whitespace.

WB_BOOL wbxml_buffer_search_char (WBXMLBuffer *to, WB_UTINY ch, WB_ULONG pos, WB_ULONG *result)
 Search a char in Buffer.

WB_BOOL wbxml_buffer_search (WBXMLBuffer *to, WBXMLBuffer *search, WB_ULONG pos, WB_ULONG *result)
 Search a Buffer in another Buffer.

WB_BOOL wbxml_buffer_search_cstr (WBXMLBuffer *to, WB_UTINY *search, WB_ULONG pos, WB_ULONG *result)
 Search a C String in a WBXMLBuffer Buffer.

unsigned char wbxml_buffer_contains_only_whitespaces (WBXMLBuffer *buffer)
 Check if a buffer contains only Whitespaces.

void wbxml_buffer_hex_to_binary (WBXMLBuffer *buffer)
 Convert an Hexa buffer to Binary.

WB_BOOL wbxml_buffer_binary_to_hex (WBXMLBuffer *buffer, WB_BOOL uppercase)
 Convert an Binary buffer to Hexa.

void wbxml_buffer_remove_trailing_zeros (WBXMLBuffer **buffer)
 Remove trailing Zeros.


Define Documentation

#define wbxml_buffer_append_cstr a,
     wbxml_buffer_append_cstr_real(a,(const WB_UTINY *)b)
 

Wrapper around wbxml_buffer_append_cstr_real() to avoid Casts in code

Definition at line 170 of file wbxml_buffers.h.

Referenced by wbxml_tree_clb_xml_end_element().

#define wbxml_buffer_append_data a,
b,
     wbxml_buffer_append_data_real(a,(const WB_UTINY *)b,c)
 

Wrapper around wbxml_buffer_append_data_real() to avoid Casts in code

Definition at line 159 of file wbxml_buffers.h.

Referenced by wbxml_buffer_append(), wbxml_buffer_append_cstr_real(), and wbxml_buffer_append_mb_uint_32().

#define wbxml_buffer_create a,
b,
     wbxml_mem_cleam(wbxml_buffer_create_real((const WB_UTINY *)a,b,c))
 

Wrapper around wbxml_buffer_create_real() to track Memory

Definition at line 67 of file wbxml_buffers.h.

Referenced by wbxml_attribute_name_create_literal(), wbxml_buffer_split_words_real(), wbxml_encoder_encode_to_wbxml(), wbxml_encoder_encode_to_xml(), wbxml_parser_parse(), wbxml_tag_create_literal(), wbxml_tree_clb_xml_characters(), and wbxml_tree_clb_xml_end_element().

#define wbxml_buffer_create_from_cstr      wbxml_buffer_create((const WB_UTINY *)a,WBXML_STRLEN(a),WBXML_STRLEN(a))
 

Wrapper around wbxml_buffer_create() when creating buffer with a C String (NULL Terminated)

Definition at line 70 of file wbxml_buffers.h.

#define wbxml_buffer_split_words      wbxml_mem_cleam(wbxml_buffer_split_words_real(a))
 

Definition at line 233 of file wbxml_buffers.h.


Function Documentation

unsigned char wbxml_buffer_append WBXMLBuffer   dest,
WBXMLBuffer   buff
 

Append a Buffer to another Buffer.

Parameters:
dest The destination Buffer
buff The Buffer to append
Returns:
TRUE if buffer appended, FALSE otherwise

Definition at line 187 of file wbxml_buffers.c.

References FALSE, NULL, TRUE, WB_BOOL, wbxml_buffer_append_data, wbxml_buffer_get_cstr(), and wbxml_buffer_len().

WB_BOOL wbxml_buffer_append_char WBXMLBuffer   buff,
WB_UTINY    ch
 

Append a byte to a Buffer.

Parameters:
buff The Buffer
ch Byte to append
Returns:
TRUE if byte appended, FALSE otherwise

WB_BOOL wbxml_buffer_append_cstr_real WBXMLBuffer   buff,
const WB_UTINY *    data
 

Append a C String (NULL terminated) to a Buffer.

Parameters:
buff The Buffer
data String to append
Returns:
TRUE if data appended, FALSE otherwise

WB_BOOL wbxml_buffer_append_data_real WBXMLBuffer   buff,
const WB_UTINY *    data,
WB_ULONG    len
 

Append data to a Buffer.

Parameters:
buff The Buffer
data Data to append
len Data length
Returns:
TRUE if data appended, FALSE otherwise

WB_BOOL wbxml_buffer_append_mb_uint_32 WBXMLBuffer   buff,
WB_ULONG    value
 

Append a Multibyte Integer.

Parameters:
buff The Buffer
value The value to append
Returns:
TRUE if value appended, FALSE otherwise

WB_BOOL wbxml_buffer_binary_to_hex WBXMLBuffer   buffer,
WB_BOOL    uppercase
 

Convert an Binary buffer to Hexa.

Parameters:
buffer The buffer to convert
uppercase Do we convert to Uppercase Hexa ?
Returns:
TRUE if converted, FALSE otherwise

int wbxml_buffer_compare WBXMLBuffer   buff1,
WBXMLBuffer   buff2
 

Compare two Buffers.

Parameters:
buff1 
buff2 
Returns:
0 if they are equal, negative if `buff1' is less than `buff2' and positive if greater

Definition at line 332 of file wbxml_buffers.c.

References WBXMLBuffer_s::data, WBXMLBuffer_s::len, NULL, and WB_LONG.

WB_LONG wbxml_buffer_compare_cstr WBXMLBuffer   buff,
const WB_TINY *    str
 

Compare a WBXML Buffer with a C String.

Parameters:
buff The WBXML Buffer
str The C String
Returns:
0 if they are equal, negative if `buff' is less than `str' and positive if greater

unsigned char wbxml_buffer_contains_only_whitespaces WBXMLBuffer   buffer
 

Check if a buffer contains only Whitespaces.

Parameters:
buffer The buffer to check
Returns:
TRUE if it contains only whitespaces, FALSE otherwise

Definition at line 557 of file wbxml_buffers.c.

References WBXMLBuffer_s::data, FALSE, WBXMLBuffer_s::len, NULL, TRUE, WB_BOOL, and WB_ULONG.

WBXMLBuffer* wbxml_buffer_create_real const WB_UTINY *    data,
WB_ULONG    len,
WB_ULONG    malloc_block
 

Create a Buffer.

Parameters:
data The initial data for buffer
len Size of data
malloc_block Size of malloc blocks (tune this parameter to avoid too many rallocations)
Returns:
The newly created Buffer, or NULL if not enought memory
Warning:
Do NOT use this function directly, use wbxml_buffer_create() macro instead

Referenced by wbxml_buffer_duplicate(), and wbxml_tree_clb_wbxml_characters().

void wbxml_buffer_delete WBXMLBuffer   buff,
WB_ULONG    pos,
WB_ULONG    len
 

Delete a range of Bytes in a Buffer.

Parameters:
buff The Buffer
pos Position where to start deletion
len Number of bytes to delete

Referenced by wbxml_buffer_remove_trailing_zeros(), wbxml_buffer_shrink_blanks(), and wbxml_buffer_strip_blanks().

void wbxml_buffer_destroy WBXMLBuffer   buff
 

Destroy a Buffer.

Parameters:
buff The Buffer to destroy

Definition at line 104 of file wbxml_buffers.c.

References WBXMLBuffer_s::data, NULL, and wbxml_free().

Referenced by wbxml_attribute_destroy(), wbxml_attribute_name_destroy(), wbxml_buffer_destroy_item(), wbxml_encoder_destroy(), wbxml_parser_destroy(), wbxml_tag_destroy(), wbxml_tree_clb_xml_end_element(), and wbxml_tree_node_destroy().

void wbxml_buffer_destroy_item void *    buff
 

Destroy a Buffer.

Parameters:
buff The Buffer to destroy

Definition at line 113 of file wbxml_buffers.c.

References wbxml_buffer_destroy().

Referenced by wbxml_buffer_split_words_real().

WBXMLBuffer* wbxml_buffer_duplicate WBXMLBuffer   buff
 

Duplicate a Buffer.

Parameters:
buff The Buffer to duplicate
Returns:
The duplicated buffer, or NULL if not enough memory

Definition at line 119 of file wbxml_buffers.c.

References NULL, wbxml_buffer_create_real(), wbxml_buffer_get_cstr(), and wbxml_buffer_len().

Referenced by wbxml_attribute_duplicate(), wbxml_attribute_name_duplicate(), and wbxml_tag_duplicate().

WB_BOOL wbxml_buffer_get_char WBXMLBuffer   buff,
WB_ULONG    pos,
WB_UTINY *    result
 

Get a byte from a Buffer.

Parameters:
buff The Buffer
pos Byte position in buffer
result The resulting char
Returns:
TRUE if OK, or FALSE if error

Referenced by wbxml_buffer_remove_trailing_zeros(), wbxml_buffer_shrink_blanks(), and wbxml_buffer_strip_blanks().

unsigned char* wbxml_buffer_get_cstr WBXMLBuffer   buff
 

Get pointer to internal buffer data.

Parameters:
buff The Buffer
Returns:
Pointer to buffer data, or "" if buffer is NULL or empty

Definition at line 160 of file wbxml_buffers.c.

References WBXMLBuffer_s::data, WBXMLBuffer_s::len, NULL, WB_UTINY, and WBXML_UTINY_NULL_STRING.

Referenced by wbxml_attribute_get_xml_value(), wbxml_attribute_name_get_xml_name(), wbxml_buffer_append(), wbxml_buffer_duplicate(), wbxml_tag_get_xml_name(), and wbxml_tree_clb_xml_end_element().

void wbxml_buffer_hex_to_binary WBXMLBuffer   buffer
 

Convert an Hexa buffer to Binary.

Parameters:
buffer The buffer to convert

Definition at line 573 of file wbxml_buffers.c.

References WBXMLBuffer_s::data, WBXMLBuffer_s::len, NULL, WB_ULONG, WB_UTINY, and wbxml_buffer_len().

WB_BOOL wbxml_buffer_insert WBXMLBuffer   to,
WBXMLBuffer   buff,
WB_ULONG    pos
 

Append a Buffer into another one.

Parameters:
to The Buffer to modify
buff The Buffer to insert
pos The position of insertion in 'to'
Returns:
TRUE if data inserted, FALSE otherwise

WB_BOOL wbxml_buffer_insert_cstr WBXMLBuffer   to,
WB_UTINY *    str,
WB_ULONG    pos
 

Append a C String into a WBXMLBuffer.

Parameters:
to The Buffer to modify
str The BC String to insert
pos The position of insertion in 'to'
Returns:
TRUE if data inserted, FALSE otherwise

unsigned int wbxml_buffer_len WBXMLBuffer   buff
 

Get data length of a buffer.

Parameters:
buff The Buffer
Returns:
The Buffer data length

Definition at line 134 of file wbxml_buffers.c.

References WBXMLBuffer_s::len, NULL, and WB_ULONG.

Referenced by wbxml_buffer_append(), wbxml_buffer_binary_to_hex(), wbxml_buffer_duplicate(), wbxml_buffer_hex_to_binary(), wbxml_buffer_remove_trailing_zeros(), wbxml_buffer_shrink_blanks(), and wbxml_buffer_strip_blanks().

void wbxml_buffer_remove_trailing_zeros WBXMLBuffer **    buffer
 

Remove trailing Zeros.

Parameters:
buffer The buffer

Definition at line 641 of file wbxml_buffers.c.

References NULL, WB_UTINY, wbxml_buffer_delete(), wbxml_buffer_get_char(), and wbxml_buffer_len().

WB_BOOL wbxml_buffer_search WBXMLBuffer   to,
WBXMLBuffer   search,
WB_ULONG    pos,
WB_ULONG *    result
 

Search a Buffer in another Buffer.

Parameters:
to The buffer to search into
search The buffer to search
pos Position to start searching in 'to' buffer
result The start position of 'search' buffer in 'to' buffer
Returns:
TRUE if successfully found 'search' in 'to' buffer, FALSE otherwise

WB_BOOL wbxml_buffer_search_char WBXMLBuffer   to,
WB_UTINY    ch,
WB_ULONG    pos,
WB_ULONG *    result
 

Search a char in Buffer.

Parameters:
to The buffer to search into
ch The char to search
pos Position to start searching in 'to' buffer
result The start position of char in 'to' buffer
Returns:
TRUE if char successfully found in 'to' buffer, FALSE otherwise

Referenced by wbxml_buffer_search(), and wbxml_buffer_search_cstr().

WB_BOOL wbxml_buffer_search_cstr WBXMLBuffer   to,
WB_UTINY *    search,
WB_ULONG    pos,
WB_ULONG *    result
 

Search a C String in a WBXMLBuffer Buffer.

Parameters:
to The buffer to search into
search The C String to search
pos Position to start searching in 'to' buffer
result The start position of 'search' buffer in 'to' buffer
Returns:
TRUE if successfully found 'search' in 'to' buffer, FALSE otherwise

void wbxml_buffer_set_char WBXMLBuffer   buff,
WB_ULONG    pos,
WB_UTINY    ch
 

Set a byte in a Buffer.

Parameters:
buff The Buffer
pos Byte position in buffer
ch The character to set

Referenced by wbxml_buffer_shrink_blanks().

void wbxml_buffer_shrink_blanks WBXMLBuffer   buff
 

Shrink all spaces in a Buffer.

Parameters:
buff The Buffer to shrink
Note:
Replace every consecutive sequence of spaces into one unique whitespace

Definition at line 272 of file wbxml_buffers.c.

References NULL, WB_ULONG, WB_UTINY, wbxml_buffer_delete(), wbxml_buffer_get_char(), wbxml_buffer_len(), and wbxml_buffer_set_char().

WBXMLList* wbxml_buffer_split_words_real WBXMLBuffer   buff
 

Split a Buffer into words at whitespace.

Parameters:
buff The buffer to split
Returns:
The List of splitted Words, or NULL if not enought memory
Warning:
Do NOT use this function directly, use wbxml_buffer_split_words() macro instead

Definition at line 416 of file wbxml_buffers.c.

References WBXMLBuffer_s::data, WBXMLBuffer_s::len, NULL, WB_ULONG, WB_UTINY, wbxml_buffer_create, wbxml_buffer_destroy_item(), WBXML_BUFFER_SPLIT_BLOCK, wbxml_list_append(), wbxml_list_create, and wbxml_list_destroy().

void wbxml_buffer_strip_blanks WBXMLBuffer   buff
 

Remove whitespaces at beginning and end of a Buffer.

Parameters:
buff The Buffer to strip

Definition at line 302 of file wbxml_buffers.c.

References WB_ULONG, WB_UTINY, wbxml_buffer_delete(), wbxml_buffer_get_char(), and wbxml_buffer_len().


Generated on Mon Nov 24 20:09:48 2003 for WBXML Library by doxygen1.3-rc1