| 1 | /* |
| 2 | * SPDX-License-Identifier: MIT |
| 3 | * |
| 4 | * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com> |
| 5 | */ |
| 6 | |
| 7 | #ifndef BABELTRACE_LIB_VALUE_H |
| 8 | #define BABELTRACE_LIB_VALUE_H |
| 9 | |
| 10 | #include <glib.h> |
| 11 | #include <babeltrace2/babeltrace.h> |
| 12 | |
| 13 | #include "lib/object.h" |
| 14 | |
| 15 | struct bt_value { |
| 16 | struct bt_object base; |
| 17 | enum bt_value_type type; |
| 18 | bt_bool frozen; |
| 19 | }; |
| 20 | |
| 21 | struct bt_value_bool { |
| 22 | struct bt_value base; |
| 23 | bt_bool value; |
| 24 | }; |
| 25 | |
| 26 | struct bt_value_integer { |
| 27 | struct bt_value base; |
| 28 | union { |
| 29 | uint64_t i; |
| 30 | int64_t u; |
| 31 | } value; |
| 32 | }; |
| 33 | |
| 34 | struct bt_value_real { |
| 35 | struct bt_value base; |
| 36 | double value; |
| 37 | }; |
| 38 | |
| 39 | struct bt_value_string { |
| 40 | struct bt_value base; |
| 41 | GString *gstr; |
| 42 | }; |
| 43 | |
| 44 | struct bt_value_array { |
| 45 | struct bt_value base; |
| 46 | GPtrArray *garray; |
| 47 | }; |
| 48 | |
| 49 | struct bt_value_map { |
| 50 | struct bt_value base; |
| 51 | GHashTable *ght; |
| 52 | }; |
| 53 | |
| 54 | void _bt_value_freeze(const struct bt_value *object); |
| 55 | |
| 56 | #ifdef BT_DEV_MODE |
| 57 | # define bt_value_freeze _bt_value_freeze |
| 58 | #else |
| 59 | # define bt_value_freeze(_value) |
| 60 | #endif /* BT_DEV_MODE */ |
| 61 | |
| 62 | #endif /* BABELTRACE_LIB_VALUE_H */ |