1 #ifndef BABELTRACE_CTF_WRITER_FIELD_TYPES_H
2 #define BABELTRACE_CTF_WRITER_FIELD_TYPES_H
5 * Babeltrace - CTF writer: Event Fields
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
36 #include <babeltrace/types.h>
43 struct bt_ctf_field_type
;
46 /// Unknown, used for errors.
47 BT_CTF_SCOPE_UNKNOWN
= -1,
49 /// Trace packet header.
50 BT_CTF_SCOPE_TRACE_PACKET_HEADER
= 1,
52 /// Stream packet context.
53 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
= 2,
55 /// Stream event header.
56 BT_CTF_SCOPE_STREAM_EVENT_HEADER
= 3,
58 /// Stream event context.
59 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
= 4,
62 BT_CTF_SCOPE_EVENT_CONTEXT
= 5,
65 BT_CTF_SCOPE_EVENT_PAYLOAD
= 6,
69 BT_CTF_SCOPE_EVENT_FIELDS
= 6,
73 enum bt_ctf_field_type_id
{
74 BT_CTF_FIELD_TYPE_ID_UNKNOWN
= -1,
75 BT_CTF_FIELD_TYPE_ID_INTEGER
= 0,
76 BT_CTF_FIELD_TYPE_ID_FLOAT
= 1,
77 BT_CTF_FIELD_TYPE_ID_ENUM
= 2,
78 BT_CTF_FIELD_TYPE_ID_STRING
= 3,
79 BT_CTF_FIELD_TYPE_ID_STRUCT
= 4,
80 BT_CTF_FIELD_TYPE_ID_ARRAY
= 5,
81 BT_CTF_FIELD_TYPE_ID_SEQUENCE
= 6,
82 BT_CTF_FIELD_TYPE_ID_VARIANT
= 7,
83 BT_CTF_FIELD_TYPE_ID_NR
,
86 extern enum bt_ctf_field_type_id
bt_ctf_field_type_get_type_id(
87 struct bt_ctf_field_type
*field_type
);
89 enum bt_ctf_byte_order
{
90 BT_CTF_BYTE_ORDER_UNKNOWN
= -1,
91 BT_CTF_BYTE_ORDER_NATIVE
= 0,
92 BT_CTF_BYTE_ORDER_UNSPECIFIED
,
93 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
,
94 BT_CTF_BYTE_ORDER_BIG_ENDIAN
,
95 BT_CTF_BYTE_ORDER_NETWORK
,
98 enum bt_ctf_string_encoding
{
99 BT_CTF_STRING_ENCODING_UNKNOWN
= -1,
100 BT_CTF_STRING_ENCODING_NONE
,
101 BT_CTF_STRING_ENCODING_UTF8
,
102 BT_CTF_STRING_ENCODING_ASCII
,
105 /* Pre-2.0 CTF writer compatibility */
106 #define ctf_string_encoding bt_ctf_string_encoding
108 extern int bt_ctf_field_type_get_alignment(
109 struct bt_ctf_field_type
*field_type
);
111 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type
*field_type
,
112 unsigned int alignment
);
114 extern enum bt_ctf_byte_order
bt_ctf_field_type_get_byte_order(
115 struct bt_ctf_field_type
*field_type
);
117 extern int bt_ctf_field_type_set_byte_order(
118 struct bt_ctf_field_type
*field_type
,
119 enum bt_ctf_byte_order byte_order
);
121 enum bt_ctf_integer_base
{
122 /// Unknown, used for errors.
123 BT_CTF_INTEGER_BASE_UNKNOWN
= -1,
125 /// Unspecified by the tracer.
126 BT_CTF_INTEGER_BASE_UNSPECIFIED
= 0,
129 BT_CTF_INTEGER_BASE_BINARY
= 2,
132 BT_CTF_INTEGER_BASE_OCTAL
= 8,
135 BT_CTF_INTEGER_BASE_DECIMAL
= 10,
138 BT_CTF_INTEGER_BASE_HEXADECIMAL
= 16,
141 extern struct bt_ctf_field_type
*bt_ctf_field_type_integer_create(
144 extern int bt_ctf_field_type_integer_get_size(
145 struct bt_ctf_field_type
*int_field_type
);
147 extern int bt_ctf_field_type_integer_set_size(
148 struct bt_ctf_field_type
*int_field_type
, unsigned int size
);
150 extern bt_bool
bt_ctf_field_type_integer_is_signed(
151 struct bt_ctf_field_type
*int_field_type
);
153 /* Pre-2.0 CTF writer compatibility */
155 int bt_ctf_field_type_integer_get_signed(
156 struct bt_ctf_field_type
*int_field_type
)
158 return bt_ctf_field_type_integer_is_signed(int_field_type
) ? 1 : 0;
161 extern int bt_ctf_field_type_integer_set_is_signed(
162 struct bt_ctf_field_type
*int_field_type
, bt_bool is_signed
);
164 /* Pre-2.0 CTF writer compatibility */
166 int bt_ctf_field_type_integer_set_signed(
167 struct bt_ctf_field_type
*int_field_type
, int is_signed
)
169 return bt_ctf_field_type_integer_set_is_signed(int_field_type
,
170 is_signed
? BT_TRUE
: BT_FALSE
);
173 extern enum bt_ctf_integer_base
bt_ctf_field_type_integer_get_base(
174 struct bt_ctf_field_type
*int_field_type
);
176 extern int bt_ctf_field_type_integer_set_base(
177 struct bt_ctf_field_type
*int_field_type
,
178 enum bt_ctf_integer_base base
);
180 extern enum bt_ctf_string_encoding
bt_ctf_field_type_integer_get_encoding(
181 struct bt_ctf_field_type
*int_field_type
);
183 extern int bt_ctf_field_type_integer_set_encoding(
184 struct bt_ctf_field_type
*int_field_type
,
185 enum bt_ctf_string_encoding encoding
);
187 extern struct bt_ctf_clock_class
*bt_ctf_field_type_integer_get_mapped_clock_class(
188 struct bt_ctf_field_type
*int_field_type
);
190 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
191 struct bt_ctf_field_type
*int_field_type
,
192 struct bt_ctf_clock_class
*clock_class
);
194 extern struct bt_ctf_field_type
*bt_ctf_field_type_floating_point_create(void);
196 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
197 struct bt_ctf_field_type
*float_field_type
);
199 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
200 struct bt_ctf_field_type
*float_field_type
,
201 unsigned int exponent_size
);
203 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
204 struct bt_ctf_field_type
*float_field_type
);
206 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
207 struct bt_ctf_field_type
*float_field_type
,
208 unsigned int mantissa_sign_size
);
210 extern struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_create(
211 struct bt_ctf_field_type
*int_field_type
);
214 struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_get_container_field_type(
215 struct bt_ctf_field_type
*enum_field_type
);
217 extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
218 struct bt_ctf_field_type
*enum_field_type
);
220 extern int bt_ctf_field_type_enumeration_signed_get_mapping_by_index(
221 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
222 const char **name
, int64_t *range_begin
, int64_t *range_end
);
224 extern int bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index(
225 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
226 const char **name
, uint64_t *range_begin
,
227 uint64_t *range_end
);
229 extern int bt_ctf_field_type_enumeration_signed_add_mapping(
230 struct bt_ctf_field_type
*enum_field_type
,
231 const char *name
, int64_t range_begin
, int64_t range_end
);
233 extern int bt_ctf_field_type_enumeration_unsigned_add_mapping(
234 struct bt_ctf_field_type
*enum_field_type
,
235 const char *name
, uint64_t range_begin
, uint64_t range_end
);
237 /* Pre-2.0 CTF writer compatibility */
239 int bt_ctf_field_type_enumeration_add_mapping(
240 struct bt_ctf_field_type
*enumeration
, const char *name
,
241 int64_t range_start
, int64_t range_end
)
243 return bt_ctf_field_type_enumeration_signed_add_mapping(enumeration
,
244 name
, range_start
, range_end
);
247 extern struct bt_ctf_field_type
*bt_ctf_field_type_string_create(void);
249 extern enum bt_ctf_string_encoding
bt_ctf_field_type_string_get_encoding(
250 struct bt_ctf_field_type
*string_field_type
);
252 extern int bt_ctf_field_type_string_set_encoding(
253 struct bt_ctf_field_type
*string_field_type
,
254 enum bt_ctf_string_encoding encoding
);
256 extern struct bt_ctf_field_type
*bt_ctf_field_type_structure_create(void);
258 extern int64_t bt_ctf_field_type_structure_get_field_count(
259 struct bt_ctf_field_type
*struct_field_type
);
261 extern int bt_ctf_field_type_structure_get_field_by_index(
262 struct bt_ctf_field_type
*struct_field_type
,
263 const char **field_name
, struct bt_ctf_field_type
**field_type
,
266 /* Pre-2.0 CTF writer compatibility */
268 int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type
*structure
,
269 const char **field_name
, struct bt_ctf_field_type
**field_type
,
272 return bt_ctf_field_type_structure_get_field_by_index(structure
,
273 field_name
, field_type
, (uint64_t) index
);
277 struct bt_ctf_field_type
*bt_ctf_field_type_structure_get_field_type_by_name(
278 struct bt_ctf_field_type
*struct_field_type
,
279 const char *field_name
);
281 extern int bt_ctf_field_type_structure_add_field(
282 struct bt_ctf_field_type
*struct_field_type
,
283 struct bt_ctf_field_type
*field_type
,
284 const char *field_name
);
286 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_create(
287 struct bt_ctf_field_type
*element_field_type
,
288 unsigned int length
);
290 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_get_element_field_type(
291 struct bt_ctf_field_type
*array_field_type
);
293 extern int64_t bt_ctf_field_type_array_get_length(
294 struct bt_ctf_field_type
*array_field_type
);
296 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_create(
297 struct bt_ctf_field_type
*element_field_type
,
298 const char *length_name
);
300 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_get_element_field_type(
301 struct bt_ctf_field_type
*sequence_field_type
);
303 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
304 struct bt_ctf_field_type
*sequence_field_type
);
306 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_create(
307 struct bt_ctf_field_type
*tag_field_type
,
308 const char *tag_name
);
310 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_tag_field_type(
311 struct bt_ctf_field_type
*variant_field_type
);
313 extern const char *bt_ctf_field_type_variant_get_tag_name(
314 struct bt_ctf_field_type
*variant_field_type
);
316 extern int bt_ctf_field_type_variant_set_tag_name(
317 struct bt_ctf_field_type
*variant_field_type
,
318 const char *tag_name
);
320 extern int64_t bt_ctf_field_type_variant_get_field_count(
321 struct bt_ctf_field_type
*variant_field_type
);
323 extern int bt_ctf_field_type_variant_get_field_by_index(
324 struct bt_ctf_field_type
*variant_field_type
,
325 const char **field_name
,
326 struct bt_ctf_field_type
**field_type
, uint64_t index
);
329 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_by_name(
330 struct bt_ctf_field_type
*variant_field_type
,
331 const char *field_name
);
334 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_from_tag(
335 struct bt_ctf_field_type
*variant_field_type
,
336 struct bt_ctf_field
*tag_field
);
338 extern int bt_ctf_field_type_variant_add_field(
339 struct bt_ctf_field_type
*variant_field_type
,
340 struct bt_ctf_field_type
*field_type
,
341 const char *field_name
);
347 #endif /* BABELTRACE_CTF_WRITER_FIELD_TYPES_H */