2 * Copyright (C) 2020 Philippe Proulx <pproulx@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
9 #define LTTNG_EVENT_FIELD_VALUE_INTERNAL_H
13 #include <lttng/event-field-value.h>
14 #include <common/dynamic-array.h>
16 struct lttng_event_field_value
{
17 enum lttng_event_field_value_type type
;
21 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_INT`.
23 struct lttng_event_field_value_uint
{
24 struct lttng_event_field_value parent
;
29 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_INT`.
31 struct lttng_event_field_value_int
{
32 struct lttng_event_field_value parent
;
37 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` and
38 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM` (base).
40 struct lttng_event_field_value_enum
{
41 struct lttng_event_field_value parent
;
44 * Array of `char *` (owned by this).
46 struct lttng_dynamic_pointer_array labels
;
50 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM`.
52 struct lttng_event_field_value_enum_uint
{
53 struct lttng_event_field_value_enum parent
;
58 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
60 struct lttng_event_field_value_enum_int
{
61 struct lttng_event_field_value_enum parent
;
65 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_REAL` */
66 struct lttng_event_field_value_real
{
67 struct lttng_event_field_value parent
;
71 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
72 struct lttng_event_field_value_string
{
73 struct lttng_event_field_value parent
;
79 /* `LTTNG_EVENT_FIELD_VALUE_TYPE_STRING` */
80 struct lttng_event_field_value_array
{
81 struct lttng_event_field_value parent
;
84 * Array of `struct lttng_event_field_value *` (owned by this).
86 * A `NULL` element means it's unavailable
87 * (`LTTNG_EVENT_FIELD_VALUE_STATUS_UNAVAILABLE` status).
89 struct lttng_dynamic_pointer_array elems
;
93 * NOTE JORAJ: This was previously public. The only slight problem with that is
94 * that as of today (2020-05-26) there is no plan/sessiond for the tracer to
95 * actually provide this information. This was already known in [1]. For now
96 * this code have no value since it only confuse the end user. At upstreaming
97 * time we will need to decide if we want to remove all code pertaining to enum
98 * label, at least on the lttng-tools API.
100 * [1] https://support.efficios.com/issues/792
102 * Sets `*count` to the number of labels of the enumeration event field
107 * `LTTNG_EVENT_FIELD_VALUE_STATUS_OK`:
110 * `LTTNG_EVENT_FIELD_VALUE_STATUS_INVALID`:
111 * * `field_val` is `NULL`.
112 * * The type of `field_val` is not
113 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
114 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
115 * * `count` is `NULL`.
118 enum lttng_event_field_value_status
119 lttng_event_field_value_enum_get_label_count(
120 const struct lttng_event_field_value
*field_val
,
121 unsigned int *count
);
124 * NOTE JORAJ: see NOTE JORAJ off lttng_event_field_value_enum_get_label_count
126 * Returns the label at index `index` of the enumeration event field
127 * value `field_val`, or `NULL` if:
129 * * `field_val` is `NULL`.
130 * * The type of `field_val` is not
131 * `LTTNG_EVENT_FIELD_VALUE_TYPE_UNSIGNED_ENUM` or
132 * `LTTNG_EVENT_FIELD_VALUE_TYPE_SIGNED_ENUM`.
133 * * `index` is greater than or equal to the label count of `field_val`,
134 * as returned by lttng_event_field_value_enum_get_label_count().
137 const char *lttng_event_field_value_enum_get_label_at_index(
138 const struct lttng_event_field_value
*field_val
,
142 struct lttng_event_field_value
*lttng_event_field_value_uint_create(
146 struct lttng_event_field_value
*lttng_event_field_value_int_create(
150 struct lttng_event_field_value
*lttng_event_field_value_enum_uint_create(
154 struct lttng_event_field_value
*lttng_event_field_value_enum_int_create(
158 struct lttng_event_field_value
*lttng_event_field_value_real_create(double val
);
161 struct lttng_event_field_value
*lttng_event_field_value_string_create(
165 struct lttng_event_field_value
*lttng_event_field_value_string_create_with_size(
166 const char *val
, size_t size
);
169 struct lttng_event_field_value
*lttng_event_field_value_array_create(void);
172 int lttng_event_field_value_enum_append_label(
173 struct lttng_event_field_value
*field_val
, const char *label
);
176 int lttng_event_field_value_enum_append_label_with_size(
177 struct lttng_event_field_value
*field_val
, const char *label
,
181 int lttng_event_field_value_array_append(
182 struct lttng_event_field_value
*array_field_val
,
183 struct lttng_event_field_value
*field_val
);
186 int lttng_event_field_value_array_append_unavailable(
187 struct lttng_event_field_value
*array_field_val
);
190 void lttng_event_field_value_destroy(struct lttng_event_field_value
*field_val
);
192 #endif /* LTTNG_EVENT_FIELD_VALUE_INTERNAL_H */