Symisc Systems

Libcox C/C++ API Reference - Populating Libcox Values


Star Follow @symisc

Syntax

int libcox_value_int(libcox_value *pVal,int iValue);

int libcox_value_int64(libcox_value *pVal,libcox_int64 iValue);

int libcox_value_bool(libcox_value *pVal,int iBool);

int libcox_value_null(libcox_value *pVal);

int libcox_value_double(libcox_value *pVal,double Value);

int libcox_value_string(libcox_value *pVal,const char *zString,int nLen);

int libcox_value_string_format(libcox_value *pVal,const char *zFormat,...);

int libcox_value_reset_string_cursor(libcox_value *pVal);


Populate a Libcox Object Value

Description

These routines are used to populate a freshly created libcox object value obtained by a prior successful call to libcox_context_new_scalar() or libcox_context_new_scalar().

The libcox_value_int() interface sets the libcox_value to the integer type where the value is specified by its 2nd argument.

The libcox_value_int64() interface sets the libcox_value to the 64-bit integer type where the value is specified by its 2nd argument.

The libcox_value_double() interface sets the libcox_value to the double type where the value is specified by its 2nd argument.

The libcox_value_bool() interface sets the libcox_value to the boolean type where the value (Only zero is assumed to be FALSE) is specified by its 2nd argument.

The libcox_value_null() interface sets the libcox_value to the NULL type.

The libcox_value_string() interface sets the libcox_value to the string type where the string content is specified by the 2nd argument.

Note that libcox_value_string() accepts a third argument which is the length of the string to append. If the nLen argument is less than zero, then zString is read up to the first zero terminator. If nLen is non-negative, then it is the maximum number of bytes read from zString.

libcox_value_string_format() is a work-alike of the "printf()" family of functions from the standard C library which is used to append a formatted string.

The libcox_value_string() and libcox_value_string_format() interfaces write their result to an internal buffer which grow automatically by successive calls to one of them (An append operation). That is, previously written data is not erased by the new call. If such behavior is wanted, call libcox_value_reset_string_cursor() to reset the internal buffer.

Note: If these routines are called from within the different thread than the one containing the application-defined function that received the libcox_value pointer, the results are undefined.


Parameters

pVal

A pointer to a libcox_value to be populated.


Return value

LIBCOX_OK is returned on success. Any other return value indicates failure.


See also

Obtaining Libcox Object Values, Libcox Object Values Type, On Demand Object Allocation, Setting the Result of a Foreign Command.