Commit | Line | Data |
---|---|---|
81447b5b PP |
1 | /* |
2 | * The MIT License (MIT) | |
3 | * | |
4 | * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com> | |
5 | * | |
6 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
7 | * of this software and associated documentation files (the "Software"), to deal | |
8 | * in the Software without restriction, including without limitation the rights | |
9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
10 | * copies of the Software, and to permit persons to whom the Software is | |
11 | * furnished to do so, subject to the following conditions: | |
12 | * | |
13 | * The above copyright notice and this permission notice shall be included in | |
14 | * all copies or substantial portions of the Software. | |
15 | * | |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
22 | * THE SOFTWARE. | |
23 | */ | |
24 | ||
81447b5b | 25 | /* Type */ |
839d52a5 | 26 | struct bt_field_type; |
81447b5b PP |
27 | |
28 | /* Common enumerations */ | |
839d52a5 PP |
29 | enum bt_scope { |
30 | BT_SCOPE_UNKNOWN = -1, | |
31 | BT_SCOPE_TRACE_PACKET_HEADER = 1, | |
32 | BT_SCOPE_STREAM_PACKET_CONTEXT = 2, | |
33 | BT_SCOPE_STREAM_EVENT_HEADER = 3, | |
34 | BT_SCOPE_STREAM_EVENT_CONTEXT = 4, | |
35 | BT_SCOPE_EVENT_CONTEXT = 5, | |
36 | BT_SCOPE_EVENT_PAYLOAD = 6, | |
37 | BT_SCOPE_ENV = 0, | |
38 | BT_SCOPE_EVENT_FIELDS = 6, | |
81447b5b PP |
39 | }; |
40 | ||
839d52a5 PP |
41 | enum bt_field_type_id { |
42 | BT_FIELD_TYPE_ID_UNKNOWN = -1, | |
43 | BT_FIELD_TYPE_ID_INTEGER = 0, | |
44 | BT_FIELD_TYPE_ID_FLOAT = 1, | |
45 | BT_FIELD_TYPE_ID_ENUM = 2, | |
46 | BT_FIELD_TYPE_ID_STRING = 3, | |
47 | BT_FIELD_TYPE_ID_STRUCT = 4, | |
48 | BT_FIELD_TYPE_ID_ARRAY = 6, | |
49 | BT_FIELD_TYPE_ID_SEQUENCE = 7, | |
50 | BT_FIELD_TYPE_ID_VARIANT = 5, | |
51 | BT_FIELD_TYPE_ID_NR = 8, | |
81447b5b PP |
52 | }; |
53 | ||
839d52a5 PP |
54 | enum bt_byte_order { |
55 | BT_BYTE_ORDER_UNKNOWN = -1, | |
56 | BT_BYTE_ORDER_NATIVE = 0, | |
57 | BT_BYTE_ORDER_UNSPECIFIED, | |
58 | BT_BYTE_ORDER_LITTLE_ENDIAN, | |
59 | BT_BYTE_ORDER_BIG_ENDIAN, | |
60 | BT_BYTE_ORDER_NETWORK, | |
81447b5b PP |
61 | }; |
62 | ||
839d52a5 PP |
63 | /** |
64 | @brief String encoding of a @ft. | |
65 | */ | |
66 | enum bt_string_encoding { | |
67 | BT_STRING_ENCODING_UNKNOWN = -1, | |
68 | BT_STRING_ENCODING_NONE, | |
69 | BT_STRING_ENCODING_UTF8, | |
70 | BT_STRING_ENCODING_ASCII, | |
81447b5b PP |
71 | }; |
72 | ||
73 | /* Common functions */ | |
839d52a5 PP |
74 | enum bt_field_type_id bt_field_type_get_type_id( |
75 | struct bt_field_type *field_type); | |
76 | int bt_field_type_get_alignment( | |
77 | struct bt_field_type *field_type); | |
78 | int bt_field_type_set_alignment(struct bt_field_type *field_type, | |
81447b5b | 79 | unsigned int alignment); |
839d52a5 PP |
80 | enum bt_byte_order bt_field_type_get_byte_order( |
81 | struct bt_field_type *field_type); | |
82 | int bt_field_type_set_byte_order( | |
83 | struct bt_field_type *field_type, | |
84 | enum bt_byte_order byte_order); | |
85 | int bt_field_type_compare(struct bt_field_type *field_type_a, | |
86 | struct bt_field_type *field_type_b); | |
87 | struct bt_field_type *bt_field_type_copy( | |
88 | struct bt_field_type *field_type); | |
81447b5b PP |
89 | |
90 | /* Integer field type base enumeration */ | |
839d52a5 PP |
91 | enum bt_integer_base { |
92 | BT_INTEGER_BASE_UNKNOWN = -1, | |
93 | BT_INTEGER_BASE_UNSPECIFIED = 0, | |
94 | BT_INTEGER_BASE_BINARY = 2, | |
95 | BT_INTEGER_BASE_OCTAL = 8, | |
96 | BT_INTEGER_BASE_DECIMAL = 10, | |
97 | BT_INTEGER_BASE_HEXADECIMAL = 16, | |
81447b5b PP |
98 | }; |
99 | ||
100 | /* Integer field type functions */ | |
839d52a5 | 101 | struct bt_field_type *bt_field_type_integer_create( |
81447b5b | 102 | unsigned int size); |
839d52a5 PP |
103 | int bt_field_type_integer_get_size( |
104 | struct bt_field_type *int_field_type); | |
105 | int bt_field_type_integer_set_size( | |
106 | struct bt_field_type *int_field_type, unsigned int size); | |
107 | int bt_field_type_integer_is_signed( | |
108 | struct bt_field_type *int_field_type); | |
109 | int bt_field_type_integer_set_is_signed( | |
110 | struct bt_field_type *int_field_type, int is_signed); | |
111 | enum bt_integer_base bt_field_type_integer_get_base( | |
112 | struct bt_field_type *int_field_type); | |
113 | int bt_field_type_integer_set_base( | |
114 | struct bt_field_type *int_field_type, | |
115 | enum bt_integer_base base); | |
116 | enum bt_string_encoding bt_field_type_integer_get_encoding( | |
117 | struct bt_field_type *int_field_type); | |
118 | int bt_field_type_integer_set_encoding( | |
119 | struct bt_field_type *int_field_type, | |
120 | enum bt_string_encoding encoding); | |
121 | struct bt_clock_class *bt_field_type_integer_get_mapped_clock_class( | |
122 | struct bt_field_type *int_field_type); | |
123 | int bt_field_type_integer_set_mapped_clock_class( | |
124 | struct bt_field_type *int_field_type, | |
125 | struct bt_clock_class *clock_class); | |
81447b5b PP |
126 | |
127 | /* Floating point number field type functions */ | |
839d52a5 PP |
128 | struct bt_field_type *bt_field_type_floating_point_create(void); |
129 | int bt_field_type_floating_point_get_exponent_digits( | |
130 | struct bt_field_type *float_field_type); | |
131 | int bt_field_type_floating_point_set_exponent_digits( | |
132 | struct bt_field_type *float_field_type, | |
81447b5b | 133 | unsigned int exponent_size); |
839d52a5 PP |
134 | int bt_field_type_floating_point_get_mantissa_digits( |
135 | struct bt_field_type *float_field_type); | |
136 | int bt_field_type_floating_point_set_mantissa_digits( | |
137 | struct bt_field_type *float_field_type, | |
81447b5b PP |
138 | unsigned int mantissa_sign_size); |
139 | ||
140 | /* Enumeration field type functions */ | |
839d52a5 PP |
141 | struct bt_field_type *bt_field_type_enumeration_create( |
142 | struct bt_field_type *int_field_type); | |
143 | struct bt_field_type *bt_field_type_enumeration_get_container_type( | |
144 | struct bt_field_type *enum_field_type); | |
145 | int64_t bt_field_type_enumeration_get_mapping_count( | |
146 | struct bt_field_type *enum_field_type); | |
147 | int bt_field_type_enumeration_get_mapping_signed( | |
148 | struct bt_field_type *enum_field_type, int index, | |
81447b5b | 149 | const char **BTOUTSTR, int64_t *OUTPUT, int64_t *OUTPUT); |
839d52a5 PP |
150 | int bt_field_type_enumeration_get_mapping_unsigned( |
151 | struct bt_field_type *enum_field_type, int index, | |
81447b5b PP |
152 | const char **BTOUTSTR, uint64_t *OUTPUT, |
153 | uint64_t *OUTPUT); | |
839d52a5 PP |
154 | int bt_field_type_enumeration_add_mapping_signed( |
155 | struct bt_field_type *enum_field_type, const char *name, | |
81447b5b | 156 | int64_t range_begin, int64_t range_end); |
839d52a5 PP |
157 | int bt_field_type_enumeration_add_mapping_unsigned( |
158 | struct bt_field_type *enum_field_type, const char *name, | |
81447b5b | 159 | uint64_t range_begin, uint64_t range_end); |
839d52a5 PP |
160 | struct bt_field_type_enumeration_mapping_iterator * |
161 | bt_field_type_enumeration_find_mappings_by_name( | |
162 | struct bt_field_type *enum_field_type, | |
81447b5b | 163 | const char *name); |
839d52a5 PP |
164 | struct bt_field_type_enumeration_mapping_iterator * |
165 | bt_field_type_enumeration_find_mappings_by_signed_value( | |
166 | struct bt_field_type *enum_field_type, | |
81447b5b | 167 | int64_t value); |
839d52a5 PP |
168 | struct bt_field_type_enumeration_mapping_iterator * |
169 | bt_field_type_enumeration_find_mappings_by_unsigned_value( | |
170 | struct bt_field_type *enum_field_type, | |
81447b5b PP |
171 | uint64_t value); |
172 | ||
173 | /* Enumeration field type mapping iterator functions */ | |
839d52a5 PP |
174 | int bt_field_type_enumeration_mapping_iterator_get_signed( |
175 | struct bt_field_type_enumeration_mapping_iterator *iter, | |
81447b5b | 176 | const char **BTOUTSTR, int64_t *OUTPUT, int64_t *OUTPUT); |
839d52a5 PP |
177 | int bt_field_type_enumeration_mapping_iterator_get_unsigned( |
178 | struct bt_field_type_enumeration_mapping_iterator *iter, | |
f6a5e476 | 179 | const char **BTOUTSTR, uint64_t *OUTPUT, uint64_t *OUTPUT); |
839d52a5 PP |
180 | int bt_field_type_enumeration_mapping_iterator_next( |
181 | struct bt_field_type_enumeration_mapping_iterator *iter); | |
81447b5b PP |
182 | |
183 | /* String field type functions */ | |
839d52a5 PP |
184 | struct bt_field_type *bt_field_type_string_create(void); |
185 | enum bt_string_encoding bt_field_type_string_get_encoding( | |
186 | struct bt_field_type *string_field_type); | |
187 | int bt_field_type_string_set_encoding( | |
188 | struct bt_field_type *string_field_type, | |
189 | enum bt_string_encoding encoding); | |
81447b5b PP |
190 | |
191 | /* Structure field type functions */ | |
839d52a5 PP |
192 | struct bt_field_type *bt_field_type_structure_create(void); |
193 | int64_t bt_field_type_structure_get_field_count( | |
194 | struct bt_field_type *struct_field_type); | |
195 | int bt_field_type_structure_get_field_by_index( | |
196 | struct bt_field_type *struct_field_type, | |
197 | const char **BTOUTSTR, struct bt_field_type **BTOUTFT, | |
f6a5e476 | 198 | uint64_t index); |
839d52a5 PP |
199 | struct bt_field_type *bt_field_type_structure_get_field_type_by_name( |
200 | struct bt_field_type *struct_field_type, | |
81447b5b | 201 | const char *field_name); |
839d52a5 PP |
202 | int bt_field_type_structure_add_field( |
203 | struct bt_field_type *struct_field_type, | |
204 | struct bt_field_type *field_type, | |
81447b5b PP |
205 | const char *field_name); |
206 | ||
207 | /* Array field type functions */ | |
839d52a5 PP |
208 | struct bt_field_type *bt_field_type_array_create( |
209 | struct bt_field_type *element_field_type, | |
81447b5b | 210 | unsigned int length); |
839d52a5 PP |
211 | struct bt_field_type *bt_field_type_array_get_element_type( |
212 | struct bt_field_type *array_field_type); | |
213 | int64_t bt_field_type_array_get_length( | |
214 | struct bt_field_type *array_field_type); | |
81447b5b PP |
215 | |
216 | /* Sequence field type functions */ | |
839d52a5 PP |
217 | struct bt_field_type *bt_field_type_sequence_create( |
218 | struct bt_field_type *element_field_type, | |
81447b5b | 219 | const char *length_name); |
839d52a5 PP |
220 | struct bt_field_type *bt_field_type_sequence_get_element_type( |
221 | struct bt_field_type *sequence_field_type); | |
222 | const char *bt_field_type_sequence_get_length_field_name( | |
223 | struct bt_field_type *sequence_field_type); | |
224 | struct bt_field_path *bt_field_type_sequence_get_length_field_path( | |
225 | struct bt_field_type *sequence_field_type); | |
81447b5b PP |
226 | |
227 | /* Variant field type functions */ | |
839d52a5 PP |
228 | struct bt_field_type *bt_field_type_variant_create( |
229 | struct bt_field_type *tag_field_type, | |
81447b5b | 230 | const char *tag_name); |
839d52a5 PP |
231 | struct bt_field_type *bt_field_type_variant_get_tag_type( |
232 | struct bt_field_type *variant_field_type); | |
233 | const char *bt_field_type_variant_get_tag_name( | |
234 | struct bt_field_type *variant_field_type); | |
235 | int bt_field_type_variant_set_tag_name( | |
236 | struct bt_field_type *variant_field_type, | |
81447b5b | 237 | const char *tag_name); |
839d52a5 PP |
238 | struct bt_field_path *bt_field_type_variant_get_tag_field_path( |
239 | struct bt_field_type *variant_field_type); | |
240 | int64_t bt_field_type_variant_get_field_count( | |
241 | struct bt_field_type *variant_field_type); | |
242 | int bt_field_type_variant_get_field_by_index( | |
243 | struct bt_field_type *variant_field_type, | |
81447b5b | 244 | const char **BTOUTSTR, |
839d52a5 PP |
245 | struct bt_field_type **BTOUTFT, uint64_t index); |
246 | struct bt_field_type *bt_field_type_variant_get_field_type_by_name( | |
247 | struct bt_field_type *variant_field_type, | |
81447b5b | 248 | const char *field_name); |
839d52a5 PP |
249 | int bt_field_type_variant_add_field( |
250 | struct bt_field_type *variant_field_type, | |
251 | struct bt_field_type *field_type, | |
81447b5b | 252 | const char *field_name); |