Babeltrace 2 C API  2.0.0
Open-source trace manipulation framework
Values

Detailed Description

Generic, JSON-like basic data containers.

Values are generic data containers. Except for the fact that integer values are explicitly unsigned or signed because of typing limitations, Babeltrace 2 values are very similar to JSON values.

The value API is completely independent from the rest of the Babeltrace 2 C API.

Component initialization parameters, query parameters, as well as trace IR user attributes (for example, bt_event_class_set_user_attributes()) use values.

The available value types are:

Scalar values
  • Null
  • Boolean
  • Unsigned integer (64-bit range)
  • Signed integer (64-bit range)
  • Real (double range)
  • String

Container values
  • Array
  • Map (string to value)

Values are shared objects: get a new reference with bt_value_get_ref() and put an existing reference with bt_value_put_ref().

Some library functions freeze values on success. The documentation of those functions indicate this postcondition.

All the value types share the same C type, bt_value.

Get the type enumerator of a value with bt_value_get_type(). Get whether or not a value type conceptually is a given type with the inline bt_value_type_is() function. Get whether or not a value has a specific type with one of the bt_value_is_*() inline helpers.

The null value is special in that it's a singleton variable, bt_value_null. You can directly compare any value pointer to bt_value_null to check if it's a null value. Like other types of values, the null value is a shared object: if you get a new null value reference, you must eventually put it.

Create a value with one of the bt_value_*_create() or bt_value_*_create_init() functions.

This documentation names the actual data that a scalar value wraps the raw value.

Set and get the raw values of scalar values with functions that are named bt_value_*_set() and bt_value_*_get().

Check that two values are recursively equal with bt_value_is_equal().

Deep-copy a value with bt_value_copy().

Extend a map value with bt_value_map_extend().

The following table shows the available functions and types for each type of value:

Name Type enumerator Type query function Creation functions Writing functions Reading functions
Null BT_VALUE_TYPE_NULL bt_value_is_null() N/A (use the bt_value_null variable directly) N/A N/A
Boolean BT_VALUE_TYPE_BOOL bt_value_is_bool() bt_value_bool_create()
bt_value_bool_create_init()
bt_value_bool_set() bt_value_bool_get()
Unsigned integer BT_VALUE_TYPE_UNSIGNED_INTEGER bt_value_is_unsigned_integer() bt_value_integer_unsigned_create()
bt_value_integer_unsigned_create_init()
bt_value_integer_unsigned_set() bt_value_integer_unsigned_get()
Signed integer BT_VALUE_TYPE_SIGNED_INTEGER bt_value_is_signed_integer() bt_value_integer_signed_create()
bt_value_integer_signed_create_init()
bt_value_integer_signed_set() bt_value_integer_signed_get()
Real BT_VALUE_TYPE_REAL bt_value_is_real() bt_value_real_create()
bt_value_real_create_init()
bt_value_real_set() bt_value_real_get()
String BT_VALUE_TYPE_STRING bt_value_is_string() bt_value_string_create()
bt_value_string_create_init()
bt_value_string_set() bt_value_string_get()
Array BT_VALUE_TYPE_ARRAY bt_value_is_array() bt_value_array_create() bt_value_array_append_element()
bt_value_array_append_bool_element()
bt_value_array_append_unsigned_integer_element()
bt_value_array_append_signed_integer_element()
bt_value_array_append_real_element()
bt_value_array_append_string_element()
bt_value_array_append_empty_array_element()
bt_value_array_append_empty_map_element()
bt_value_array_set_element_by_index()
bt_value_array_get_length()
bt_value_array_is_empty()
bt_value_array_borrow_element_by_index()
bt_value_array_borrow_element_by_index_const()
Map BT_VALUE_TYPE_MAP bt_value_is_map() bt_value_map_create() bt_value_map_insert_entry()
bt_value_map_insert_bool_entry()
bt_value_map_insert_unsigned_integer_entry()
bt_value_map_insert_signed_integer_entry()
bt_value_map_insert_real_entry()
bt_value_map_insert_string_entry()
bt_value_map_insert_empty_array_entry()
bt_value_map_insert_empty_map_entry()
bt_value_map_extend()
bt_value_map_get_size()
bt_value_map_is_empty()
bt_value_map_has_entry()
bt_value_map_borrow_entry_value()
bt_value_map_borrow_entry_value_const()
bt_value_map_foreach_entry()
bt_value_map_foreach_entry_const()

Type

typedef struct bt_value bt_value
 Value.
 

Type query

enum  bt_value_type {
  BT_VALUE_TYPE_NULL,
  BT_VALUE_TYPE_BOOL,
  BT_VALUE_TYPE_INTEGER,
  BT_VALUE_TYPE_UNSIGNED_INTEGER,
  BT_VALUE_TYPE_SIGNED_INTEGER,
  BT_VALUE_TYPE_REAL,
  BT_VALUE_TYPE_STRING,
  BT_VALUE_TYPE_ARRAY,
  BT_VALUE_TYPE_MAP
}
 Value type enumerators. More...
 
typedef enum bt_value_type bt_value_type
 Value type enumerators.
 
bt_value_type bt_value_get_type (const bt_value *value)
 Returns the type enumerator of the value value. More...
 
static bt_bool bt_value_type_is (const bt_value_type type, const bt_value_type other_type)
 Returns whether or not the value type type conceptually is the value type other_type. More...
 
static bt_bool bt_value_is_null (const bt_value *value)
 Returns whether or not the value value is a null value. More...
 
static bt_bool bt_value_is_bool (const bt_value *value)
 Returns whether or not the value value is a boolean value. More...
 
static bt_bool bt_value_is_unsigned_integer (const bt_value *value)
 Returns whether or not the value value is an unsigned integer value. More...
 
static bt_bool bt_value_is_signed_integer (const bt_value *value)
 Returns whether or not the value value is a signed integer value. More...
 
static bt_bool bt_value_is_real (const bt_value *value)
 Returns whether or not the value value is a real value. More...
 
static bt_bool bt_value_is_string (const bt_value *value)
 Returns whether or not the value value is a string value. More...
 
static bt_bool bt_value_is_array (const bt_value *value)
 Returns whether or not the value value is an array value. More...
 
static bt_bool bt_value_is_map (const bt_value *value)
 Returns whether or not the value value is a map value. More...
 

Null value

bt_value *const bt_value_null
 The null value singleton. More...
 

Boolean value

bt_valuebt_value_bool_create (void)
 Creates and returns a boolean value initialized to BT_FALSE. More...
 
bt_valuebt_value_bool_create_init (bt_bool raw_value)
 Creates and returns a boolean value initialized to raw_value. More...
 
void bt_value_bool_set (bt_value *value, bt_bool raw_value)
 Sets the raw value of the boolean value value to raw_value. More...
 
bt_bool bt_value_bool_get (const bt_value *value)
 Returns the raw value of the boolean value value. More...
 

Unsigned integer value

bt_valuebt_value_integer_unsigned_create (void)
 Creates and returns an unsigned integer value initialized to 0. More...
 
