User Tools

Site Tools


Sidebar

Table Of Contents

endurox:v8.0.x:api:ubf:cbaddfast.3

cbaddfast

Name

CBaddfast — Fast adding to buffer with type convert

Synopsis

#include <ubf.h>

int Baddfast (UBFH *p_ub, BFLDID bfldid, char *buf, BFLDLEN len, Bfld_loc_info_t *next_fld);

int CBaddfast (UBFH *p_ub, BFLDID bfldid, char *buf, BFLDLEN len, int usrtype, Bfld_loc_info_t *next_fld);

Link with -lubf -lnstd -lm -lpthread

DESCRIPTION

Add field to UBF buffer. By difference to Badd, this function offers to add next occurrence of the field just right after the previous Baddfast function. So basically if batch of occurrences needs to be loaded to buffer or incrementing BFLDID of the same type needs to be added to the buffer in quick manner, then at first call provide next_fld set to 0 (memset(next_fld, 0, sizeof(next_fld))). Then first call will add data as normal Badd() call, but in result next_fld will keep the pointer to last position of the buffer, just right after data inserted. Thus Next Baddfast() is performing from that place. The benefit is avoided position search in buffer, which at large number of occurrences might grow exponentially. Then p_ub buffer must not be modified between the calls. next_fld is valid only for adding the same field occurrences or adding (when programmer knows for sure) incremented field id. Function is beneficial for carray or string fields, as on these types UBF does not perform binary search to get the position.

The UBF buffer pointer is passed by p_ub, field id in bfldid. The user value is passed in buf. The len is used only if field type is BFLD_CARRAY. The data type for buf must match with bfldid type.

CBaddfast() version additionally supports data type conversion from provided usrtype which denotes the data type pointed by buf and len. Function operations on field types BFLD_UBF and BFLD_VIEW are not supported. This includes type of bfldid or usrtype having any unsupported field types for this function.

RETURN VALUE

On success, Baddfast() return zero; on error, -1 is returned, with Berror set to indicate the error.

ERRORS

Note that Bstrerror() returns generic error message plus custom message with debug info from last function call.

BEINVAL next_fld is NULL. bfldid is less than bfldid used in previous Baddfast() call.

BALIGNERR Corrupted buffer or pointing to not aligned memory area.

BNOTFLD Buffer not fielded, not correctly allocated or corrupted.

BNOSPACE No space in buffer for string data.

BMALLOC Failed to allocate type conversion buffer, for CBaddfast() only.

BEBADOP Operation not supported (e.g. work with BFLD_UBF or BFLD_VIEW type fields), for CBaddfast() only.

EXAMPLE

See ubftest/test_badd.c for sample code.

BUGS

Report bugs to support@mavimax.com

COPYING

© Mavimax, Ltd