2 * Copyright (C) 2021 Francis Deslauriers <francis.deslauriers@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
7 #ifndef LTTNG_MAP_KEY_INTERNAL_H
8 #define LTTNG_MAP_KEY_INTERNAL_H
10 #include <common/dynamic-array.h>
11 #include <common/macros.h>
15 #include <lttng/map-key.h>
18 struct lttng_payload_view
;
19 struct lttng_map_key_token
;
21 typedef bool (*map_key_token_equal_cb
)(const struct lttng_map_key_token
*a
,
22 const struct lttng_map_key_token
*b
);
24 enum lttng_map_key_token_type
{
25 LTTNG_MAP_KEY_TOKEN_TYPE_STRING
,
26 LTTNG_MAP_KEY_TOKEN_TYPE_VARIABLE
,
29 struct lttng_map_key_token
{
30 enum lttng_map_key_token_type type
;
31 map_key_token_equal_cb equal
;
34 struct lttng_map_key_token_comm
{
38 struct lttng_map_key_token_string
{
39 struct lttng_map_key_token parent
;
43 struct lttng_map_key_token_string_comm
{
46 /* Includes null terminator. */
52 struct lttng_map_key_token_variable
{
53 struct lttng_map_key_token parent
;
54 enum lttng_map_key_token_variable_type type
;
57 struct lttng_map_key_token_variable_comm
{
62 struct lttng_map_key
{
63 /* Reference counting is only exposed to internal users*/
65 /* Array of `struct lttng_map_key_token` */
66 struct lttng_dynamic_pointer_array tokens
;
69 struct lttng_map_key_comm
{
71 /* Array of `struct lttng_map_key_token` */
76 void lttng_map_key_get(struct lttng_map_key
*key
);
79 void lttng_map_key_put(struct lttng_map_key
*key
);
82 ssize_t
lttng_map_key_create_from_payload(struct lttng_payload_view
*view
,
83 struct lttng_map_key
**key
);
86 int lttng_map_key_serialize(const struct lttng_map_key
*key
,
87 struct lttng_payload
*payload
);
90 enum lttng_map_key_status
lttng_map_key_get_token_count(
91 const struct lttng_map_key
*key
, unsigned int *count
);
94 const struct lttng_map_key_token
*lttng_map_key_get_token_at_index(
95 const struct lttng_map_key
*key
, unsigned int index
);
98 enum lttng_map_key_token_variable_type
lttng_map_key_token_variable_get_type(
99 const struct lttng_map_key_token_variable
*token
);
102 const char *lttng_map_key_token_string_get_string(
103 const struct lttng_map_key_token_string
*token
);
106 bool lttng_map_key_is_equal(
107 const struct lttng_map_key
*a
, const struct lttng_map_key
*b
);
110 void lttng_map_key_get(struct lttng_map_key
*key
);
113 void lttng_map_key_put(struct lttng_map_key
*key
);
116 struct lttng_map_key
*lttng_map_key_parse_from_string(const char *key_str
);
118 #endif /* LTTNG_MAP_KEY_INTERNAL_H */