bt_valuebt_value_integer_unsigned_create_init (uint64_t raw_value)
 Creates and returns an unsigned integer value initialized to raw_value. More...
 
void bt_value_integer_unsigned_set (bt_value *value, uint64_t raw_value)
 Sets the raw value of the unsigned integer value value to raw_value. More...
 
uint64_t bt_value_integer_unsigned_get (const bt_value *value)
 Returns the raw value of the unsigned integer value value. More...
 

Signed integer value

bt_valuebt_value_integer_signed_create (void)
 Creates and returns a signed integer value initialized to 0. More...
 
bt_valuebt_value_integer_signed_create_init (int64_t raw_value)
 Creates and returns a signed integer value initialized to raw_value. More...
 
void bt_value_integer_signed_set (bt_value *value, int64_t raw_value)
 Sets the raw value of the signed integer value value to raw_value. More...
 
int64_t bt_value_integer_signed_get (const bt_value *value)
 Returns the raw value of the signed integer value value. More...
 

Real value

bt_valuebt_value_real_create (void)
 Creates and returns a real value initialized to 0. More...
 
bt_valuebt_value_real_create_init (double raw_value)
 Creates and returns a real value initialized to raw_value. More...
 
void bt_value_real_set (bt_value *value, double raw_value)
 Sets the raw value of the real value value to raw_value. More...
 
double bt_value_real_get (const bt_value *value)
 Returns the raw value of the real value value. More...
 

String value

enum  bt_value_string_set_status {
  BT_VALUE_STRING_SET_STATUS_OK,
  BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR
}
 Status codes for bt_value_string_set(). More...
 
typedef enum bt_value_string_set_status bt_value_string_set_status
 Status codes for bt_value_string_set().
 
bt_valuebt_value_string_create (void)
 Creates and returns an empty string value. More...
 
bt_valuebt_value_string_create_init (const char *raw_value)
 Creates and returns a string value initialized to a copy of raw_value. More...
 
bt_value_string_set_status bt_value_string_set (bt_value *value, const char *raw_value)
 Sets the raw value of the string value value to a copy of raw_value. More...
 
const char * bt_value_string_get (const bt_value *value)
 Returns the raw value of the string value value. More...
 

Array value

enum  bt_value_array_append_element_status {
  BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK,
  BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR
}
 Status codes for the bt_value_array_append_*() functions. More...
 
enum  bt_value_array_set_element_by_index_status {
  BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OK,
  BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROR
}
 Status codes for bt_value_array_set_element_by_index(). More...
 
typedef enum bt_value_array_append_element_status bt_value_array_append_element_status
 Status codes for the bt_value_array_append_*() functions.
 
typedef enum bt_value_array_set_element_by_index_status bt_value_array_set_element_by_index_status
 Status codes for bt_value_array_set_element_by_index().
 
bt_valuebt_value_array_create (void)
 Creates and returns an empty array value. More...
 
bt_value_array_append_element_status bt_value_array_append_element (bt_value *value, bt_value *element_value)
 Appends the value element_value to the array value value. More...
 
bt_value_array_append_element_status bt_value_array_append_bool_element (bt_value *value, bt_bool raw_value)
 Creates a boolean value initialized to raw_value and appends it to the array value value. More...
 
bt_value_array_append_element_status bt_value_array_append_unsigned_integer_element (bt_value *value, uint64_t raw_value)
 Creates an unsigned integer value initialized to raw_value and appends it to the array value value. More...
 
bt_value_array_append_element_status bt_value_array_append_signed_integer_element (bt_value *value, int64_t raw_value)
 Creates a signed integer value initialized to raw_value and appends it to the array value value. More...
 
bt_value_array_append_element_status bt_value_array_append_real_element (bt_value *value, double raw_value)
 Creates a real value initialized to raw_value and appends it to the array value value. More...
 
bt_value_array_append_element_status bt_value_array_append_string_element (bt_value *value, const char *raw_value)
 Creates a string value initialized to a copy of raw_value and appends it to the array value value. More...
 
bt_value_array_append_element_status bt_value_array_append_empty_array_element (bt_value *value, bt_value **element_value)
 Creates an empty array value and appends it to the array value value. More...
 
bt_value_array_append_element_status bt_value_array_append_empty_map_element (bt_value *value, bt_value **element_value)
 Creates an empty map value and appends it to the array value value. More...
 
bt_value_array_set_element_by_index_status bt_value_array_set_element_by_index (bt_value *value, uint64_t index, bt_value *element_value)
 Sets the element of the array value value at index index to the value element_value. More...
 
bt_valuebt_value_array_borrow_element_by_index (bt_value *value, uint64_t index)
 Borrows the element at index index from the array value value. More...
 
const bt_valuebt_value_array_borrow_element_by_index_const (const bt_value *value, uint64_t index)
 Borrows the element at index index from the array value value (const version). More...
 
uint64_t bt_value_array_get_length (const bt_value *value)
 Returns the length of the array value value. More...
 
static bt_bool bt_value_array_is_empty (const bt_value *value)
 Returns whether or not the array value value is empty. More...
 

Map value

enum  bt_value_map_insert_entry_status {
  BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK,
  BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR
}
 Status codes for the bt_value_map_insert_*() functions. More...
 
enum  bt_value_map_foreach_entry_func_status {
  BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_OK,
  BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_INTERRUPT,
  BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_MEMORY_ERROR,
  BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_ERROR
}
 Status codes for bt_value_map_foreach_entry_func. More...
 
enum  bt_value_map_foreach_entry_status {
  BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK,
  BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED,
  BT_VALUE_MAP_FOREACH_ENTRY_STATUS_USER_ERROR,
  BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROR,
  BT_VALUE_MAP_FOREACH_ENTRY_STATUS_ERROR
}
 Status codes for bt_value_map_foreach_entry(). More...
 
enum  bt_value_map_foreach_entry_const_func_status {
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_OK,
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_INTERRUPT,
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_MEMORY_ERROR,
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_ERROR
}
 Status codes for bt_value_map_foreach_entry_const_func. More...
 
enum  bt_value_map_foreach_entry_const_status {
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_OK,
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_INTERRUPTED,
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_USER_ERROR,
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_MEMORY_ERROR,
  BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_ERROR
}
 Status codes for bt_value_map_foreach_entry_const(). More...
 
enum  bt_value_map_extend_status {
  BT_VALUE_MAP_EXTEND_STATUS_OK,
  BT_VALUE_MAP_EXTEND_STATUS_MEMORY_ERROR
}
 Status codes for bt_value_map_extend(). More...
 
typedef enum bt_value_map_insert_entry_status bt_value_map_insert_entry_status
 Status codes for the bt_value_map_insert_*() functions.
 
typedef enum bt_value_map_foreach_entry_func_status bt_value_map_foreach_entry_func_status
 Status codes for bt_value_map_foreach_entry_func.
 
typedef bt_value_map_foreach_entry_func_status(* bt_value_map_foreach_entry_func) (const char *key, bt_value *value, void *user_data)
 User function for bt_value_map_foreach_entry(). More...
 
