1 #ifndef BABELTRACE_VALUES_H
2 #define BABELTRACE_VALUES_H
5 * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #include <babeltrace/types.h>
32 /* For enum bt_value_status, enum bt_value_type */
33 #include <babeltrace/value-const.h>
41 extern struct bt_value
*bt_value_null
;
43 extern struct bt_value
*bt_value_bool_create(void);
45 extern struct bt_value
*bt_value_bool_create_init(bt_bool val
);
47 extern void bt_value_bool_set(struct bt_value
*bool_obj
, bt_bool val
);
49 extern struct bt_value
*bt_value_integer_create(void);
51 extern struct bt_value
*bt_value_integer_create_init(
54 extern void bt_value_integer_set(struct bt_value
*integer_obj
, int64_t val
);
56 extern struct bt_value
*bt_value_real_create(void);
58 extern struct bt_value
*bt_value_real_create_init(double val
);
60 extern void bt_value_real_set(struct bt_value
*real_obj
, double val
);
62 extern struct bt_value
*bt_value_string_create(void);
64 extern struct bt_value
*bt_value_string_create_init(const char *val
);
66 extern enum bt_value_status
bt_value_string_set(struct bt_value
*string_obj
,
69 extern struct bt_value
*bt_value_array_create(void);
71 extern struct bt_value
*bt_value_array_borrow_element_by_index(
72 struct bt_value
*array_obj
, uint64_t index
);
74 extern enum bt_value_status
bt_value_array_append_element(
75 struct bt_value
*array_obj
,
76 struct bt_value
*element_obj
);
78 extern enum bt_value_status
bt_value_array_append_bool_element(
79 struct bt_value
*array_obj
, bt_bool val
);
81 extern enum bt_value_status
bt_value_array_append_integer_element(
82 struct bt_value
*array_obj
, int64_t val
);
84 extern enum bt_value_status
bt_value_array_append_real_element(
85 struct bt_value
*array_obj
, double val
);
87 extern enum bt_value_status
bt_value_array_append_string_element(
88 struct bt_value
*array_obj
, const char *val
);
90 extern enum bt_value_status
bt_value_array_append_empty_array_element(
91 struct bt_value
*array_obj
);
93 extern enum bt_value_status
bt_value_array_append_empty_map_element(
94 struct bt_value
*array_obj
);
96 extern enum bt_value_status
bt_value_array_set_element_by_index(
97 struct bt_value
*array_obj
, uint64_t index
,
98 struct bt_value
*element_obj
);
100 extern struct bt_value
*bt_value_map_create(void);
102 extern struct bt_value
*bt_value_map_borrow_entry_value(
103 struct bt_value
*map_obj
, const char *key
);
105 typedef bt_bool (* bt_value_map_foreach_entry_func
)(const char *key
,
106 struct bt_value
*object
, void *data
);
108 extern enum bt_value_status
bt_value_map_foreach_entry(
109 struct bt_value
*map_obj
,
110 bt_value_map_foreach_entry_func func
, void *data
);
112 extern enum bt_value_status
bt_value_map_insert_entry(
113 struct bt_value
*map_obj
, const char *key
,
114 struct bt_value
*element_obj
);
116 extern enum bt_value_status
bt_value_map_insert_bool_entry(
117 struct bt_value
*map_obj
, const char *key
, bt_bool val
);
119 extern enum bt_value_status
bt_value_map_insert_integer_entry(
120 struct bt_value
*map_obj
, const char *key
, int64_t val
);
122 extern enum bt_value_status
bt_value_map_insert_real_entry(
123 struct bt_value
*map_obj
, const char *key
, double val
);
125 extern enum bt_value_status
bt_value_map_insert_string_entry(
126 struct bt_value
*map_obj
, const char *key
,
129 extern enum bt_value_status
bt_value_map_insert_empty_array_entry(
130 struct bt_value
*map_obj
, const char *key
);
132 extern enum bt_value_status
bt_value_map_insert_empty_map_entry(
133 struct bt_value
*map_obj
, const char *key
);
139 #endif /* BABELTRACE_VALUES_H */