/* For bt_bool */
#include <babeltrace/types.h>
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@brief Value object type.
*/
enum bt_value_type {
- /// Unknown value object, used as an error code.
- BT_VALUE_TYPE_UNKNOWN = -1,
-
/// Null value object.
BT_VALUE_TYPE_NULL = 0,
BT_VALUE_TYPE_INTEGER = 2,
/// Floating point number value object (holds a \c double raw value).
- BT_VALUE_TYPE_FLOAT = 3,
+ BT_VALUE_TYPE_REAL = 3,
/// String value object.
BT_VALUE_TYPE_STRING = 4,
@sa bt_value_get_type(): Returns the type of a given value object.
*/
static inline
-bt_bool bt_value_is_float(const struct bt_value *object)
+bt_bool bt_value_is_real(const struct bt_value *object)
{
- return bt_value_get_type(object) == BT_VALUE_TYPE_FLOAT;
+ return bt_value_get_type(object) == BT_VALUE_TYPE_REAL;
}
/**
@sa bt_value_float_create_init(): Creates an initialized floating
point number value object.
*/
-extern struct bt_value *bt_value_float_create(void);
+extern struct bt_value *bt_value_real_create(void);
/**
@brief Creates a floating point number value object with its initial raw
@sa bt_value_float_create(): Creates a default floating point number
value object.
*/
-extern struct bt_value *bt_value_float_create_init(double val);
+extern struct bt_value *bt_value_real_create_init(double val);
/**
@brief Returns the floating point number raw value of the floating point
@sa bt_value_float_set(): Sets the raw value of a given floating
point number value object.
*/
-extern enum bt_value_status bt_value_float_get(
- const struct bt_value *float_obj, double *val);
+extern enum bt_value_status bt_value_real_get(
+ const struct bt_value *real_obj, double *val);
/**
@brief Sets the floating point number raw value of the floating point
@sa bt_value_float_get(): Returns the raw value of a floating point
number value object.
*/
-extern enum bt_value_status bt_value_float_set(
- struct bt_value *float_obj, double val);
+extern enum bt_value_status bt_value_real_set(
+ struct bt_value *real_obj, double val);
/** @} */
*/
extern bt_bool bt_value_array_is_empty(const struct bt_value *array_obj);
+extern struct bt_value *bt_value_array_borrow(const struct bt_value *array_obj,
+ uint64_t index);
+
/**
@brief Returns the value object contained in the array value object
\p array_obj at the index \p index.
\ref bt_value_null</strong>, its reference count is incremented.
@postrefcountsame{array_obj}
*/
-extern struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
- uint64_t index);
+static inline
+struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
+ uint64_t index)
+{
+ return bt_get(bt_value_array_borrow(array_obj, index));
+}
/**
@brief Appends the value object \p element_obj to the array value
@sa bt_value_array_append(): Appends a value object to a given
array value object.
*/
-extern enum bt_value_status bt_value_array_append_float(
+extern enum bt_value_status bt_value_array_append_real(
struct bt_value *array_obj, double val);
/**
*/
extern bt_bool bt_value_map_is_empty(const struct bt_value *map_obj);
+extern struct bt_value *bt_value_map_borrow(const struct bt_value *map_obj,
+ const char *key);
+
/**
@brief Returns the value object associated with the key \p key within
the map value object \p map_obj.
@post <strong>On success, if the returned value object is not
\ref bt_value_null</strong>, its reference count is incremented.
*/
-extern struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
- const char *key);
+static inline
+struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
+ const char *key)
+{
+ return bt_get(bt_value_map_borrow(map_obj, key));
+}
/**
@brief User function type to use with bt_value_map_foreach().
@sa bt_value_map_insert(): Inserts a value object into a given map
value object.
*/
-extern enum bt_value_status bt_value_map_insert_float(
+extern enum bt_value_status bt_value_map_insert_real(
struct bt_value *map_obj, const char *key, double val);
/**