typedef enum bt_value_map_foreach_entry_status bt_value_map_foreach_entry_status
 Status codes for bt_value_map_foreach_entry().
 
typedef enum bt_value_map_foreach_entry_const_func_status bt_value_map_foreach_entry_const_func_status
 Status codes for bt_value_map_foreach_entry_const_func.
 
typedef bt_value_map_foreach_entry_const_func_status(* bt_value_map_foreach_entry_const_func) (const char *key, const bt_value *value, void *user_data)
 User function for bt_value_map_foreach_entry_const_func(). More...
 
typedef enum bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const_status
 Status codes for bt_value_map_foreach_entry_const().
 
typedef enum bt_value_map_extend_status bt_value_map_extend_status
 Status codes for bt_value_map_extend().
 
bt_valuebt_value_map_create (void)
 Creates and returns an empty map value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_entry (bt_value *value, const char *key, bt_value *entry_value)
 Inserts or replaces an entry with the key key and the value entry_value in the map value value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_bool_entry (bt_value *value, const char *key, bt_bool raw_value)
 Creates a boolean value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_unsigned_integer_entry (bt_value *value, const char *key, uint64_t raw_value)
 Creates an unsigned integer value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_signed_integer_entry (bt_value *value, const char *key, int64_t raw_value)
 Creates a signed integer value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_real_entry (bt_value *value, const char *key, double raw_value)
 Creates a real value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_string_entry (bt_value *value, const char *key, const char *raw_value)
 Creates a string value initialized to a copy of raw_value and inserts or replaces an entry with the key key and this value in the map value value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_empty_array_entry (bt_value *value, const char *key, bt_value **entry_value)
 Creates an empty array value and inserts or replaces an entry with the key key and this value in the map value value. More...
 
bt_value_map_insert_entry_status bt_value_map_insert_empty_map_entry (bt_value *value, const char *key, bt_value **entry_value)
 Creates an empty map value and inserts or replaces an entry with the key key and this value in the map value value. More...
 
bt_valuebt_value_map_borrow_entry_value (bt_value *value, const char *key)
 Borrows the value of the entry with the key key in the map value value. More...
 
const bt_valuebt_value_map_borrow_entry_value_const (const bt_value *value, const char *key)
 Borrows the value of the entry with the key key in the map value value (const version). More...
 
bt_value_map_foreach_entry_status bt_value_map_foreach_entry (bt_value *value, bt_value_map_foreach_entry_func user_func, void *user_data)
 Iterates the entries of the map value value, calling user_func for each entry. More...
 
bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const (const bt_value *value, bt_value_map_foreach_entry_const_func user_func, void *user_data)
 Iterates the entries of the map value value, calling user_func for each entry (const version). More...
 
uint64_t bt_value_map_get_size (const bt_value *value)
 Returns the size of the map value value. More...
 
static bt_bool bt_value_map_is_empty (const bt_value *value)
 Returns whether or not the map value value is empty. More...
 
bt_bool bt_value_map_has_entry (const bt_value *value, const char *key)
 Returns whether or not the map value value has an entry with the key key. More...
 
bt_value_map_extend_status bt_value_map_extend (bt_value *value, const bt_value *extension_value)
 Extends the map value value with the map value extension_value. More...
 

General

enum  bt_value_copy_status {
  BT_VALUE_COPY_STATUS_OK,
  BT_VALUE_COPY_STATUS_MEMORY_ERROR
}
 Status codes for bt_value_copy(). More...
 
typedef enum bt_value_copy_status bt_value_copy_status
 Status codes for bt_value_copy().
 
bt_value_copy_status bt_value_copy (const bt_value *value, bt_value **copy_value)
 Deep-copies a value object. More...
 
bt_bool bt_value_is_equal (const bt_value *a_value, const bt_value *b_value)
 Returns whether or not the value a_value is equal, recursively, to b_value. More...
 

Reference count

void bt_value_get_ref (const bt_value *value)
 Increments the reference count of the value value. More...
 
void bt_value_put_ref (const bt_value *value)
 Decrements the reference count of the value value. More...
 
#define BT_VALUE_PUT_REF_AND_RESET(_value)
 Decrements the reference count of the value _value, and then sets _value to NULL. More...
 
#define BT_VALUE_MOVE_REF(_dst, _src)
 Decrements the reference count of the value _dst, sets _dst to _src, and then sets _src to NULL. More...
 

Typedef Documentation

◆ bt_value_map_foreach_entry_func

typedef bt_value_map_foreach_entry_func_status(* bt_value_map_foreach_entry_func) (const char *key, bt_value *value, void *user_data)

User function for bt_value_map_foreach_entry().

This is the type of the user function that bt_value_map_foreach_entry() calls for each entry of the map value.

Parameters
[in]keyKey of the map value entry.
[in]valueValue of the map value entry.
[in]user_dataUser data, as passed as the user_data parameter of bt_value_map_foreach_entry().
Return values
BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_OKSuccess.
BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_INTERRUPTInterrupt the iteration process.
BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_MEMORY_ERROROut of memory.
BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_ERRORUser error.
Precondition
key is not NULL.
value is not NULL.
See also
bt_value_map_foreach_entry() — Iterates the entries of a map value.

◆ bt_value_map_foreach_entry_const_func

typedef bt_value_map_foreach_entry_const_func_status(* bt_value_map_foreach_entry_const_func) (const char *key, const bt_value *value, void *user_data)

User function for bt_value_map_foreach_entry_const_func().

This is the type of the user function that bt_value_map_foreach_entry_const_func() calls for each entry of the map value.

Parameters
[in]keyKey of the map value entry.
[in]valueValue of the map value entry.
[in]user_dataUser data.
Return values
BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_OKSuccess.
BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_INTERRUPTInterrupt the iteration process.
BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_MEMORY_ERROROut of memory.
BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_ERRORUser error.
Precondition
key is not NULL.
value is not NULL.
See also
bt_value_map_foreach_entry_const() — Iterates the entries of a const map value.

Enumeration Type Documentation

◆ bt_value_type

Value type enumerators.

Enumerator
BT_VALUE_TYPE_NULL 

Null value.

BT_VALUE_TYPE_BOOL 

Boolean value.

BT_VALUE_TYPE_INTEGER 

Integer value.

No value has this type: use it with bt_value_type_is().

BT_VALUE_TYPE_UNSIGNED_INTEGER 

Unsigned integer value.

This type conceptually inherits BT_VALUE_TYPE_INTEGER.

BT_VALUE_TYPE_SIGNED_INTEGER 

Signed integer value.

This type conceptually inherits BT_VALUE_TYPE_INTEGER.

BT_VALUE_TYPE_REAL 

Real value.

BT_VALUE_TYPE_STRING 

String value.

BT_VALUE_TYPE_ARRAY 

Array value.

BT_VALUE_TYPE_MAP 

Map value.

◆ bt_value_string_set_status

Status codes for bt_value_string_set().

Enumerator
BT_VALUE_STRING_SET_STATUS_OK 

Success.

BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR 

Out of memory.

◆ bt_value_array_append_element_status

