Back to home page

Enduro/X

 
 

    


0001 SYNOPSIS
0002 --------
0003 
0004 #include <ubf.h>
0005 
0006 int Baddfast (UBFH *p_ub, BFLDID bfldid, char *buf, BFLDLEN len, Bfld_loc_info_t *next_fld);
0007 
0008 int CBaddfast (UBFH *p_ub, BFLDID bfldid, char *buf, BFLDLEN len, int usrtype, Bfld_loc_info_t *next_fld);
0009 
0010 Link with '-lubf -lnstd -lm -lpthread'
0011 
0012 DESCRIPTION
0013 -----------
0014 Add field to UBF buffer. By difference to Badd, this function offers to add next
0015 occurrence of the field just right after the previous Baddfast function. So basically
0016 if batch of occurrences needs to be loaded to buffer or incrementing BFLDID of the
0017 same type needs to be added to the buffer in quick manner, then at first call
0018 provide 'next_fld' set to 0 (memset('next_fld', 0, sizeof('next_fld'))). Then first
0019 call will add data as normal *Badd()* call, but in result 'next_fld' will keep
0020 the pointer to last position of the buffer, just right after data inserted. Thus
0021 Next Baddfast() is performing from that place. The benefit is avoided position search
0022 in buffer, which at large number of occurrences might grow exponentially. Then
0023 'p_ub' buffer must not be modified between the calls. 'next_fld' is valid only
0024 for adding the same field occurrences or adding (when programmer knows for sure) 
0025 incremented field id. Function is beneficial for carray or string fields, 
0026 as on these types UBF does not perform binary search to get the position.
0027 
0028 The UBF buffer pointer is passed by 'p_ub', field id in 'bfldid'. 
0029 The user value is passed in 'buf'. The 'len' is used only if field type is 
0030 *BFLD_CARRAY*. The data type for 'buf' must match with 'bfldid' type.
0031 
0032 CBaddfast() version additionally supports data type conversion from provided
0033 'usrtype' which denotes the data type pointed by 'buf' and 'len'. Function operations
0034 on field types *BFLD_UBF* and *BFLD_VIEW* are not supported. 
0035 This includes type of 'bfldid' or 'usrtype' having any unsupported field types
0036 for this function.
0037 
0038 
0039 RETURN VALUE
0040 ------------
0041 On success, *Baddfast()* return zero; on error, -1 is returned, 
0042 with *Berror* set to indicate the error.
0043 
0044 ERRORS
0045 ------
0046 Note that *Bstrerror()* returns generic error message plus custom message 
0047 with debug info from last function call.
0048 
0049 *BEINVAL* 'next_fld' is NULL. *bfldid* is less than *bfldid* used in previous
0050 Baddfast() call.
0051 
0052 *BALIGNERR* Corrupted buffer or pointing to not aligned memory area.
0053 
0054 *BNOTFLD* Buffer not fielded, not correctly allocated or corrupted.
0055 
0056 *BNOSPACE* No space in buffer for string data.
0057 
0058 *BMALLOC* Failed to allocate type conversion buffer, for CBaddfast() only.
0059 
0060 *BEBADOP* Operation not supported (e.g. work with *BFLD_UBF* or *BFLD_VIEW* type fields),
0061 for CBaddfast() only.
0062 
0063 
0064 EXAMPLE
0065 -------
0066 See *ubftest/test_badd.c* for sample code.
0067 
0068 BUGS
0069 ----
0070 Report bugs to support@mavimax.com
0071 
0072 SEE ALSO
0073 --------
0074 *CBchg(3)* *Bdel(3)* *Badd(3)* *Bchg(3)* *CBadd(3)* *Badd(3)*
0075 
0076 COPYING
0077 -------
0078 (C) Mavimax, Ltd
0079