values: make `bt_value_map_extend()` extend the provided base map
[babeltrace.git] / include / babeltrace2 / value.h
CommitLineData
3fd40f46
PP
1#ifndef BABELTRACE2_VALUE_H
2#define BABELTRACE2_VALUE_H
dac5c838
PP
3
4/*
0dcb770f 5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
dac5c838
PP
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
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
23 * SOFTWARE.
24 */
25
9df34b44
PP
26#ifndef __BT_IN_BABELTRACE_H
27# error "Please include <babeltrace2/babeltrace.h> instead."
28#endif
29
dac5c838 30#include <stdint.h>
dac5c838 31#include <stddef.h>
e0831b38 32
71c5da58 33#include <babeltrace2/types.h>
71c5da58 34#include <babeltrace2/value-const.h>
78cf9df6 35
dac5c838
PP
36#ifdef __cplusplus
37extern "C" {
38#endif
39
038be990 40extern bt_value *const bt_value_null;
dac5c838 41
8eee8ea2 42extern bt_value *bt_value_bool_create(void);
dac5c838 43
8eee8ea2 44extern bt_value *bt_value_bool_create_init(bt_bool val);
dac5c838 45
8eee8ea2 46extern void bt_value_bool_set(bt_value *bool_obj, bt_bool val);
dac5c838 47
60bbfc7c 48extern bt_value *bt_value_integer_unsigned_create(void);
dac5c838 49
60bbfc7c 50extern bt_value *bt_value_integer_unsigned_create_init(uint64_t val);
dac5c838 51
60bbfc7c 52extern void bt_value_integer_unsigned_set(bt_value *integer_obj, uint64_t val);
68d9d039 53
60bbfc7c 54extern bt_value *bt_value_integer_signed_create(void);
68d9d039 55
60bbfc7c 56extern bt_value *bt_value_integer_signed_create_init(int64_t val);
68d9d039 57
60bbfc7c 58extern void bt_value_integer_signed_set(bt_value *integer_obj, int64_t val);
de079588 59
8eee8ea2 60extern bt_value *bt_value_real_create(void);
de079588 61
8eee8ea2 62extern bt_value *bt_value_real_create_init(double val);
dac5c838 63
8eee8ea2 64extern void bt_value_real_set(bt_value *real_obj, double val);
dac5c838 65
8eee8ea2 66extern bt_value *bt_value_string_create(void);
dac5c838 67
8eee8ea2 68extern bt_value *bt_value_string_create_init(const char *val);
dac5c838 69
fb25b9e3
PP
70typedef enum bt_value_string_set_status {
71 BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
72 BT_VALUE_STRING_SET_STATUS_OK = __BT_FUNC_STATUS_OK,
73} bt_value_string_set_status;
74
75extern bt_value_string_set_status bt_value_string_set(bt_value *string_obj,
ce141536 76 const char *val);
de079588 77
8eee8ea2 78extern bt_value *bt_value_array_create(void);
dac5c838 79
fb25b9e3
PP
80extern bt_value *bt_value_array_borrow_element_by_index(bt_value *array_obj,
81 uint64_t index);
dac5c838 82
fb25b9e3
PP
83typedef enum bt_value_array_append_element_status {
84 BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
85 BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK = __BT_FUNC_STATUS_OK,
86} bt_value_array_append_element_status;
dac5c838 87
fb25b9e3
PP
88extern bt_value_array_append_element_status bt_value_array_append_element(
89 bt_value *array_obj, bt_value *element_obj);
ce141536 90
fb25b9e3
PP
91extern bt_value_array_append_element_status
92bt_value_array_append_bool_element(bt_value *array_obj, bt_bool val);
68d9d039 93
fb25b9e3
PP
94extern bt_value_array_append_element_status
95bt_value_array_append_unsigned_integer_element(bt_value *array_obj,
96 uint64_t val);
ce141536 97
fb25b9e3
PP
98extern bt_value_array_append_element_status
99bt_value_array_append_signed_integer_element(bt_value *array_obj, int64_t val);
ce141536 100
fb25b9e3
PP
101extern bt_value_array_append_element_status
102bt_value_array_append_real_element(bt_value *array_obj, double val);
ce141536 103
fb25b9e3
PP
104extern bt_value_array_append_element_status
105bt_value_array_append_string_element(bt_value *array_obj, const char *val);
ce141536 106
fb25b9e3 107extern bt_value_array_append_element_status
1b8e1443
PP
108bt_value_array_append_empty_array_element(bt_value *array_obj,
109 bt_value **element_obj);
ce141536 110
fb25b9e3 111extern bt_value_array_append_element_status
1b8e1443
PP
112bt_value_array_append_empty_map_element(bt_value *array_obj,
113 bt_value **element_obj);
fb25b9e3
PP
114
115typedef enum bt_value_array_set_element_by_index_status {
116 BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
117 BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OK = __BT_FUNC_STATUS_OK,
118} bt_value_array_set_element_by_index_status;
119
120extern bt_value_array_set_element_by_index_status
121bt_value_array_set_element_by_index(bt_value *array_obj, uint64_t index,
8eee8ea2 122 bt_value *element_obj);
ce141536 123
8eee8ea2 124extern bt_value *bt_value_map_create(void);
dac5c838 125
8eee8ea2
PP
126extern bt_value *bt_value_map_borrow_entry_value(
127 bt_value *map_obj, const char *key);
dac5c838 128
78cf9df6 129typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key,
8eee8ea2 130 bt_value *object, void *data);
de079588 131
fb25b9e3 132typedef enum bt_value_map_foreach_entry_status {
fb25b9e3 133 BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK,
d73bb381 134 BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED = __BT_FUNC_STATUS_INTERRUPTED,
fb25b9e3 135} bt_value_map_foreach_entry_status;
dac5c838 136
fb25b9e3
PP
137extern bt_value_map_foreach_entry_status bt_value_map_foreach_entry(
138 bt_value *map_obj, bt_value_map_foreach_entry_func func,
139 void *data);
ce141536 140
fb25b9e3
PP
141typedef enum bt_value_map_insert_entry_status {
142 BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
143 BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK,
144} bt_value_map_insert_entry_status;
145
146extern bt_value_map_insert_entry_status bt_value_map_insert_entry(
147 bt_value *map_obj, const char *key, bt_value *element_obj);
148
149extern bt_value_map_insert_entry_status bt_value_map_insert_bool_entry(
8eee8ea2 150 bt_value *map_obj, const char *key, bt_bool val);
ce141536 151
fb25b9e3
PP
152extern bt_value_map_insert_entry_status
153bt_value_map_insert_unsigned_integer_entry(bt_value *map_obj, const char *key,
154 uint64_t val);
68d9d039 155
fb25b9e3
PP
156extern bt_value_map_insert_entry_status
157bt_value_map_insert_signed_integer_entry(bt_value *map_obj, const char *key,
158 int64_t val);
ce141536 159
fb25b9e3 160extern bt_value_map_insert_entry_status bt_value_map_insert_real_entry(
8eee8ea2 161 bt_value *map_obj, const char *key, double val);
ce141536 162
fb25b9e3
PP
163extern bt_value_map_insert_entry_status
164bt_value_map_insert_string_entry(bt_value *map_obj, const char *key,
ce141536
PP
165 const char *val);
166
fb25b9e3 167extern bt_value_map_insert_entry_status
1b8e1443
PP
168bt_value_map_insert_empty_array_entry(bt_value *map_obj, const char *key,
169 bt_value **entry_obj);
dac5c838 170
fb25b9e3 171extern bt_value_map_insert_entry_status
1b8e1443
PP
172bt_value_map_insert_empty_map_entry(bt_value *map_obj, const char *key,
173 bt_value **entry_obj);
770750d3 174
ca914e54
FD
175typedef enum bt_value_map_extend_status {
176 BT_VALUE_MAP_EXTEND_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
177 BT_VALUE_MAP_EXTEND_STATUS_OK = __BT_FUNC_STATUS_OK,
178} bt_value_map_extend_status;
179
180extern bt_value_map_extend_status bt_value_map_extend(
181 bt_value *base_map_obj,
182 const bt_value *extension_map_obj);
183
dac5c838
PP
184#ifdef __cplusplus
185}
186#endif
187
3fd40f46 188#endif /* BABELTRACE2_VALUE_H */
This page took 0.067351 seconds and 4 git commands to generate.