Status codes for the bt_value_array_append_*() functions.

Enumerator
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK 

Success.

BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR 

Out of memory.

◆ bt_value_array_set_element_by_index_status

Status codes for bt_value_array_set_element_by_index().

Enumerator
BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OK 

Success.

BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROR 

Out of memory.

◆ bt_value_map_insert_entry_status

Status codes for the bt_value_map_insert_*() functions.

Enumerator
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK 

Success.

BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR 

Out of memory.

◆ bt_value_map_foreach_entry_func_status

Status codes for bt_value_map_foreach_entry_func.

Enumerator
BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_OK 

Success.

BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_INTERRUPT 

Interrupt the iteration process.

BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_MEMORY_ERROR 

Out of memory.

BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_ERROR 

User error.

◆ bt_value_map_foreach_entry_status

Status codes for bt_value_map_foreach_entry().

Enumerator
BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK 

Success.

BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED 

User function interrupted the iteration process.

BT_VALUE_MAP_FOREACH_ENTRY_STATUS_USER_ERROR 

User function error.

BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROR 

Out of memory.

BT_VALUE_MAP_FOREACH_ENTRY_STATUS_ERROR 

Other error.

◆ bt_value_map_foreach_entry_const_func_status

Status codes for bt_value_map_foreach_entry_const_func.

Enumerator
BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_OK 

Success.

BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_INTERRUPT 

Interrupt the iteration process.

BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_MEMORY_ERROR 

Out of memory.

BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_ERROR 

User error.

◆ bt_value_map_foreach_entry_const_status

Status codes for bt_value_map_foreach_entry_const().

Enumerator
BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_OK 

Success.

BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_INTERRUPTED 

User function interrupted the iteration process.

BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_USER_ERROR 

User function error.

BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_MEMORY_ERROR 

Out of memory.

BT_VALUE_MAP_FOREACH_ENTRY_CONST_STATUS_ERROR 

Other error.

◆ bt_value_map_extend_status

Status codes for bt_value_map_extend().

Enumerator
BT_VALUE_MAP_EXTEND_STATUS_OK 

Success.

BT_VALUE_MAP_EXTEND_STATUS_MEMORY_ERROR 

Out of memory.

◆ bt_value_copy_status

Status codes for bt_value_copy().

Enumerator
BT_VALUE_COPY_STATUS_OK 

Success.

BT_VALUE_COPY_STATUS_MEMORY_ERROR 

Out of memory.

Macro Definition Documentation

◆ BT_VALUE_PUT_REF_AND_RESET

#define BT_VALUE_PUT_REF_AND_RESET (   _value)

Decrements the reference count of the value _value, and then sets _value to NULL.

Parameters
_value

Value of which to decrement the reference count.

Can contain NULL.

Precondition
_value is an assignable expression.

◆ BT_VALUE_MOVE_REF

#define BT_VALUE_MOVE_REF (   _dst,
  _src 
)

Decrements the reference count of the value _dst, sets _dst to _src, and then sets _src to NULL.

This macro effectively moves a value reference from the expression _src to the expression _dst, putting the existing _dst reference.

Parameters
_dst

Destination expression.

Can contain NULL.

_src

Source expression.

Can contain NULL.

Precondition
_dst is an assignable expression.
_src is an assignable expression.

Variable Documentation

◆ bt_value_null

bt_value* const bt_value_null

The null value singleton.

This is the only instance of a null value.

Like any type of value, the null value is a shared object: if you get a new null value reference with bt_value_get_ref(), you must eventually put it with bt_value_put_ref(). The null value singleton's reference count must never reach 0: libbabeltrace2 logs a warning message when this programming error occurs.

Because all null values point to the same null value singleton, you can directly compare a value to the bt_value_null variable.

Attention

bt_value_null is different from NULL: the former is a true Babeltrace 2 value object while the latter is a C definition which usually means "no pointer".

For example, bt_value_map_borrow_entry_value() can return bt_value_null if the requested key is mapped to a null value, but it can also return NULL if the key is not found.

See also
bt_value_is_null() — Returns whether or not a value is a null value.

Function Documentation

◆ bt_value_get_type()

bt_value_type bt_value_get_type ( const bt_value value)

Returns the type enumerator of the value value.

Parameters
[in]valueValue of which to get the type enumerator
Returns
Type enumerator of value.
Precondition
value is not NULL.
See also
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.
bt_value_is_null() — Returns whether or not a value is a null value.
bt_value_is_bool() — Returns whether or not a value is a boolean value.
bt_value_is_unsigned_integer() — Returns whether or not a value is an unsigned integer value.
bt_value_is_signed_integer() — Returns whether or not a value is a signed integer value.
bt_value_is_real() — Returns whether or not a value is a real value.
bt_value_is_string() — Returns whether or not a value is a string value.
bt_value_is_array() — Returns whether or not a value is an array value.
bt_value_is_map() — Returns whether or not a value is a map value.

◆ bt_value_type_is()

static bt_bool bt_value_type_is ( const bt_value_type  type,
const bt_value_type  other_type 
)
inlinestatic

Returns whether or not the value type type conceptually is the value type other_type.

For example, an unsigned integer value conceptually is an integer value, so

returns BT_TRUE.

Parameters
[in]typeValue type to check against other_type.
[in]other_typeValue type against which to check type.
Returns
BT_TRUE if type conceptually is other_type.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_is_null() — Returns whether or not a value is a null value.
bt_value_is_bool() — Returns whether or not a value is a boolean value.
bt_value_is_unsigned_integer() — Returns whether or not a value is an unsigned integer value.
bt_value_is_signed_integer() — Returns whether or not a value is a signed integer value.
bt_value_is_real() — Returns whether or not a value is a real value.
bt_value_is_string() — Returns whether or not a value is a string value.
bt_value_is_array() — Returns whether or not a value is an array value.
bt_value_is_map() — Returns whether or not a value is a map value.

◆ bt_value_is_null()

static bt_bool bt_value_is_null ( const bt_value value)
inlinestatic

Returns whether or not the value value is a null value.

Note
Because all null values point to the same null value singleton, you can also directly compare value to the bt_value_null variable.
Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is a null value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.
bt_value_null — The null value singleton.

◆ bt_value_is_bool()

static bt_bool bt_value_is_bool ( const bt_value value)
inlinestatic

Returns whether or not the value value is a boolean value.

Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is a boolean value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.

◆ bt_value_is_unsigned_integer()

static bt_bool bt_value_is_unsigned_integer ( const bt_value value)
inlinestatic

Returns whether or not the value value is an unsigned integer value.

Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is an unsigned integer value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.

◆ bt_value_is_signed_integer()

static bt_bool bt_value_is_signed_integer ( const bt_value value)
inlinestatic

Returns whether or not the value value is a signed integer value.

Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is a signed integer value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.

◆ bt_value_is_real()

static bt_bool bt_value_is_real ( const bt_value value)
inlinestatic

Returns whether or not the value value is a real value.

Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is a real value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.

◆ bt_value_is_string()

static bt_bool bt_value_is_string ( const bt_value value)
inlinestatic

