lib: add unsigned and signed integer value API
[babeltrace.git] / include / babeltrace / value.h
CommitLineData
1ca80abd
PP
1#ifndef BABELTRACE_VALUES_H
2#define BABELTRACE_VALUES_H
dac5c838
PP
3
4/*
05e21286 5 * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
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
dac5c838 26#include <stdint.h>
dac5c838 27#include <stddef.h>
9d408fca 28
b19ff26f 29/* For bt_bool, bt_value */
c55a9f58 30#include <babeltrace/types.h>
dac5c838 31
4cdfc5e8 32/* For bt_value_status, bt_value_type */
c6bd8523 33#include <babeltrace/value-const.h>
40f4ba76 34
dac5c838
PP
35#ifdef __cplusplus
36extern "C" {
37#endif
38
211796dc 39extern bt_value *const bt_value_null;
dac5c838 40
b19ff26f 41extern bt_value *bt_value_bool_create(void);
dac5c838 42
b19ff26f 43extern bt_value *bt_value_bool_create_init(bt_bool val);
dac5c838 44
b19ff26f 45extern void bt_value_bool_set(bt_value *bool_obj, bt_bool val);
dac5c838 46
fdd3a2da 47extern bt_value *bt_value_unsigned_integer_create(void);
dac5c838 48
fdd3a2da 49extern bt_value *bt_value_unsigned_integer_create_init(uint64_t val);
dac5c838 50
fdd3a2da
PP
51extern void bt_value_unsigned_integer_set(bt_value *integer_obj, uint64_t val);
52
53extern bt_value *bt_value_signed_integer_create(void);
54
55extern bt_value *bt_value_signed_integer_create_init(int64_t val);
56
57extern void bt_value_signed_integer_set(bt_value *integer_obj, int64_t val);
de079588 58
b19ff26f 59extern bt_value *bt_value_real_create(void);
de079588 60
b19ff26f 61extern bt_value *bt_value_real_create_init(double val);
dac5c838 62
b19ff26f 63extern void bt_value_real_set(bt_value *real_obj, double val);
dac5c838 64
b19ff26f 65extern bt_value *bt_value_string_create(void);
dac5c838 66
b19ff26f 67extern bt_value *bt_value_string_create_init(const char *val);
dac5c838 68
4cdfc5e8 69extern bt_value_status bt_value_string_set(bt_value *string_obj,
05e21286 70 const char *val);
de079588 71
b19ff26f 72extern bt_value *bt_value_array_create(void);
dac5c838 73
b19ff26f
PP
74extern bt_value *bt_value_array_borrow_element_by_index(
75 bt_value *array_obj, uint64_t index);
dac5c838 76
4cdfc5e8 77extern bt_value_status bt_value_array_append_element(
b19ff26f
PP
78 bt_value *array_obj,
79 bt_value *element_obj);
dac5c838 80
4cdfc5e8 81extern bt_value_status bt_value_array_append_bool_element(
b19ff26f 82 bt_value *array_obj, bt_bool val);
05e21286 83
fdd3a2da
PP
84extern bt_value_status bt_value_array_append_unsigned_integer_element(
85 bt_value *array_obj, uint64_t val);
86
87extern bt_value_status bt_value_array_append_signed_integer_element(
b19ff26f 88 bt_value *array_obj, int64_t val);
05e21286 89
4cdfc5e8 90extern bt_value_status bt_value_array_append_real_element(
b19ff26f 91 bt_value *array_obj, double val);
05e21286 92
4cdfc5e8 93extern bt_value_status bt_value_array_append_string_element(
b19ff26f 94 bt_value *array_obj, const char *val);
05e21286 95
4cdfc5e8 96extern bt_value_status bt_value_array_append_empty_array_element(
b19ff26f 97 bt_value *array_obj);
05e21286 98
4cdfc5e8 99extern bt_value_status bt_value_array_append_empty_map_element(
b19ff26f 100 bt_value *array_obj);
05e21286 101
4cdfc5e8 102extern bt_value_status bt_value_array_set_element_by_index(
b19ff26f
PP
103 bt_value *array_obj, uint64_t index,
104 bt_value *element_obj);
05e21286 105
b19ff26f 106extern bt_value *bt_value_map_create(void);
dac5c838 107
b19ff26f
PP
108extern bt_value *bt_value_map_borrow_entry_value(
109 bt_value *map_obj, const char *key);
dac5c838 110
40f4ba76 111typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key,
b19ff26f 112 bt_value *object, void *data);
de079588 113
4cdfc5e8 114extern bt_value_status bt_value_map_foreach_entry(
b19ff26f 115 bt_value *map_obj,
40f4ba76 116 bt_value_map_foreach_entry_func func, void *data);
dac5c838 117
4cdfc5e8 118extern bt_value_status bt_value_map_insert_entry(
b19ff26f
PP
119 bt_value *map_obj, const char *key,
120 bt_value *element_obj);
05e21286 121
4cdfc5e8 122extern bt_value_status bt_value_map_insert_bool_entry(
b19ff26f 123 bt_value *map_obj, const char *key, bt_bool val);
05e21286 124
fdd3a2da
PP
125extern bt_value_status bt_value_map_insert_unsigned_integer_entry(
126 bt_value *map_obj, const char *key, uint64_t val);
127
128extern bt_value_status bt_value_map_insert_signed_integer_entry(
b19ff26f 129 bt_value *map_obj, const char *key, int64_t val);
05e21286 130
4cdfc5e8 131extern bt_value_status bt_value_map_insert_real_entry(
b19ff26f 132 bt_value *map_obj, const char *key, double val);
05e21286 133
4cdfc5e8 134extern bt_value_status bt_value_map_insert_string_entry(
b19ff26f 135 bt_value *map_obj, const char *key,
05e21286
PP
136 const char *val);
137
4cdfc5e8 138extern bt_value_status bt_value_map_insert_empty_array_entry(
b19ff26f 139 bt_value *map_obj, const char *key);
dac5c838 140
4cdfc5e8 141extern bt_value_status bt_value_map_insert_empty_map_entry(
b19ff26f 142 bt_value *map_obj, const char *key);
770750d3 143
dac5c838
PP
144#ifdef __cplusplus
145}
146#endif
147
1ca80abd 148#endif /* BABELTRACE_VALUES_H */
This page took 0.063751 seconds and 4 git commands to generate.