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