Returns whether or not the value value is a string value.

Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is a string value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.

◆ bt_value_is_array()

static bt_bool bt_value_is_array ( const bt_value value)
inlinestatic

Returns whether or not the value value is an array value.

Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is an array value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.

◆ bt_value_is_map()

static bt_bool bt_value_is_map ( const bt_value value)
inlinestatic

Returns whether or not the value value is a map value.

Parameters
[in]valueValue to check.
Returns
BT_TRUE if value is a map value.
Precondition
value is not NULL.
See also
bt_value_get_type() — Returns the type enumerator of a value.
bt_value_type_is() — Returns whether or not the type of a value conceptually is a given type.

◆ bt_value_bool_create()

bt_value* bt_value_bool_create ( void  )

Creates and returns a boolean value initialized to BT_FALSE.

The returned value has the type BT_VALUE_TYPE_BOOL.

Returns
New boolean value reference, or NULL on memory error.
See also
bt_value_bool_create_init() — Creates a boolean value with a given initial raw value.

◆ bt_value_bool_create_init()

bt_value* bt_value_bool_create_init ( bt_bool  raw_value)

Creates and returns a boolean value initialized to raw_value.

The returned value has the type BT_VALUE_TYPE_BOOL.

Parameters
[in]raw_valueInitial raw value of the boolean value to create.
Returns
New boolean value reference, or NULL on memory error.
See also
bt_value_bool_create() — Creates a boolean value initialized to BT_FALSE.

◆ bt_value_bool_set()

void bt_value_bool_set ( bt_value value,
bt_bool  raw_value 
)

Sets the raw value of the boolean value value to raw_value.

Parameters
[in]valueBoolean value of which to set the raw value to raw_value.
[in]raw_valueNew raw value of value.
Precondition
value is not NULL.
value is a boolean value (bt_value_is_bool() returns BT_TRUE).
value is not frozen.
See also
bt_value_bool_get() — Returns the raw value of a boolean value.

◆ bt_value_bool_get()

bt_bool bt_value_bool_get ( const bt_value value)

Returns the raw value of the boolean value value.

Parameters
[in]valueBoolean value of which to get the raw value.
Returns
Raw value of value.
Precondition
value is not NULL.
value is a boolean value (bt_value_is_bool() returns BT_TRUE).
See also
bt_value_bool_set() — Sets the raw value of a boolean value.

◆ bt_value_integer_unsigned_create()

bt_value* bt_value_integer_unsigned_create ( void  )

Creates and returns an unsigned integer value initialized to 0.

The returned value has the type BT_VALUE_TYPE_UNSIGNED_INTEGER.

Returns
New unsigned integer value reference, or NULL on memory error.
See also
bt_value_integer_unsigned_create_init() — Creates an unsigned integer value with a given initial raw value.

◆ bt_value_integer_unsigned_create_init()

bt_value* bt_value_integer_unsigned_create_init ( uint64_t  raw_value)

Creates and returns an unsigned integer value initialized to raw_value.

The returned value has the type BT_VALUE_TYPE_UNSIGNED_INTEGER.

Parameters
[in]raw_valueInitial raw value of the unsigned integer value to create.
Returns
New unsigned integer value reference, or NULL on memory error.
See also
bt_value_bool_create() — Creates an unsigned integer value initialized to 0.

◆ bt_value_integer_unsigned_set()

void bt_value_integer_unsigned_set ( bt_value value,
uint64_t  raw_value 
)

Sets the raw value of the unsigned integer value value to raw_value.

Parameters
[in]valueUnsigned integer value of which to set the raw value to raw_value.
[in]raw_valueNew raw value of value.
Precondition
value is not NULL.
value is an unsigned integer value (bt_value_is_unsigned_integer() returns BT_TRUE).
value is not frozen.
See also
bt_value_integer_unsigned_get() — Returns the raw value of an unsigned integer value.

◆ bt_value_integer_unsigned_get()

uint64_t bt_value_integer_unsigned_get ( const bt_value value)

Returns the raw value of the unsigned integer value value.

Parameters
[in]valueUnsigned integer value of which to get the raw value.
Returns
Raw value of value.
Precondition
value is not NULL.
value is an unsigned integer value (bt_value_is_unsigned_integer() returns BT_TRUE).
See also
bt_value_integer_unsigned_set() — Sets the raw value of an unsigned integer value.

◆ bt_value_integer_signed_create()

bt_value* bt_value_integer_signed_create ( void  )

Creates and returns a signed integer value initialized to 0.

The returned value has the type BT_VALUE_TYPE_SIGNED_INTEGER.

Returns
New signed integer value reference, or NULL on memory error.
See also
bt_value_integer_signed_create_init() — Creates a signed integer value with a given initial raw value.

◆ bt_value_integer_signed_create_init()

bt_value* bt_value_integer_signed_create_init ( int64_t  raw_value)

Creates and returns a signed integer value initialized to raw_value.

The returned value has the type BT_VALUE_TYPE_SIGNED_INTEGER.

Parameters
[in]raw_valueInitial raw value of the signed integer value to create.
Returns
New signed integer value reference, or NULL on memory error.
See also
bt_value_bool_create() — Creates a signed integer value initialized to 0.

◆ bt_value_integer_signed_set()

void bt_value_integer_signed_set ( bt_value value,
int64_t  raw_value 
)

Sets the raw value of the signed integer value value to raw_value.

Parameters
[in]valueSigned integer value of which to set the raw value to raw_value.
[in]raw_valueNew raw value of value.
Precondition
value is not NULL.
value is a signed integer value (bt_value_is_signed_integer() returns BT_TRUE).
value is not frozen.
See also
bt_value_integer_signed_get() — Returns the raw value of a signed integer value.

◆ bt_value_integer_signed_get()

int64_t bt_value_integer_signed_get ( const bt_value value)

Returns the raw value of the signed integer value value.

Parameters
[in]valueSigned integer value of which to get the raw value.
Returns
Raw value of value.
Precondition
value is not NULL.
value is a signed integer value (bt_value_is_signed_integer() returns BT_TRUE).
See also
bt_value_integer_signed_set() — Sets the raw value of a signed integer value.

◆ bt_value_real_create()

bt_value* bt_value_real_create ( void  )

Creates and returns a real value initialized to 0.

The returned value has the type BT_VALUE_TYPE_REAL.

Returns
New real value reference, or NULL on memory error.
See also
bt_value_real_create_init() — Creates a real value with a given initial raw value.

◆ bt_value_real_create_init()

bt_value* bt_value_real_create_init ( double  raw_value)

Creates and returns a real value initialized to raw_value.

The returned value has the type BT_VALUE_TYPE_REAL.

Parameters
[in]raw_valueInitial raw value of the real value to create.
Returns
New real value reference, or NULL on memory error.
See also
bt_value_real_create() — Creates a real value initialized to 0.

◆ bt_value_real_set()

void bt_value_real_set ( bt_value value,
double  raw_value 
)

Sets the raw value of the real value value to raw_value.

