1 #ifndef BABELTRACE_CTF_WRITER_FIELD_TYPES_H
2 #define BABELTRACE_CTF_WRITER_FIELD_TYPES_H
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * The Common Trace Format (CTF) Specification is available at
28 * http://www.efficios.com/ctf
34 #include <babeltrace/types.h>
41 struct bt_ctf_field_type
;
44 /// Unknown, used for errors.
45 BT_CTF_SCOPE_UNKNOWN
= -1,
47 /// Trace packet header.
48 BT_CTF_SCOPE_TRACE_PACKET_HEADER
= 1,
50 /// Stream packet context.
51 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
= 2,
53 /// Stream event header.
54 BT_CTF_SCOPE_STREAM_EVENT_HEADER
= 3,
56 /// Stream event context.
57 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
= 4,
60 BT_CTF_SCOPE_EVENT_CONTEXT
= 5,
63 BT_CTF_SCOPE_EVENT_PAYLOAD
= 6,
67 BT_CTF_SCOPE_EVENT_FIELDS
= 6,
71 enum bt_ctf_field_type_id
{
72 BT_CTF_FIELD_TYPE_ID_UNKNOWN
= -1,
73 BT_CTF_FIELD_TYPE_ID_INTEGER
= 0,
74 BT_CTF_FIELD_TYPE_ID_FLOAT
= 1,
75 BT_CTF_FIELD_TYPE_ID_ENUM
= 2,
76 BT_CTF_FIELD_TYPE_ID_STRING
= 3,
77 BT_CTF_FIELD_TYPE_ID_STRUCT
= 4,
78 BT_CTF_FIELD_TYPE_ID_ARRAY
= 5,
79 BT_CTF_FIELD_TYPE_ID_SEQUENCE
= 6,
80 BT_CTF_FIELD_TYPE_ID_VARIANT
= 7,
81 BT_CTF_FIELD_TYPE_ID_NR
,
84 extern enum bt_ctf_field_type_id
bt_ctf_field_type_get_type_id(
85 struct bt_ctf_field_type
*field_type
);
87 enum bt_ctf_byte_order
{
88 BT_CTF_BYTE_ORDER_UNKNOWN
= -1,
89 BT_CTF_BYTE_ORDER_NATIVE
= 0,
90 BT_CTF_BYTE_ORDER_UNSPECIFIED
,
91 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
,
92 BT_CTF_BYTE_ORDER_BIG_ENDIAN
,
93 BT_CTF_BYTE_ORDER_NETWORK
,
96 enum bt_ctf_string_encoding
{
97 BT_CTF_STRING_ENCODING_UNKNOWN
= -1,
98 BT_CTF_STRING_ENCODING_NONE
,
99 BT_CTF_STRING_ENCODING_UTF8
,
100 BT_CTF_STRING_ENCODING_ASCII
,
103 /* Pre-2.0 CTF writer compatibility */
104 #define ctf_string_encoding bt_ctf_string_encoding
106 extern int bt_ctf_field_type_get_alignment(
107 struct bt_ctf_field_type
*field_type
);
109 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type
*field_type
,
110 unsigned int alignment
);
112 extern enum bt_ctf_byte_order
bt_ctf_field_type_get_byte_order(
113 struct bt_ctf_field_type
*field_type
);
115 extern int bt_ctf_field_type_set_byte_order(
116 struct bt_ctf_field_type
*field_type
,
117 enum bt_ctf_byte_order byte_order
);
119 enum bt_ctf_integer_base
{
120 /// Unknown, used for errors.
121 BT_CTF_INTEGER_BASE_UNKNOWN
= -1,
123 /// Unspecified by the tracer.
124 BT_CTF_INTEGER_BASE_UNSPECIFIED
= 0,
127 BT_CTF_INTEGER_BASE_BINARY
= 2,
130 BT_CTF_INTEGER_BASE_OCTAL
= 8,
133 BT_CTF_INTEGER_BASE_DECIMAL
= 10,
136 BT_CTF_INTEGER_BASE_HEXADECIMAL
= 16,
139 extern struct bt_ctf_field_type
*bt_ctf_field_type_integer_create(
142 extern int bt_ctf_field_type_integer_get_size(
143 struct bt_ctf_field_type
*int_field_type
);
145 extern int bt_ctf_field_type_integer_set_size(
146 struct bt_ctf_field_type
*int_field_type
, unsigned int size
);
148 extern bt_bool
bt_ctf_field_type_integer_is_signed(
149 struct bt_ctf_field_type
*int_field_type
);
151 /* Pre-2.0 CTF writer compatibility */
153 int bt_ctf_field_type_integer_get_signed(
154 struct bt_ctf_field_type
*int_field_type
)
156 return bt_ctf_field_type_integer_is_signed(int_field_type
) ? 1 : 0;
159 extern int bt_ctf_field_type_integer_set_is_signed(
160 struct bt_ctf_field_type
*int_field_type
, bt_bool is_signed
);
162 /* Pre-2.0 CTF writer compatibility */
164 int bt_ctf_field_type_integer_set_signed(
165 struct bt_ctf_field_type
*int_field_type
, int is_signed
)
167 return bt_ctf_field_type_integer_set_is_signed(int_field_type
,
168 is_signed
? BT_TRUE
: BT_FALSE
);
171 extern enum bt_ctf_integer_base
bt_ctf_field_type_integer_get_base(
172 struct bt_ctf_field_type
*int_field_type
);
174 extern int bt_ctf_field_type_integer_set_base(
175 struct bt_ctf_field_type
*int_field_type
,
176 enum bt_ctf_integer_base base
);
178 extern enum bt_ctf_string_encoding
bt_ctf_field_type_integer_get_encoding(
179 struct bt_ctf_field_type
*int_field_type
);
181 extern int bt_ctf_field_type_integer_set_encoding(
182 struct bt_ctf_field_type
*int_field_type
,
183 enum bt_ctf_string_encoding encoding
);
185 extern struct bt_ctf_clock_class
*bt_ctf_field_type_integer_get_mapped_clock_class(
186 struct bt_ctf_field_type
*int_field_type
);
188 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
189 struct bt_ctf_field_type
*int_field_type
,
190 struct bt_ctf_clock_class
*clock_class
);
192 extern struct bt_ctf_field_type
*bt_ctf_field_type_floating_point_create(void);
194 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
195 struct bt_ctf_field_type
*float_field_type
);
197 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
198 struct bt_ctf_field_type
*float_field_type
,
199 unsigned int exponent_size
);
201 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
202 struct bt_ctf_field_type
*float_field_type
);
204 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
205 struct bt_ctf_field_type
*float_field_type
,
206 unsigned int mantissa_sign_size
);
208 extern struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_create(
209 struct bt_ctf_field_type
*int_field_type
);
212 struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_get_container_field_type(
213 struct bt_ctf_field_type
*enum_field_type
);
215 extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
216 struct bt_ctf_field_type
*enum_field_type
);
218 extern int bt_ctf_field_type_enumeration_signed_get_mapping_by_index(
219 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
220 const char **name
, int64_t *range_begin
, int64_t *range_end
);
222 extern int bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index(
223 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
224 const char **name
, uint64_t *range_begin
,
225 uint64_t *range_end
);
227 extern int bt_ctf_field_type_enumeration_signed_add_mapping(
228 struct bt_ctf_field_type
*enum_field_type
,
229 const char *name
, int64_t range_begin
, int64_t range_end
);
231 extern int bt_ctf_field_type_enumeration_unsigned_add_mapping(
232 struct bt_ctf_field_type
*enum_field_type
,
233 const char *name
, uint64_t range_begin
, uint64_t range_end
);
235 /* Pre-2.0 CTF writer compatibility */
237 int bt_ctf_field_type_enumeration_add_mapping(
238 struct bt_ctf_field_type
*enumeration
, const char *name
,
239 int64_t range_start
, int64_t range_end
)
241 return bt_ctf_field_type_enumeration_signed_add_mapping(enumeration
,
242 name
, range_start
, range_end
);
245 extern struct bt_ctf_field_type
*bt_ctf_field_type_string_create(void);
247 extern enum bt_ctf_string_encoding
bt_ctf_field_type_string_get_encoding(
248 struct bt_ctf_field_type
*string_field_type
);
250 extern int bt_ctf_field_type_string_set_encoding(
251 struct bt_ctf_field_type
*string_field_type
,
252 enum bt_ctf_string_encoding encoding
);
254 extern struct bt_ctf_field_type
*bt_ctf_field_type_structure_create(void);
256 extern int64_t bt_ctf_field_type_structure_get_field_count(
257 struct bt_ctf_field_type
*struct_field_type
);
259 extern int bt_ctf_field_type_structure_get_field_by_index(
260 struct bt_ctf_field_type
*struct_field_type
,
261 const char **field_name
, struct bt_ctf_field_type
**field_type
,
264 /* Pre-2.0 CTF writer compatibility */
266 int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type
*structure
,
267 const char **field_name
, struct bt_ctf_field_type
**field_type
,
270 return bt_ctf_field_type_structure_get_field_by_index(structure
,
271 field_name
, field_type
, (uint64_t) index
);
275 struct bt_ctf_field_type
*bt_ctf_field_type_structure_get_field_type_by_name(
276 struct bt_ctf_field_type
*struct_field_type
,
277 const char *field_name
);
279 extern int bt_ctf_field_type_structure_add_field(
280 struct bt_ctf_field_type
*struct_field_type
,
281 struct bt_ctf_field_type
*field_type
,
282 const char *field_name
);
284 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_create(
285 struct bt_ctf_field_type
*element_field_type
,
286 unsigned int length
);
288 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_get_element_field_type(
289 struct bt_ctf_field_type
*array_field_type
);
291 extern int64_t bt_ctf_field_type_array_get_length(
292 struct bt_ctf_field_type
*array_field_type
);
294 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_create(
295 struct bt_ctf_field_type
*element_field_type
,
296 const char *length_name
);
298 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_get_element_field_type(
299 struct bt_ctf_field_type
*sequence_field_type
);
301 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
302 struct bt_ctf_field_type
*sequence_field_type
);
304 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_create(
305 struct bt_ctf_field_type
*tag_field_type
,
306 const char *tag_name
);
308 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_tag_field_type(
309 struct bt_ctf_field_type
*variant_field_type
);
311 extern const char *bt_ctf_field_type_variant_get_tag_name(
312 struct bt_ctf_field_type
*variant_field_type
);
314 extern int bt_ctf_field_type_variant_set_tag_name(
315 struct bt_ctf_field_type
*variant_field_type
,
316 const char *tag_name
);
318 extern int64_t bt_ctf_field_type_variant_get_field_count(
319 struct bt_ctf_field_type
*variant_field_type
);
321 extern int bt_ctf_field_type_variant_get_field_by_index(
322 struct bt_ctf_field_type
*variant_field_type
,
323 const char **field_name
,
324 struct bt_ctf_field_type
**field_type
, uint64_t index
);
327 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_by_name(
328 struct bt_ctf_field_type
*variant_field_type
,
329 const char *field_name
);
332 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_from_tag(
333 struct bt_ctf_field_type
*variant_field_type
,
334 struct bt_ctf_field
*tag_field
);
336 extern int bt_ctf_field_type_variant_add_field(
337 struct bt_ctf_field_type
*variant_field_type
,
338 struct bt_ctf_field_type
*field_type
,
339 const char *field_name
);
345 #endif /* BABELTRACE_CTF_WRITER_FIELD_TYPES_H */