+static inline
+struct ctf_field_class_enum_mapping *ctf_field_class_enum_borrow_mapping_by_label(
+ struct ctf_field_class_enum *fc, const char *label)
+{
+ struct ctf_field_class_enum_mapping *ret_mapping = NULL;
+ uint64_t i;
+
+ BT_ASSERT_DBG(fc);
+ BT_ASSERT_DBG(label);
+
+ for (i = 0; i < fc->mappings->len; i++) {
+ struct ctf_field_class_enum_mapping *mapping =
+ ctf_field_class_enum_borrow_mapping_by_index(fc, i);
+
+ if (strcmp(mapping->label->str, label) == 0) {
+ ret_mapping = mapping;
+ goto end;
+ }
+ }
+
+end:
+ return ret_mapping;
+}
+
+static inline
+void ctf_field_class_enum_map_range(struct ctf_field_class_enum *fc,
+ const char *label, uint64_t u_lower, uint64_t u_upper)
+{
+ struct ctf_field_class_enum_mapping *mapping = NULL;
+ struct ctf_range range = {
+ .lower.u = u_lower,
+ .upper.u = u_upper,
+ };
+ uint64_t i;
+
+ BT_ASSERT(fc);
+ BT_ASSERT(label);
+
+ for (i = 0; i < fc->mappings->len; i++) {
+ mapping = ctf_field_class_enum_borrow_mapping_by_index(
+ fc, i);
+
+ if (strcmp(mapping->label->str, label) == 0) {
+ break;
+ }
+ }
+
+ if (i == fc->mappings->len) {
+ mapping = NULL;
+ }
+
+ if (!mapping) {
+ g_array_set_size(fc->mappings, fc->mappings->len + 1);
+ mapping = ctf_field_class_enum_borrow_mapping_by_index(
+ fc, fc->mappings->len - 1);
+ _ctf_field_class_enum_mapping_init(mapping);
+ g_string_assign(mapping->label, label);
+ }
+
+ g_array_append_val(mapping->ranges, range);
+}
+