Parameters
[in]valueReal value of which to set the raw value to raw_value.
[in]raw_valueNew raw value of value.
Precondition
value is not NULL.
value is a real value (bt_value_is_real() returns BT_TRUE).
value is not frozen.
See also
bt_value_real_get() — Returns the raw value of a real value.

◆ bt_value_real_get()

double bt_value_real_get ( const bt_value value)

Returns the raw value of the real value value.

Parameters
[in]valueReal value of which to get the raw value.
Returns
Raw value of value.
Precondition
value is not NULL.
value is a real value (bt_value_is_real() returns BT_TRUE).
See also
bt_value_real_set() — Sets the raw value of a real value.

◆ bt_value_string_create()

bt_value* bt_value_string_create ( void  )

Creates and returns an empty string value.

The returned value has the type BT_VALUE_TYPE_STRING.

Returns
New string value reference, or NULL on memory error.
See also
bt_value_string_create_init() — Creates a string value with a given initial raw value.

◆ bt_value_string_create_init()

bt_value* bt_value_string_create_init ( const char *  raw_value)

Creates and returns a string value initialized to a copy of raw_value.

The returned value has the type BT_VALUE_TYPE_STRING.

Parameters
[in]raw_valueInitial raw value of the string value to create (copied).
Returns
New string value reference, or NULL on memory error.
Precondition
raw_value is not NULL.
See also
bt_value_string_create() — Creates an empty string value.

◆ bt_value_string_set()

bt_value_string_set_status bt_value_string_set ( bt_value value,
const char *  raw_value 
)

Sets the raw value of the string value value to a copy of raw_value.

Parameters
[in]valueString value of which to set the raw value to a copy of raw_value.
[in]raw_valueNew raw value of value (copied).
Return values
BT_VALUE_STRING_SET_STATUS_OKSuccess.
BT_VALUE_STRING_SET_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a string value (bt_value_is_string() returns BT_TRUE).
value is not frozen.
raw_value is not NULL.
See also
bt_value_string_get() — Returns the raw value of a string value.

◆ bt_value_string_get()

const char* bt_value_string_get ( const bt_value value)

Returns the raw value of the string value value.

Parameters
[in]valueString value of which to get the raw value.
Returns

Raw value of value.

The returned pointer remains valid until value is modified.

Precondition
value is not NULL.
value is a string value (bt_value_is_string() returns BT_TRUE).
See also
bt_value_string_set() — Sets the raw value of a string value.

◆ bt_value_array_create()

bt_value* bt_value_array_create ( void  )

Creates and returns an empty array value.

The returned value has the type BT_VALUE_TYPE_ARRAY.

Returns
New array value reference, or NULL on memory error.

◆ bt_value_array_append_element()

bt_value_array_append_element_status bt_value_array_append_element ( bt_value value,
bt_value element_value 
)

Appends the value element_value to the array value value.

To append a null value, pass bt_value_null as element_value.

Parameters
[in]valueArray value to which to append element_value.
[in]element_valueValue to append to value.
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
element_value is not NULL.
element_value does not contain value, recursively.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_bool_element() — Creates and appends a boolean value to an array value.
bt_value_array_append_unsigned_integer_element() — Creates and appends an unsigned integer value to an array value.
bt_value_array_append_signed_integer_element() — Creates and appends a signed integer value to an array value.
bt_value_array_append_real_element() — Creates and appends a real value to an array value.
bt_value_array_append_string_element() — Creates and appends a string value to an array value.
bt_value_array_append_empty_array_element() — Creates and appends an empty array value to an array value.
bt_value_array_append_empty_map_element() — Creates and appends an empty map value to an array value.

◆ bt_value_array_append_bool_element()

bt_value_array_append_element_status bt_value_array_append_bool_element ( bt_value value,
bt_bool  raw_value 
)

Creates a boolean value initialized to raw_value and appends it to the array value value.

Parameters
[in]valueArray value to which to append the created boolean value.
[in]raw_valueRaw value of the boolean value to create and append to value.
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends an existing value to an array value.

◆ bt_value_array_append_unsigned_integer_element()

bt_value_array_append_element_status bt_value_array_append_unsigned_integer_element ( bt_value value,
uint64_t  raw_value 
)

Creates an unsigned integer value initialized to raw_value and appends it to the array value value.

Parameters
[in]valueArray value to which to append the created unsigned integer value.
[in]raw_valueRaw value of the unsigned integer value to create and append to value.
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends an existing value to an array value.

◆ bt_value_array_append_signed_integer_element()

bt_value_array_append_element_status bt_value_array_append_signed_integer_element ( bt_value value,
int64_t  raw_value 
)

Creates a signed integer value initialized to raw_value and appends it to the array value value.

Parameters
[in]valueArray value to which to append the created signed integer value.
[in]raw_valueRaw value of the signed integer value to create and append to value.
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends an existing value to an array value.

◆ bt_value_array_append_real_element()

bt_value_array_append_element_status bt_value_array_append_real_element ( bt_value value,
double  raw_value 
)

Creates a real value initialized to raw_value and appends it to the array value value.

Parameters
[in]valueArray value to which to append the created real value.
[in]raw_valueRaw value of the real value to create and append to value.
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends an existing value to an array value.

◆ bt_value_array_append_string_element()

bt_value_array_append_element_status bt_value_array_append_string_element ( bt_value value,
const char *  raw_value 
)

Creates a string value initialized to a copy of raw_value and appends it to the array value value.

Parameters
[in]valueArray value to which to append the created string value.
[in]raw_valueRaw value of the string value to create and append to value (copied).
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends an existing value to an array value.

◆ bt_value_array_append_empty_array_element()

bt_value_array_append_element_status bt_value_array_append_empty_array_element ( bt_value value,
bt_value **  element_value 
)

Creates an empty array value and appends it to the array value value.

On success, if element_value is not NULL, this function sets *element_value to a borrowed reference of the created empty array value.

Parameters
[in]valueArray value to which to append the created empty array value.
[out]element_valueOn success, if not NULL, *element_value is a borrowed reference of the created empty array value.
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends an existing value to an array value.

◆ bt_value_array_append_empty_map_element()

bt_value_array_append_element_status bt_value_array_append_empty_map_element ( bt_value value,
bt_value **  element_value 
)

Creates an empty map value and appends it to the array value value.

On success, if element_value is not NULL, this function sets *element_value to a borrowed reference of the created empty map value.

Parameters
[in]valueArray value to which to append the created empty array value.
[out]element_valueOn success, if not NULL, *element_value is a borrowed reference of the created empty map value.
Return values
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OKSuccess.
BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends an existing value to an array value.

◆ bt_value_array_set_element_by_index()

bt_value_array_set_element_by_index_status bt_value_array_set_element_by_index ( bt_value value,
uint64_t  index,
bt_value element_value 
)

Sets the element of the array value value at index index to the value element_value.

On success, this function replaces the existing element of value at index index.

