ir: clock class: use bt_bool instead of int for boolean properties
[babeltrace.git] / include / babeltrace / ctf-ir / fields.h
CommitLineData
2e33ac5a
PP
1#ifndef BABELTRACE_CTF_IR_FIELDS_H
2#define BABELTRACE_CTF_IR_FIELDS_H
adc315b8
JG
3
4/*
2e33ac5a 5 * Babeltrace - CTF IR: Event Fields
adc315b8 6 *
de9dd397 7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
adc315b8
JG
8 *
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
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
27 * SOFTWARE.
28 *
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
31 */
32
33#include <stdint.h>
cd95e351 34#include <stddef.h>
544d0515 35#include <babeltrace/ctf-ir/field-types.h>
adc315b8
JG
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
91f379cb
PP
41/**
42@defgroup ctfirfields CTF IR fields
43@ingroup ctfir
44@brief CTF IR fields.
45
46@code
47#include <babeltrace/ctf-ir/fields.h>
48@endcode
49
50A CTF IR <strong><em>field</em></strong> is an object which holds a
51concrete value, and which is described by a @ft.
52
53In the CTF IR hierarchy, you can set the root fields of two objects:
54
55- \ref ctfirpacket
56 - Trace packet header field: bt_ctf_packet_set_header().
57 - Stream packet context field: bt_ctf_packet_set_context().
58- \ref ctfirevent
59 - Stream event header field: bt_ctf_event_set_header().
60 - Stream event context field: bt_ctf_event_set_stream_event_context().
61 - Event context field: bt_ctf_event_set_event_context().
62 - Event payload field: bt_ctf_event_set_payload_field().
63
64There are two categories of fields:
65
66- <strong>Basic fields</strong>:
67 - @intfield: contains an integral value.
68 - @floatfield: contains a floating point number value.
69 - @enumfield: contains an integer field which contains an integral
70 value.
71 - @stringfield: contains a string value.
72- <strong>Compound fields</strong>:
73 - @structfield: contains an ordered list of named fields
74 (possibly with different @fts).
75 - @arrayfield: contains an ordered list of fields which share
76 the same field type.
77 - @seqfield: contains an ordered list of fields which share
78 the same field type.
79 - @varfield: contains a single, current field.
80
81You can create a field object from a @ft object with
82bt_ctf_field_create(). The enumeration and compound fields create their
83contained fields with the following getters if such fields do not exist
84yet:
85
86- bt_ctf_field_enumeration_get_container()
87- bt_ctf_field_structure_get_field()
88- bt_ctf_field_array_get_field()
89- bt_ctf_field_sequence_get_field()
90- bt_ctf_field_variant_get_field()
91
7fcd5734
JD
92If you already have a field object, you can also assign it to a specific
93name within a @structfield with bt_ctf_field_structure_set_field().
94
91f379cb
PP
95You can get a reference to the @ft which was used to create a field with
96bt_ctf_field_get_type(). You can get the
1487a16a 97\link #bt_ctf_field_type_id type ID\endlink of this field type directly with
91f379cb
PP
98bt_ctf_field_get_type_id().
99
100You can get a deep copy of a field with bt_ctf_field_copy(). The field
101copy, and its contained field copies if it's the case, have the same
102field type as the originals.
103
104As with any Babeltrace object, CTF IR field objects have
105<a href="https://en.wikipedia.org/wiki/Reference_counting">reference
106counts</a>. See \ref refs to learn more about the reference counting
107management of Babeltrace objects.
108
109The functions which freeze CTF IR \link ctfirpacket packet\endlink and
110\link ctfirevent event\endlink objects also freeze their root field
111objects. You cannot modify a frozen field object: it is considered
112immutable, except for \link refs reference counting\endlink.
113
114@sa ctfirfieldtypes
115
116@file
117@brief CTF IR fields type and functions.
118@sa ctfirfields
119
120@addtogroup ctfirfields
121@{
122*/
123
124/**
125@struct bt_ctf_field
126@brief A CTF IR field.
127@sa ctfirfields
128*/
129struct bt_ctf_field;
adc315b8
JG
130struct bt_ctf_event_class;
131struct bt_ctf_event;
adc315b8 132struct bt_ctf_field_type;
e0f15669 133struct bt_ctf_field_type_enumeration_mapping_iterator;
adc315b8 134
91f379cb
PP
135/**
136@name Creation and parent field type access functions
137@{
138*/
139
140/**
141@brief Creates an uninitialized @field described by the @ft
142 \p field_type.
143
144On success, \p field_type becomes the parent of the created field
145object.
146
147On success, this function creates an \em uninitialized field: it has
148no value. You need to set the value of the created field with one of the
149its specific setters.
150
151@param[in] field_type Field type which describes the field to create.
152@returns Created field object, or \c NULL on error.
153
154@prenotnull{field_type}
155@postsuccessrefcountret1
156@postsuccessfrozen{field_type}
157*/
adc315b8 158extern struct bt_ctf_field *bt_ctf_field_create(
91f379cb 159 struct bt_ctf_field_type *field_type);
adc315b8 160
91f379cb
PP
161/**
162@brief Returns the parent @ft of the @field \p field.
adc315b8 163
91f379cb
PP
164This function returns a reference to the field type which was used to
165create the field object in the first place with bt_ctf_field_create().
cd95e351 166
91f379cb
PP
167@param[in] field Field of which to get the parent field type.
168@returns Parent field type of \p event,
169 or \c NULL on error.
adc315b8 170
91f379cb
PP
171@prenotnull{field}
172@postrefcountsame{field}
173@postsuccessrefcountretinc
174*/
175extern struct bt_ctf_field_type *bt_ctf_field_get_type(
176 struct bt_ctf_field *field);
cd95e351 177
91f379cb 178/** @} */
adc315b8 179
91f379cb
PP
180/**
181@name Type information
182@{
183*/
adc315b8 184
91f379cb
PP
185/**
186@brief Returns the type ID of the @ft of the @field \p field.
adc315b8 187
91f379cb
PP
188@param[in] field Field of which to get the type ID of its
189 parent field type..
190@returns Type ID of the parent field type of \p field,
1487a16a 191 or #BT_CTF_FIELD_TYPE_ID_UNKNOWN on error.
3f4a108d 192
91f379cb
PP
193@prenotnull{field}
194@postrefcountsame{field}
f78d67fb 195
1487a16a 196@sa #bt_ctf_field_type_id: CTF IR field type ID.
91f379cb
PP
197@sa bt_ctf_field_is_integer(): Returns whether or not a given field is a
198 @intfield.
199@sa bt_ctf_field_is_floating_point(): Returns whether or not a given
200 field is a @floatfield.
201@sa bt_ctf_field_is_enumeration(): Returns whether or not a given field
202 is a @enumfield.
203@sa bt_ctf_field_is_string(): Returns whether or not a given field is a
204 @stringfield.
205@sa bt_ctf_field_is_structure(): Returns whether or not a given field is
206 a @structfield.
207@sa bt_ctf_field_is_array(): Returns whether or not a given field is a
208 @arrayfield.
209@sa bt_ctf_field_is_sequence(): Returns whether or not a given field is
210 a @seqfield.
211@sa bt_ctf_field_is_variant(): Returns whether or not a given field is a
212 @varfield.
213*/
1487a16a 214extern enum bt_ctf_field_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field);
adc315b8 215
96e8f959
MD
216/*
217 * bt_ctf_field_signed_integer_get_value: get a signed integer field's value
218 *
219 * Get a signed integer field's value.
220 *
221 * @param integer Signed integer field instance.
222 * @param value Pointer to a signed integer where the value will be stored.
223 *
224 * Returns 0 on success, a negative value on error.
225 */
226extern int bt_ctf_field_signed_integer_get_value(struct bt_ctf_field *integer,
227 int64_t *value);
228
91f379cb
PP
229/**
230@brief Returns whether or not the @field \p field is a @intfield.
cd95e351 231
91f379cb
PP
232@param[in] field Field to check (can be \c NULL).
233@returns 1 if \p field is an integer field, or 0
234 otherwise (including if \p field is
235 \c NULL).
cd95e351 236
91f379cb
PP
237@prenotnull{field}
238@postrefcountsame{field}
adc315b8 239
91f379cb
PP
240@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
241 field's type.
242*/
243extern int bt_ctf_field_is_integer(struct bt_ctf_field *field);
cd95e351 244
91f379cb
PP
245/**
246@brief Returns whether or not the @field \p field is a @floatfield.
adc315b8 247
91f379cb
PP
248@param[in] field Field to check (can be \c NULL).
249@returns 1 if \p field is a floating point number field,
250 or 0 otherwise (including if \p field is
251 \c NULL).
252
253@prenotnull{field}
254@postrefcountsame{field}
255
256@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
257 field's type.
258*/
259extern int bt_ctf_field_is_floating_point(struct bt_ctf_field *field);
260
261/**
262@brief Returns whether or not the @field \p field is a @enumfield.
263
264@param[in] field Field to check (can be \c NULL).
265@returns 1 if \p field is an enumeration field, or 0
266 otherwise (including if \p field is
267 \c NULL).
268
269@prenotnull{field}
270@postrefcountsame{field}
271
272@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
273 field's type.
274*/
275extern int bt_ctf_field_is_enumeration(struct bt_ctf_field *field);
276
277/**
278@brief Returns whether or not the @field \p field is a @stringfield.
279
280@param[in] field Field to check (can be \c NULL).
281@returns 1 if \p field is a string field, or 0
282 otherwise (including if \p field is
283 \c NULL).
284
285@prenotnull{field}
286@postrefcountsame{field}
287
288@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
289 field's type.
290*/
291extern int bt_ctf_field_is_string(struct bt_ctf_field *field);
292
293/**
294@brief Returns whether or not the @field \p field is a @structfield.
295
296@param[in] field Field to check (can be \c NULL).
297@returns 1 if \p field is a structure field, or 0
298 otherwise (including if \p field is
299 \c NULL).
300
301@prenotnull{field}
302@postrefcountsame{field}
303
304@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
305 field's type.
306*/
307extern int bt_ctf_field_is_structure(struct bt_ctf_field *field);
308
309/**
310@brief Returns whether or not the @field \p field is a @arrayfield.
311
312@param[in] field Field to check (can be \c NULL).
313@returns 1 if \p field is an array field, or 0
314 otherwise (including if \p field is
315 \c NULL).
316
317@prenotnull{field}
318@postrefcountsame{field}
319
320@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
321 field's type.
322*/
323extern int bt_ctf_field_is_array(struct bt_ctf_field *field);
324
325/**
326@brief Returns whether or not the @field \p field is a @seqfield.
327
328@param[in] field Field to check (can be \c NULL).
329@returns 1 if \p field is a sequence field, or 0
330 otherwise (including if \p field is
331 \c NULL).
332
333@prenotnull{field}
334@postrefcountsame{field}
335
336@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
337 field's type.
338*/
339extern int bt_ctf_field_is_sequence(struct bt_ctf_field *field);
340
341/**
342@brief Returns whether or not the @field \p field is a @varfield.
343
344@param[in] field Field to check (can be \c NULL).
345@returns 1 if \p field is a variant field, or 0
346 otherwise (including if \p field is
347 \c NULL).
348
349@prenotnull{field}
350@postrefcountsame{field}
351
352@sa bt_ctf_field_get_type_id(): Returns the type ID of a given
353 field's type.
354*/
355extern int bt_ctf_field_is_variant(struct bt_ctf_field *field);
356
357/** @} */
358
359/**
360@name Misc. functions
361@{
362*/
363
364/**
365@brief Creates a \em deep copy of the @field \p field.
366
367You can copy a frozen field: the resulting copy is <em>not frozen</em>.
368
369@param[in] field Field to copy.
370@returns Deep copy of \p field on success,
371 or \c NULL on error.
372
373@prenotnull{field}
374@postrefcountsame{field}
375@postsuccessrefcountret1
376@post <strong>On success</strong>, the returned field is not frozen.
377*/
378extern struct bt_ctf_field *bt_ctf_field_copy(struct bt_ctf_field *field);
379
380/** @} */
381
382/** @} */
383
384/**
385@defgroup ctfirintfield CTF IR integer field
386@ingroup ctfirfields
387@brief CTF IR integer field.
388
389@code
390#include <babeltrace/ctf-ir/fields.h>
391@endcode
392
393A CTF IR <strong><em>integer field</em></strong> is a @field which
394holds a signed or unsigned integral value, and which is described by
395a @intft.
396
397An integer field object is considered \em unsigned if
398bt_ctf_field_type_integer_get_signed() on its parent field type returns
3990. Otherwise it is considered \em signed. You \em must use
400bt_ctf_field_unsigned_integer_get_value() and
401bt_ctf_field_unsigned_integer_set_value() with an unsigned integer
402field, and bt_ctf_field_signed_integer_get_value() and
403bt_ctf_field_signed_integer_set_value() with a signed integer field.
404
405After you create an integer field with bt_ctf_field_create(), you
406\em must set an integral value with
407bt_ctf_field_unsigned_integer_set_value() or
408bt_ctf_field_signed_integer_set_value() before you can get the
409field's value with bt_ctf_field_unsigned_integer_get_value() or
410bt_ctf_field_signed_integer_get_value().
411
412@sa ctfirintfieldtype
413@sa ctfirfields
414
415@addtogroup ctfirintfield
416@{
417*/
418
419/**
420@brief Returns the signed integral value of the @intfield
421 \p integer_field.
422
423@param[in] integer_field Integer field of which to get the
424 signed integral value.
425@param[out] value Returned signed integral value of
426 \p integer_field.
427@returns 0 on success, or a negative value on
428 error, including if \p integer_field
429 has no integral value yet.
430
431@prenotnull{integer_field}
432@prenotnull{value}
433@preisintfield{integer_field}
434@pre bt_ctf_field_type_integer_get_signed() returns 1 for the parent
435 @ft of \p integer_field.
436@pre \p integer_field contains a signed integral value previously
437 set with bt_ctf_field_signed_integer_set_value().
438@postrefcountsame{integer_field}
439
440@sa bt_ctf_field_signed_integer_set_value(): Sets the signed integral
441 value of a given integer field.
442*/
443extern int bt_ctf_field_signed_integer_get_value(
444 struct bt_ctf_field *integer_field, int64_t *value);
445
446/**
447@brief Sets the signed integral value of the @intfield
448 \p integer_field to \p value.
449
450@param[in] integer_field Integer field of which to set
451 the signed integral value.
452@param[in] value New signed integral value of
453 \p integer_field.
454@returns 0 on success, or a negative value on error.
455
456@prenotnull{integer_field}
457@preisintfield{integer_field}
458@prehot{integer_field}
459@pre bt_ctf_field_type_integer_get_signed() returns 1 for the parent
460 @ft of \p integer_field.
461@postrefcountsame{integer_field}
462
463@sa bt_ctf_field_signed_integer_get_value(): Returns the signed integral
464 value of a given integer field.
465*/
466extern int bt_ctf_field_signed_integer_set_value(
467 struct bt_ctf_field *integer_field, int64_t value);
468
469/**
470@brief Returns the unsigned integral value of the @intfield
471 \p integer_field.
472
473@param[in] integer_field Integer field of which to get the
474 unsigned integral value.
475@param[out] value Returned unsigned integral value of
476 \p integer_field.
477@returns 0 on success, or a negative value on
478 error, including if \p integer_field
479 has no integral value yet.
480
481@prenotnull{integer_field}
482@prenotnull{value}
483@preisintfield{integer_field}
484@pre bt_ctf_field_type_integer_get_signed() returns 0 for the parent
485 @ft of \p integer_field.
486@pre \p integer_field contains an unsigned integral value previously
487 set with bt_ctf_field_unsigned_integer_set_value().
488@postrefcountsame{integer_field}
489
490@sa bt_ctf_field_unsigned_integer_set_value(): Sets the unsigned
491 integral value of a given integer field.
492*/
493extern int bt_ctf_field_unsigned_integer_get_value(
494 struct bt_ctf_field *integer_field, uint64_t *value);
495
496/**
497@brief Sets the unsigned integral value of the @intfield
498 \p integer_field to \p value.
499
500@param[in] integer_field Integer field of which to set
501 the unsigned integral value.
502@param[in] value New unsigned integral value of
503 \p integer_field.
504@returns 0 on success, or a negative value on error.
505
506@prenotnull{integer_field}
507@preisintfield{integer_field}
508@prehot{integer_field}
509@pre bt_ctf_field_type_integer_get_signed() returns 0 for the parent
510 @ft of \p integer_field.
511@postrefcountsame{integer_field}
512
513@sa bt_ctf_field_unsigned_integer_get_value(): Returns the unsigned
514 integral value of a given integer field.
515*/
516extern int bt_ctf_field_unsigned_integer_set_value(
517 struct bt_ctf_field *integer_field, uint64_t value);
518
519/** @} */
520
521/**
522@defgroup ctfirfloatfield CTF IR floating point number field
523@ingroup ctfirfields
524@brief CTF IR floating point number field.
525
526@code
527#include <babeltrace/ctf-ir/fields.h>
528@endcode
529
530A CTF IR <strong><em>floating point number field</em></strong> is a
531@field which holds a floating point number value, and which is
532described by a @floatft.
533
534After you create a floating point number field with bt_ctf_field_create(), you
535\em must set a floating point number value with
536bt_ctf_field_floating_point_set_value() before you can get the
537field's value with bt_ctf_field_floating_point_get_value().
538
539@sa ctfirfloatfieldtype
540@sa ctfirfields
541
542@addtogroup ctfirfloatfield
543@{
544*/
545
546/**
547@brief Returns the floating point number value of the @floatfield
548 \p float_field.
549
550@param[in] float_field Floating point number field of which to get the
551 floating point number value.
552@param[out] value Returned floating point number value of
553 \p float_field.
554@returns 0 on success, or a negative value on error,
555 including if \p float_field has no floating
556 point number value yet.
557
558@prenotnull{float_field}
559@prenotnull{value}
560@preisfloatfield{float_field}
561@pre \p float_field contains a floating point number value previously
562 set with bt_ctf_field_floating_point_set_value().
563@postrefcountsame{float_field}
564
565@sa bt_ctf_field_floating_point_set_value(): Sets the floating point
566 number value of a given floating point number field.
567*/
cd95e351 568extern int bt_ctf_field_floating_point_get_value(
91f379cb 569 struct bt_ctf_field *float_field, double *value);
cd95e351 570
91f379cb
PP
571/**
572@brief Sets the floating point number value of the @floatfield
573 \p float_field to \p value.
574
575@param[in] float_field Floating point number field of which to set
576 the floating point number value.
577@param[in] value New floating point number value of
578 \p float_field.
579@returns 0 on success, or a negative value on error.
580
581@prenotnull{float_field}
582@preisfloatfield{float_field}
583@prehot{float_field}
584@postrefcountsame{float_field}
585
586@sa bt_ctf_field_floating_point_get_value(): Returns the floating point
587 number value of a given floating point number field.
588*/
adc315b8 589extern int bt_ctf_field_floating_point_set_value(
91f379cb 590 struct bt_ctf_field *float_field,
adc315b8
JG
591 double value);
592
91f379cb
PP
593/** @} */
594
595/**
596@defgroup ctfirenumfield CTF IR enumeration field
597@ingroup ctfirfields
598@brief CTF IR enumeration field.
599
600@code
601#include <babeltrace/ctf-ir/fields.h>
602@endcode
603
604A CTF IR <strong><em>enumeration field</em></strong> is a @field which
605holds a @intfield, and which is described by a @enumft.
606
607To set the current integral value of an enumeration field, you need to
608get its wrapped @intfield with bt_ctf_field_enumeration_get_container(),
609and then set the integral value with either
610bt_ctf_field_signed_integer_set_value() or
611bt_ctf_field_unsigned_integer_set_value().
612
613Once you set the integral value of an enumeration field by following the
5c3f3b7e
PP
614previous paragraph, you can get the mappings containing this value in
615their range with bt_ctf_field_enumeration_get_mappings(). This function
616returns a @enumftiter.
91f379cb
PP
617
618@sa ctfirenumfieldtype
619@sa ctfirfields
620
621@addtogroup ctfirenumfield
622@{
623*/
624
625/**
626@brief Returns the @intfield, potentially creating it, wrapped by the
627 @enumfield \p enum_field.
628
629This function creates the @intfield to return if it does not currently
630exist.
631
632@param[in] enum_field Enumeration field of which to get the wrapped
633 integer field.
634@returns Integer field wrapped by \p enum_field, or
635 \c NULL on error.
636
637@prenotnull{enum_field}
638@preisenumfield{enum_field}
639@postrefcountsame{enum_field}
640@postsuccessrefcountretinc
641*/
642extern struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
643 struct bt_ctf_field *enum_field);
644
645/**
5c3f3b7e
PP
646@brief Returns a @enumftiter on all the mappings of the field type of
647 \p enum_field which contain the current integral value of the
648 @enumfield \p enum_field in their range.
649
650This function is the equivalent of using
651bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value() or
652bt_ctf_field_type_enumeration_find_mappings_by_signed_value() with the
653current integral value of \p enum_field.
654
655@param[in] enum_field Enumeration field of which to get the mappings
656 containing the current integral value of \p
657 enum_field in their range.
658@returns @enumftiter on the set of mappings of the field
659 type of \p enum_field which contain the current
660 integral value of \p enum_field in their range,
661 or \c NULL if no mappings were found or on
662 error.
91f379cb
PP
663
664@prenotnull{enum_field}
665@preisenumfield{enum_field}
666@pre The wrapped integer field of \p enum_field contains an integral
667 value.
668@postrefcountsame{enum_field}
8dc7eb94 669@postsuccessrefcountret1
5c3f3b7e
PP
670@post <strong>On success</strong>, the returned @enumftiter can iterate
671 on at least one mapping.
91f379cb 672*/
e0f15669
JG
673extern struct bt_ctf_field_type_enumeration_mapping_iterator *
674bt_ctf_field_enumeration_get_mappings(struct bt_ctf_field *enum_field);
91f379cb
PP
675
676/** @} */
677
678/**
679@defgroup ctfirstringfield CTF IR string field
680@ingroup ctfirfields
681@brief CTF IR string field.
682
683@code
684#include <babeltrace/ctf-ir/fields.h>
685@endcode
686
687A CTF IR <strong><em>string field</em></strong> is a @field which holds
688a string value, and which is described by a @stringft.
689
690Use bt_ctf_field_string_set_value() to set the current string value
691of a string field object. You can also use bt_ctf_field_string_append()
692and bt_ctf_field_string_append_len() to append a string to the current
693value of a string field.
694
695After you create a string field with bt_ctf_field_create(), you
696\em must set a string value with
697bt_ctf_field_string_set_value(), bt_ctf_field_string_append(), or
698bt_ctf_field_string_append_len() before you can get the
699field's value with bt_ctf_field_string_get_value().
700
701@sa ctfirstringfieldtype
702@sa ctfirfields
703
704@addtogroup ctfirstringfield
705@{
706*/
707
708/**
709@brief Returns the string value of the @stringfield \p string_field.
710
711On success, \p string_field remains the sole owner of the returned
712value.
713
714@param[in] string_field String field field of which to get the
715 string value.
716@returns String value, or \c NULL on error.
717
718@prenotnull{string_field}
719@prenotnull{value}
720@preisstringfield{string_field}
721@pre \p string_field contains a string value previously
722 set with bt_ctf_field_string_set_value(),
723 bt_ctf_field_string_append(), or
724 bt_ctf_field_string_append_len().
725@postrefcountsame{string_field}
726
727@sa bt_ctf_field_string_set_value(): Sets the string value of a given
728 string field.
729*/
cd95e351
JG
730extern const char *bt_ctf_field_string_get_value(
731 struct bt_ctf_field *string_field);
732
91f379cb
PP
733/**
734@brief Sets the string value of the @stringfield \p string_field to
735 \p value.
736
737@param[in] string_field String field of which to set
738 the string value.
739@param[in] value New string value of \p string_field (copied
740 on success).
741@returns 0 on success, or a negative value on error.
742
743@prenotnull{string_field}
744@prenotnull{value}
745@preisstringfield{string_field}
746@prehot{string_field}
747@postrefcountsame{string_field}
748
749@sa bt_ctf_field_string_get_value(): Returns the string value of a
750 given string field.
751*/
cd95e351 752extern int bt_ctf_field_string_set_value(struct bt_ctf_field *string_field,
adc315b8
JG
753 const char *value);
754
91f379cb
PP
755/**
756@brief Appends the string \p value to the current string value of
757 the @stringfield \p string_field.
758
759This function is the equivalent of:
760
761@code
762bt_ctf_field_string_append_len(string_field, value, strlen(value));
763@endcode
764
765@param[in] string_field String field of which to append \p value to
766 its current value.
767@param[in] value String to append to the current string value
768 of \p string_field (copied on success).
769@returns 0 on success, or a negative value on error.
770
771@prenotnull{string_field}
772@prenotnull{value}
773@preisstringfield{string_field}
774@prehot{string_field}
775@postrefcountsame{string_field}
776
777@sa bt_ctf_field_string_set_value(): Sets the string value of a given
778 string field.
779*/
c6f9c5a3
PP
780extern int bt_ctf_field_string_append(struct bt_ctf_field *string_field,
781 const char *value);
782
91f379cb
PP
783/**
784@brief Appends the first \p length characters of \p value to the
785 current string value of the @stringfield \p string_field.
786
787If \p string_field has no current string value, this function first
788sets an empty string as the string value of \p string_field and then
789appends the first \p length characters of \p value.
790
791@param[in] string_field String field of which to append the first
792 \p length characters of \p value to
793 its current value.
794@param[in] value String containing the characters to append to
795 the current string value of \p string_field
796 (copied on success).
797@param[in] length Number of characters of \p value to append to
798 the current string value of \p string_field.
799@returns 0 on success, or a negative value on error.
800
801@prenotnull{string_field}
802@prenotnull{value}
803@preisstringfield{string_field}
804@prehot{string_field}
805@postrefcountsame{string_field}
806
807@sa bt_ctf_field_string_set_value(): Sets the string value of a given
808 string field.
809*/
f98c6554
PP
810extern int bt_ctf_field_string_append_len(
811 struct bt_ctf_field *string_field, const char *value,
812 unsigned int length);
813
91f379cb 814/** @} */
cd95e351 815
91f379cb
PP
816/**
817@defgroup ctfirstructfield CTF IR structure field
818@ingroup ctfirfields
819@brief CTF IR structure field.
4ebcc695 820
91f379cb
PP
821@code
822#include <babeltrace/ctf-ir/fields.h>
823@endcode
8f3553be 824
91f379cb
PP
825A CTF IR <strong><em>structure field</em></strong> is a @field which
826contains an ordered list of zero or more named @fields which can be
827different @fts, and which is described by a @structft.
8f3553be 828
91f379cb
PP
829To set the value of a specific field of a structure field, you need to
830first get the field with bt_ctf_field_structure_get_field() or
7fcd5734
JD
831bt_ctf_field_structure_get_field_by_index(). If you already have a
832field object, you can assign it to a specific name within a structure
833field with bt_ctf_field_structure_set_field().
8f3553be 834
91f379cb
PP
835@sa ctfirstructfieldtype
836@sa ctfirfields
8f3553be 837
91f379cb
PP
838@addtogroup ctfirstructfield
839@{
840*/
8f3553be 841
91f379cb
PP
842/**
843@brief Returns the @field named \p name, potentially creating it,
844 in the @structfield \p struct_field.
8f3553be 845
91f379cb
PP
846This function creates the @field to return if it does not currently
847exist.
8f3553be 848
91f379cb
PP
849@param[in] struct_field Structure field of which to get the field
850 named \p name.
851@param[in] name Name of the field to get from \p struct_field.
852@returns Field named \p name in \p struct_field, or
853 \c NULL on error.
8f3553be 854
91f379cb
PP
855@prenotnull{struct_field}
856@prenotnull{name}
857@preisstructfield{struct_field}
858@postrefcountsame{struct_field}
859@postsuccessrefcountretinc
860
861@sa bt_ctf_field_structure_get_field_by_index(): Returns the field of a
862 given structure field by index.
7fcd5734
JD
863@sa bt_ctf_field_structure_set_field(): Sets the field of a given
864 structure field.
91f379cb 865*/
9ac68eb1 866extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_name(
91f379cb
PP
867 struct bt_ctf_field *struct_field, const char *name);
868
9ac68eb1
PP
869/* Pre-2.0 CTF writer compatibility */
870#define bt_ctf_field_structure_get_field bt_ctf_field_structure_get_field_by_name
871
91f379cb
PP
872/**
873@brief Returns the @field at index \p index in the @structfield
874 \p struct_field.
875
876@param[in] struct_field Structure field of which to get the field
877 at index \p index.
878@param[in] index Index of the field to get in \p struct_field.
879@returns Field at index \p index in \p struct_field, or
880 \c NULL on error.
881
882@prenotnull{struct_field}
883@preisstructfield{struct_field}
884@pre \p index is lesser than the number of fields contained in the
885 parent field type of \p struct_field (see
886 bt_ctf_field_type_structure_get_field_count()).
887@postrefcountsame{struct_field}
888@postsuccessrefcountretinc
889
890@sa bt_ctf_field_structure_get_field(): Returns the field of a
891 given structure field by name.
7fcd5734
JD
892@sa bt_ctf_field_structure_set_field(): Sets the field of a given
893 structure field.
91f379cb
PP
894*/
895extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
9ac68eb1 896 struct bt_ctf_field *struct_field, uint64_t index);
91f379cb 897
7fcd5734
JD
898/**
899@brief Sets the field of the @structfield \p struct_field named \p name
900 to the @field \p field.
901
902If \p struct_field already contains a field named \p name, then its
903reference count is decremented, and \p field replaces it.
904
905The field type of \p field, as returned by bt_ctf_field_get_type(),
906\em must be equivalent to the field type returned by
907bt_ctf_field_type_structure_get_field_type_by_name() with the field
908type of \p struct_field and the same name, \p name.
909
910bt_ctf_trace_get_packet_header_type() for the parent trace class of
911\p packet.
912
913@param[in] struct_field Structure field of which to set the field
914 named \p name.
915@param[in] name Name of the field to set in \p struct_field.
916@param[in] field Field named \p name to set in \p struct_field.
917@returns 0 on success, or -1 on error.
918
919@prenotnull{struct_field}
920@prenotnull{name}
921@prenotnull{field}
922@prehot{struct_field}
923@preisstructfield{struct_field}
924@pre \p field has a field type equivalent to the field type returned by
925 bt_ctf_field_type_structure_get_field_type_by_name() for the
926 field type of \p struct_field with the name \p name.
927@postrefcountsame{struct_field}
928@post <strong>On success, if there's an existing field in
929 \p struct_field named \p name</strong>, its reference count is
930 decremented.
931@postsuccessrefcountinc{field}
932
933@sa bt_ctf_field_structure_get_field_by_index(): Returns the field of a
934 given structure field by index.
935@sa bt_ctf_field_structure_get_field(): Returns the field of a
936 given structure field by name.
937*/
938extern int bt_ctf_field_structure_set_field(struct bt_ctf_field *struct_field,
939 const char *name, struct bt_ctf_field *field);
940
91f379cb
PP
941/** @} */
942
943/**
944@defgroup ctfirarrayfield CTF IR array field
945@ingroup ctfirfields
946@brief CTF IR array field.
947
948@code
949#include <babeltrace/ctf-ir/fields.h>
950@endcode
951
952A CTF IR <strong><em>array field</em></strong> is a @field which
953contains an ordered list of zero or more @fields sharing the same @ft,
954and which is described by a @arrayft.
955
956To set the value of a specific field of an array field, you need to
957first get the field with bt_ctf_field_array_get_field().
958
959@sa ctfirarrayfieldtype
960@sa ctfirfields
961
962@addtogroup ctfirarrayfield
963@{
964*/
965
966/**
967@brief Returns the @field at index \p index, potentially creating it,
968 in the @arrayfield \p array_field.
969
970This function creates the @field to return if it does not currently
971exist.
972
973@param[in] array_field Array field of which to get the field
974 at index \p index.
975@param[in] index Index of the field to get in \p array_field.
976@returns Field at index \p index in \p array_field, or
977 \c NULL on error.
978
979@prenotnull{array_field}
980@preisarrayfield{array_field}
981@pre \p index is lesser than bt_ctf_field_type_array_get_length() called
982 on the field type of \p array_field.
983@postrefcountsame{array_field}
984@postsuccessrefcountretinc
985*/
986extern struct bt_ctf_field *bt_ctf_field_array_get_field(
987 struct bt_ctf_field *array_field, uint64_t index);
988
989/** @} */
990
991/**
992@defgroup ctfirseqfield CTF IR sequence field
993@ingroup ctfirfields
994@brief CTF IR sequence field.
995
996@code
997#include <babeltrace/ctf-ir/fields.h>
998@endcode
999
1000A CTF IR <strong><em>sequence field</em></strong> is a @field which
1001contains an ordered list of zero or more @fields sharing the same @ft,
1002and which is described by a @seqft.
1003
1004Before you can get a specific field of a sequence field with
1005bt_ctf_field_sequence_get_field(), you need to set its current length
1006@intfield with bt_ctf_field_sequence_set_length(). The integral value of
1007the length field of a sequence field indicates the number of fields
1008it contains.
1009
1010@sa ctfirseqfieldtype
1011@sa ctfirfields
1012
1013@addtogroup ctfirseqfield
1014@{
1015*/
1016
1017/**
1018@brief Returns the @field at index \p index, potentially creating it,
1019 in the @seqfield \p sequence_field.
1020
1021This function creates the @field to return if it does not currently
1022exist.
1023
1024@param[in] sequence_field Sequence field of which to get the field
1025 at index \p index.
1026@param[in] index Index of the field to get in
1027 \p sequence_field.
1028@returns Field at index \p index in
1029 \p sequence_field, or \c NULL on error.
1030
1031@prenotnull{sequence_field}
1032@preisseqfield{sequence_field}
1033@pre \p sequence_field has a length field previously set with
1034 bt_ctf_field_sequence_set_length().
1035@pre \p index is lesser than the current integral value of the current
1036 length field of \p sequence_field (see
1037 bt_ctf_field_sequence_get_length()).
1038@postrefcountsame{sequence_field}
1039@postsuccessrefcountretinc
1040*/
1041extern struct bt_ctf_field *bt_ctf_field_sequence_get_field(
1042 struct bt_ctf_field *sequence_field, uint64_t index);
1043
1044/**
1045@brief Returns the length @intfield of the @seqfield \p sequence_field.
1046
1047The current integral value of the returned length field indicates the
1048number of fields contained in \p sequence_field.
1049
1050@param[in] sequence_field Sequence field of which to get the
1051 length field.
1052@returns Length field of \p sequence_field, or
1053 \c NULL on error.
1054
1055@prenotnull{sequence_field}
1056@preisseqfield{sequence_field}
1057@pre \p sequence_field has a length field previously set with
1058 bt_ctf_field_sequence_set_length().
1059@postrefcountsame{sequence_field}
1060@postsuccessrefcountretinc
1061@post <strong>On success</strong>, the returned field is a @intfield.
1062
1063@sa bt_ctf_field_sequence_set_length(): Sets the length field of a given
1064 sequence field.
1065*/
1066extern struct bt_ctf_field *bt_ctf_field_sequence_get_length(
1067 struct bt_ctf_field *sequence_field);
1068
1069/**
1070@brief Sets the length @intfield of the @seqfield \p sequence_field
1071 to \p length_field.
1072
1073The current integral value of \p length_field indicates the number of
1074fields contained in \p sequence_field.
1075
1076@param[in] sequence_field Sequence field of which to set the
1077 length field.
1078@param[in] length_field Length field of \p sequence_field.
1079@returns 0 on success, or a negative value on error.
1080
1081@prenotnull{sequence_field}
1082@prenotnull{length_field}
1083@preisseqfield{sequence_field}
1084@preisintfield{length_field}
1085@prehot{sequence_field}
1086@postrefcountsame{sequence_field}
1087@postsuccessrefcountinc{length_field}
1088
1089@sa bt_ctf_field_sequence_get_length(): Returns the length field of a
1090 given sequence field.
1091*/
1092extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field *sequence_field,
1093 struct bt_ctf_field *length_field);
1094
1095/** @} */
1096
1097/**
1098@defgroup ctfirvarfield CTF IR variant field
1099@ingroup ctfirfields
1100@brief CTF IR variant field.
1101
1102@code
1103#include <babeltrace/ctf-ir/fields.h>
1104@endcode
1105
1106A CTF IR <strong><em>variant field</em></strong> is a @field which
1107contains a current @field amongst one or more choices, and which is
1108described by a @varft.
1109
1110Use bt_ctf_field_variant_get_field() to get the @field selected by
1111a specific tag @enumfield. Once you call this function, you can call
1112bt_ctf_field_variant_get_current_field() afterwards to get this last
1113field again.
1114
1115@sa ctfirvarfieldtype
1116@sa ctfirfields
1117
1118@addtogroup ctfirvarfield
1119@{
1120*/
1121
1122/**
1123@brief Returns the @field, potentially creating it, selected by the
1124 tag @intfield \p tag_field in the @varfield \p variant_field.
1125
1126This function creates the @field to return if it does not currently
1127exist.
1128
1129Once you call this function, you can call
1130bt_ctf_field_variant_get_current_field() to get the same field again,
1131and you can call bt_ctf_field_variant_get_tag() to get \p tag_field.
1132
1133@param[in] variant_field Variant field of which to get the field
1134 selected by \p tag_field.
1135@param[in] tag_field Tag field.
1136@returns Field selected by \p tag_field in
1137 \p variant_field, or \c NULL on error.
1138
1139@prenotnull{variant_field}
1140@prenotnull{tag_field}
1141@preisvarfield{variant_field}
1142@preisenumfield{tag_field}
1143@postrefcountsame{variant_field}
1144@postsuccessrefcountinc{tag_field}
1145@postsuccessrefcountretinc
1146*/
1147extern struct bt_ctf_field *bt_ctf_field_variant_get_field(
1148 struct bt_ctf_field *variant_field,
1149 struct bt_ctf_field *tag_field);
1150
1151/**
1152@brief Returns the currently selected @field of the @varfield
1153 \p variant_field.
1154
1155@param[in] variant_field Variant field of which to get the
1156 currently selected field.
1157@returns Currently selected field of
1158 \p variant_field, or \c NULL if there's
1159 no selected field or on error.
1160
1161@prenotnull{variant_field}
1162@preisvarfield{variant_field}
1163@pre \p variant_field contains has a current selected field previously
1164 set with bt_ctf_field_variant_get_field().
1165@postrefcountsame{variant_field}
1166@postsuccessrefcountretinc
1167*/
1168extern struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
1169 struct bt_ctf_field *variant_field);
1170
1171/**
1172@brief Returns the tag @enumfield of the @varfield \p variant_field.
1173
1174@param[in] variant_field Variant field of which to get the
1175 tag field.
1176@returns Tag field of \p variant_field, or
1177 \c NULL on error.
1178
1179@prenotnull{variant_field}
1180@preisvarfield{variant_field}
1181@pre \p variant_field contains has a current selected field previously
1182 set with bt_ctf_field_variant_get_field().
1183@postrefcountsame{variant_field}
1184@postsuccessrefcountretinc
1185@post <strong>On success</strong>, the returned field is a @enumfield.
1186*/
1187extern struct bt_ctf_field *bt_ctf_field_variant_get_tag(
1188 struct bt_ctf_field *variant_field);
1189
1190/** @} */
a39fe52e 1191
adc315b8
JG
1192#ifdef __cplusplus
1193}
1194#endif
1195
2e33ac5a 1196#endif /* BABELTRACE_CTF_IR_FIELDS_H */
This page took 0.083968 seconds and 4 git commands to generate.