X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fvalues.h;h=f6a9de549f68ec6a8a8ce6be35196ecf5bff029c;hb=05e2128659970c32648a01255ed870449f05d518;hp=5919b3ddf9f0e3823287ed156ab2a8cc7a2ba5b9;hpb=398454ed067b95215c7affbe265fd36edab931ee;p=babeltrace.git diff --git a/include/babeltrace/values.h b/include/babeltrace/values.h index 5919b3dd..f6a9de54 100644 --- a/include/babeltrace/values.h +++ b/include/babeltrace/values.h @@ -3,7 +3,7 @@ /* * Copyright (c) 2015-2016 EfficiOS Inc. and Linux Foundation - * Copyright (c) 2015-2016 Philippe Proulx + * Copyright (c) 2015-2018 Philippe Proulx * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -34,9 +34,6 @@ extern "C" { #endif -/** -@brief Status codes. -*/ enum bt_value_status { /// Operation canceled. BT_VALUE_STATUS_CANCELED = 125, @@ -48,11 +45,6 @@ enum bt_value_status { BT_VALUE_STATUS_OK = 0, }; -struct bt_value; -struct bt_private_value; - -extern struct bt_value *bt_value_null; - enum bt_value_type { /// Null value object. BT_VALUE_TYPE_NULL = 0, @@ -76,100 +68,101 @@ enum bt_value_type { BT_VALUE_TYPE_MAP = 6, }; -extern enum bt_value_type bt_value_get_type(const struct bt_value *object); - -static inline -bt_bool bt_value_is_null(const struct bt_value *object) -{ - return bt_value_get_type(object) == BT_VALUE_TYPE_NULL; -} +struct bt_value; -static inline -bt_bool bt_value_is_bool(const struct bt_value *object) -{ - return bt_value_get_type(object) == BT_VALUE_TYPE_BOOL; -} +extern struct bt_value *bt_value_null; -static inline -bt_bool bt_value_is_integer(const struct bt_value *object) -{ - return bt_value_get_type(object) == BT_VALUE_TYPE_INTEGER; -} +extern struct bt_value *bt_value_bool_create(void); -static inline -bt_bool bt_value_is_real(const struct bt_value *object) -{ - return bt_value_get_type(object) == BT_VALUE_TYPE_REAL; -} +extern struct bt_value *bt_value_bool_create_init(bt_bool val); -static inline -bt_bool bt_value_is_string(const struct bt_value *object) -{ - return bt_value_get_type(object) == BT_VALUE_TYPE_STRING; -} +extern void bt_value_bool_set(struct bt_value *bool_obj, bt_bool val); -static inline -bt_bool bt_value_is_array(const struct bt_value *object) -{ - return bt_value_get_type(object) == BT_VALUE_TYPE_ARRAY; -} +extern struct bt_value *bt_value_integer_create(void); -static inline -bt_bool bt_value_is_map(const struct bt_value *object) -{ - return bt_value_get_type(object) == BT_VALUE_TYPE_MAP; -} +extern struct bt_value *bt_value_integer_create_init( + int64_t val); -extern enum bt_value_status bt_value_copy(struct bt_private_value **copy, - const struct bt_value *object); +extern void bt_value_integer_set(struct bt_value *integer_obj, int64_t val); -extern bt_bool bt_value_compare(const struct bt_value *object_a, - const struct bt_value *object_b); +extern struct bt_value *bt_value_real_create(void); -extern bt_bool bt_value_bool_get(const struct bt_value *bool_obj); +extern struct bt_value *bt_value_real_create_init(double val); -extern int64_t bt_value_integer_get(const struct bt_value *integer_obj); +extern void bt_value_real_set(struct bt_value *real_obj, double val); -extern double bt_value_real_get(const struct bt_value *real_obj); +extern struct bt_value *bt_value_string_create(void); -extern const char *bt_value_string_get(const struct bt_value *string_obj); +extern struct bt_value *bt_value_string_create_init(const char *val); -extern uint64_t bt_value_array_get_size(const struct bt_value *array_obj); +extern enum bt_value_status bt_value_string_set(struct bt_value *string_obj, + const char *val); -static inline -bt_bool bt_value_array_is_empty(const struct bt_value *array_obj) -{ - return bt_value_array_get_size(array_obj) == 0; -} +extern struct bt_value *bt_value_array_create(void); extern struct bt_value *bt_value_array_borrow_element_by_index( - const struct bt_value *array_obj, uint64_t index); + struct bt_value *array_obj, uint64_t index); -extern uint64_t bt_value_map_get_size(const struct bt_value *map_obj); +extern enum bt_value_status bt_value_array_append_element( + struct bt_value *array_obj, + struct bt_value *element_obj); -static inline -bt_bool bt_value_map_is_empty(const struct bt_value *map_obj) -{ - return bt_value_map_get_size(map_obj) == 0; -} +extern enum bt_value_status bt_value_array_append_bool_element( + struct bt_value *array_obj, bt_bool val); + +extern enum bt_value_status bt_value_array_append_integer_element( + struct bt_value *array_obj, int64_t val); + +extern enum bt_value_status bt_value_array_append_real_element( + struct bt_value *array_obj, double val); + +extern enum bt_value_status bt_value_array_append_string_element( + struct bt_value *array_obj, const char *val); + +extern enum bt_value_status bt_value_array_append_empty_array_element( + struct bt_value *array_obj); + +extern enum bt_value_status bt_value_array_append_empty_map_element( + struct bt_value *array_obj); + +extern enum bt_value_status bt_value_array_set_element_by_index( + struct bt_value *array_obj, uint64_t index, + struct bt_value *element_obj); + +extern struct bt_value *bt_value_map_create(void); extern struct bt_value *bt_value_map_borrow_entry_value( - const struct bt_value *map_obj, const char *key); + struct bt_value *map_obj, const char *key); typedef bt_bool (* bt_value_map_foreach_entry_cb)(const char *key, - struct bt_value *object, void *data); + struct bt_value *object, void *data); extern enum bt_value_status bt_value_map_foreach_entry( - const struct bt_value *map_obj, + struct bt_value *map_obj, bt_value_map_foreach_entry_cb cb, void *data); -extern bt_bool bt_value_map_has_entry(const struct bt_value *map_obj, - const char *key); +extern enum bt_value_status bt_value_map_insert_entry( + struct bt_value *map_obj, const char *key, + struct bt_value *element_obj); + +extern enum bt_value_status bt_value_map_insert_bool_entry( + struct bt_value *map_obj, const char *key, bt_bool val); + +extern enum bt_value_status bt_value_map_insert_integer_entry( + struct bt_value *map_obj, const char *key, int64_t val); + +extern enum bt_value_status bt_value_map_insert_real_entry( + struct bt_value *map_obj, const char *key, double val); + +extern enum bt_value_status bt_value_map_insert_string_entry( + struct bt_value *map_obj, const char *key, + const char *val); + +extern enum bt_value_status bt_value_map_insert_empty_array_entry( + struct bt_value *map_obj, const char *key); -extern enum bt_value_status bt_value_map_extend( - struct bt_private_value **extended_map_obj, - const struct bt_value *base_map_obj, - const struct bt_value *extension_map_obj); +extern enum bt_value_status bt_value_map_insert_empty_map_entry( + struct bt_value *map_obj, const char *key); #ifdef __cplusplus }