Parameters
[in]valueArray value of which to set the element at index index.
[in]indexIndex of the element to set in value.
[in]element_valueValue to set as the element of value at index index.
Return values
BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OKSuccess.
BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
value is not frozen.
index is less than the length of value (as returned by bt_value_array_get_length()).
element_value is not NULL.
element_value does not contain value, recursively.
Postcondition
On success, the length of value is incremented.
See also
bt_value_array_append_element() — Appends a value to an array value.

◆ bt_value_array_borrow_element_by_index()

bt_value* bt_value_array_borrow_element_by_index ( bt_value value,
uint64_t  index 
)

Borrows the element at index index from the array value value.

Parameters
[in]valueArray value from which to borrow the element at index index.
[in]indexIndex of the element to borrow from value.
Returns

Borrowed reference of the element of value at index index.

The returned pointer remains valid until value is modified.

Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
index is less than the length of value (as returned by bt_value_array_get_length()).
See also
bt_value_array_borrow_element_by_index_const()const version of this function.

◆ bt_value_array_borrow_element_by_index_const()

const bt_value* bt_value_array_borrow_element_by_index_const ( const bt_value value,
uint64_t  index 
)

Borrows the element at index index from the array value value (const version).

See bt_value_array_borrow_element_by_index().

◆ bt_value_array_get_length()

uint64_t bt_value_array_get_length ( const bt_value value)

Returns the length of the array value value.

Parameters
[in]valueArray value of which to get the length.
Returns
Length (number of contained elements) of value.
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
See also
bt_value_array_is_empty() — Returns whether or not an array value is empty.

◆ bt_value_array_is_empty()

static bt_bool bt_value_array_is_empty ( const bt_value value)
inlinestatic

Returns whether or not the array value value is empty.

Parameters
[in]valueArray value to check.
Returns
BT_TRUE if value is empty (has the length 0).
Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
See also
bt_value_array_get_length() — Returns the length of an array value.

◆ bt_value_map_create()

bt_value* bt_value_map_create ( void  )

Creates and returns an empty map value.

The returned value has the type BT_VALUE_TYPE_MAP.

Returns
New map value reference, or NULL on memory error.

◆ bt_value_map_insert_entry()

bt_value_map_insert_entry_status bt_value_map_insert_entry ( bt_value value,
const char *  key,
bt_value entry_value 
)

Inserts or replaces an entry with the key key and the value entry_value in the map value value.

To insert an entry having a null value, pass bt_value_null as entry_value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with entry_value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and value entry_value.
[in]keyKey of the entry to insert or replace in value (copied).
[in]entry_valueValue of the entry to insert or replace in value.
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
entry_value is not NULL.
entry_value does not contain value, recursively.
See also
bt_value_map_insert_bool_entry() — Creates a boolean value and uses it to insert an entry in a map value.
bt_value_map_insert_unsigned_integer_entry() — Creates an unsigned integer value and uses it to insert an entry in a map value.
bt_value_map_insert_signed_integer_entry() — Creates a signed value and uses it to insert an entry in a map value.
bt_value_map_insert_real_entry() — Creates a real value and uses it to insert an entry in a map value.
bt_value_map_insert_string_entry() — Creates a string value and uses it to insert an entry in a map value.
bt_value_map_insert_empty_array_entry() — Creates an empty array value and uses it to insert an entry in a map value.
bt_value_map_insert_empty_map_entry() — Creates a map value and uses it to insert an entry in a map value.

◆ bt_value_map_insert_bool_entry()

bt_value_map_insert_entry_status bt_value_map_insert_bool_entry ( bt_value value,
const char *  key,
bt_bool  raw_value 
)

Creates a boolean value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with the created boolean value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and the created boolean value.
[in]keyKey of the entry to insert or replace in value (copied).
[in]raw_valueInitial raw value of the boolean value to create.
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
See also
bt_value_map_insert_entry() — Inserts an entry with an existing value in a map value.

◆ bt_value_map_insert_unsigned_integer_entry()

bt_value_map_insert_entry_status bt_value_map_insert_unsigned_integer_entry ( bt_value value,
const char *  key,
uint64_t  raw_value 
)

Creates an unsigned integer value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with the created unsigned integer value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and the created unsigned integer value.
[in]keyKey of the entry to insert or replace in value (copied).
[in]raw_valueInitial raw value of the unsigned integer value to create.
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
See also
bt_value_map_insert_entry() — Inserts an entry with an existing value in a map value.

◆ bt_value_map_insert_signed_integer_entry()

bt_value_map_insert_entry_status bt_value_map_insert_signed_integer_entry ( bt_value value,
const char *  key,
int64_t  raw_value 
)

Creates a signed integer value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with the created signed integer value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and the created signed integer value.
[in]keyKey of the entry to insert or replace in value (copied).
[in]raw_valueInitial raw value of the signed integer value to create.
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
See also
bt_value_map_insert_entry() — Inserts an entry with an existing value in a map value.

◆ bt_value_map_insert_real_entry()

bt_value_map_insert_entry_status bt_value_map_insert_real_entry ( bt_value value,
const char *  key,
double  raw_value 
)

Creates a real value initialized to raw_value and inserts or replaces an entry with the key key and this value in the map value value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with the created real value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and the created real value.
[in]keyKey of the entry to insert or replace in value (copied).
[in]raw_valueInitial raw value of the real value to create.
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
See also
bt_value_map_insert_entry() — Inserts an entry with an existing value in a map value.

◆ bt_value_map_insert_string_entry()

bt_value_map_insert_entry_status bt_value_map_insert_string_entry ( bt_value value,
const char *  key,
const char *  raw_value 
)

Creates a string value initialized to a copy of raw_value and inserts or replaces an entry with the key key and this value in the map value value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with the created string value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and the created string value.
[in]keyKey of the entry to insert or replace in value (copied).
[in]raw_valueInitial raw value of the string value to create (copied).
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
See also
bt_value_map_insert_entry() — Inserts an entry with an existing value in a map value.

◆ bt_value_map_insert_empty_array_entry()

bt_value_map_insert_entry_status bt_value_map_insert_empty_array_entry ( bt_value value,
const char *  key,
bt_value **  entry_value 
)

Creates an empty array value and inserts or replaces an entry with the key key and this value in the map value value.

On success, if entry_value is not NULL, this function sets *entry_value to a borrowed reference of the created empty array value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with the created empty array value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and the created empty array value.
[in]keyKey of the entry to insert or replace in value (copied).
[out]entry_valueOn success, if not NULL, *entry_value is a borrowed reference of the created empty array value.
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
See also
bt_value_map_insert_entry() — Inserts an entry with an existing value in a map value.

◆ bt_value_map_insert_empty_map_entry()

bt_value_map_insert_entry_status bt_value_map_insert_empty_map_entry ( bt_value value,
const char *  key,
bt_value **  entry_value 
)

Creates an empty map value and inserts or replaces an entry with the key key and this value in the map value value.

On success, if entry_value is not NULL, this function sets *entry_value to a borrowed reference of the created empty map value.

On success, if value already contains an entry with key key, this function replaces the existing entry's value with the created empty map value.

Parameters
[in]valueMap value in which to insert or replace an entry with key key and the created empty map value.
[in]keyKey of the entry to insert or replace in value (copied).
[out]entry_valueOn success, if not NULL, *entry_value is a borrowed reference of the created empty map value.
Return values
BT_VALUE_MAP_INSERT_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
value is not frozen.
key is not NULL.
See also
bt_value_map_insert_entry() — Inserts an entry with an existing value in a map value.

◆ bt_value_map_borrow_entry_value()

bt_value* bt_value_map_borrow_entry_value ( bt_value value,
const char *  key 
)

Borrows the value of the entry with the key key in the map value value.

If no entry with key key exists in value, this function returns NULL.

Parameters
[in]valueMap value from which to borrow the value of the entry with the key key.
[in]keyKey of the entry from which to borrow the value in value.
Returns

Borrowed reference of the value of the entry with key key in value, or NULL if none.

The returned pointer remains valid until value is modified.

Precondition
value is not NULL.
value is an array value (bt_value_is_array() returns BT_TRUE).
key is not NULL.
See also
bt_value_map_borrow_entry_value_const()const version of this function.
bt_value_map_has_entry() — Returns whether or not a map value has an entry with a given key.

◆ bt_value_map_borrow_entry_value_const()

const bt_value* bt_value_map_borrow_entry_value_const ( const bt_value value,
const char *  key 
)

Borrows the value of the entry with the key key in the map value value (const version).

See bt_value_map_borrow_entry_value().

◆ bt_value_map_foreach_entry()

bt_value_map_foreach_entry_status bt_value_map_foreach_entry ( bt_value value,
bt_value_map_foreach_entry_func  user_func,
void *  user_data 
)

Iterates the entries of the map value value, calling user_func for each entry.

This function iterates the entries of value in no particular order.

Attention
You must not modify value during the iteration process.

user_func receives user_data as its last parameter.

The iteration process stops when one of:

Parameters
[in]valueMap value of which to iterate the entries.
[in]user_funcUser function to call for each entry of value.
[in]user_dataUser data to pass as the user_data parameter of each call to user_func.
Return values
BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OKSuccess.
BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTEDuser_func returned BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_INTERRUPT to interrupt the iteration process.
BT_VALUE_MAP_FOREACH_ENTRY_STATUS_USER_ERRORuser_func returned BT_VALUE_MAP_FOREACH_ENTRY_FUNC_STATUS_ERROR.
BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROROut of memory.
BT_VALUE_MAP_FOREACH_ENTRY_STATUS_ERROROther error caused the bt_value_map_foreach_entry() function itself.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
user_func is not NULL.
See also
bt_value_map_foreach_entry_const()const version of this function.
bt_value_map_borrow_entry_value() — Borrows the value of a specific map value entry.

◆ bt_value_map_foreach_entry_const()

bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const ( const bt_value value,
bt_value_map_foreach_entry_const_func  user_func,
void *  user_data 
)

Iterates the entries of the map value value, calling user_func for each entry (const version).

See bt_value_map_foreach_entry().

See also
bt_value_map_borrow_entry_value_const() — Borrows the value of a specific map value entry.

◆ bt_value_map_get_size()

uint64_t bt_value_map_get_size ( const bt_value value)

Returns the size of the map value value.

Parameters
[in]valueMap value of which to get the size.
Returns
Size (number of contained entries) of value.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
See also
bt_value_map_is_empty() — Returns whether or not a map value is empty.

◆ bt_value_map_is_empty()

static bt_bool bt_value_map_is_empty ( const bt_value value)
inlinestatic

Returns whether or not the map value value is empty.

Parameters
[in]valueMap value to check.
Returns
BT_TRUE if value is empty (has the size 0).
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
See also
bt_value_map_get_size() — Returns the size of a map value.

◆ bt_value_map_has_entry()

bt_bool bt_value_map_has_entry ( const bt_value value,
const char *  key 
)

Returns whether or not the map value value has an entry with the key key.

Parameters
[in]valueMap value to check.
[in]keyKey to check.
Returns
BT_TRUE if value has an entry with the key key.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
key is not NULL.
See also
bt_value_map_borrow_entry_value_const() — Borrows the value of a specific map value entry.

◆ bt_value_map_extend()

bt_value_map_extend_status bt_value_map_extend ( bt_value value,
const bt_value extension_value 
)

Extends the map value value with the map value extension_value.

For each entry in extension_value, this function calls bt_value_map_insert_entry() to insert or replace it in the map value value.

For example, with:

value
{
"man": "giant",
"strange": 23
}

extension_value
{
"balance": -17
"strange": false
}

The map value value becomes:

{
"man": "giant",
"strange": false,
"balance": -17
}
Parameters
[in]valueMap value to extend.
[in]extension_valueExtension map value.
Return values
BT_VALUE_MAP_EXTEND_STATUS_OKSuccess.
BT_VALUE_MAP_EXTEND_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
value is a map value (bt_value_is_map() returns BT_TRUE).
extension_value is not NULL.
extension_value is a map value (bt_value_is_map() returns BT_TRUE).
See also
bt_value_copy() — Deep-copies a value.

◆ bt_value_copy()

bt_value_copy_status bt_value_copy ( const bt_value value,
bt_value **  copy_value 
)

Deep-copies a value object.

This function deep-copies value and sets *copy to the result.

Because *copy is a deep copy, it does not contain, recursively, any reference that value contains, but the raw values are identical.

Parameters
[in]valueValue to deep-copy.
[in]copy_valueOn success, *copy_value is a deep copy of value.
Return values
BT_VALUE_COPY_STATUS_OKSuccess.
BT_VALUE_COPY_STATUS_MEMORY_ERROROut of memory.
Precondition
value is not NULL.
copy_value is not NULL.

◆ bt_value_is_equal()

bt_bool bt_value_is_equal ( const bt_value a_value,
const bt_value b_value 
)

Returns whether or not the value a_value is equal, recursively, to b_value.

Note
If you want to know whether or not a value is a null value, you can also directly compare its pointer to the bt_value_null variable.
Parameters
[in]a_valueValue A.
[in]b_valueValue B.
Returns
BT_TRUE if a_value is equal, recursively, to b_value.
Precondition
a_value is not NULL.
b_value is not NULL.

◆ bt_value_get_ref()

void bt_value_get_ref ( const bt_value value)

Increments the reference count of the value value.

Parameters
[in]value

Value of which to increment the reference count.

Can be NULL.

See also
bt_value_put_ref() — Decrements the reference count of a value.

◆ bt_value_put_ref()

void bt_value_put_ref ( const bt_value value)

Decrements the reference count of the value value.

Parameters
[in]value

Value of which to decrement the reference count.

Can be NULL.

See also
bt_value_get_ref() — Increments the reference count of a value.
bt_value_type_is
static bt_bool bt_value_type_is(const bt_value_type type, const bt_value_type other_type)
Returns whether or not the value type type conceptually is the value type other_type.
Definition: value.h:386
BT_VALUE_TYPE_UNSIGNED_INTEGER
Unsigned integer value.
Definition: value.h:275
BT_VALUE_TYPE_INTEGER
Integer value.
Definition: value.h:267