*/
/*
- * For bt_bool, bt_field_class bt_field_path
- * bt_field_class_signed_enumeration_mapping_ranges
- * bt_field_class_unsigned_enumeration_mapping_ranges,
+ * For bt_bool, bt_field_class, bt_field_path,
+ * bt_field_class_enumeration_mapping,
+ * bt_field_class_unsigned_enumeration_mapping,
+ * bt_field_class_signed_enumeration_mapping,
* bt_field_class_enumeration_mapping_label_array
*/
#include <babeltrace/types.h>
extern uint64_t bt_field_class_enumeration_get_mapping_count(
const bt_field_class *field_class);
-extern void bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
- const bt_field_class *field_class, uint64_t index,
- const char **label,
- const bt_field_class_unsigned_enumeration_mapping_ranges **ranges);
+extern const bt_field_class_unsigned_enumeration_mapping *
+bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+ const bt_field_class *field_class, uint64_t index);
+
+extern const bt_field_class_signed_enumeration_mapping *
+bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
+ const bt_field_class *field_class, uint64_t index);
-extern void bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
- const bt_field_class *field_class, uint64_t index,
- const char **label,
- const bt_field_class_signed_enumeration_mapping_ranges **ranges);
+static inline
+const bt_field_class_enumeration_mapping *
+bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
+ const bt_field_class_unsigned_enumeration_mapping *mapping)
+{
+ return (const void *) mapping;
+}
+
+static inline
+const bt_field_class_enumeration_mapping *
+bt_field_class_signed_enumeration_mapping_as_mapping_const(
+ const bt_field_class_signed_enumeration_mapping *mapping)
+{
+ return (const void *) mapping;
+}
-extern uint64_t
-bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
- const bt_field_class_unsigned_enumeration_mapping_ranges *ranges);
+extern const char *bt_field_class_enumeration_mapping_get_label(
+ const bt_field_class_enumeration_mapping *mapping);
-extern uint64_t
-bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
- const bt_field_class_signed_enumeration_mapping_ranges *ranges);
+extern uint64_t bt_field_class_enumeration_mapping_get_range_count(
+ const bt_field_class_enumeration_mapping *mapping);
extern void
-bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
- const bt_field_class_unsigned_enumeration_mapping_ranges *ranges,
+bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
+ const bt_field_class_unsigned_enumeration_mapping *mapping,
uint64_t index, uint64_t *lower, uint64_t *upper);
extern void
-bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
- const bt_field_class_signed_enumeration_mapping_ranges *ranges,
+bt_field_class_signed_enumeration_mapping_get_range_by_index(
+ const bt_field_class_signed_enumeration_mapping *mapping,
uint64_t index, int64_t *lower, int64_t *upper);
extern bt_field_class_status
GArray *ranges;
};
+struct bt_field_class_unsigned_enumeration_mapping;
+struct bt_field_class_signed_enumeration_mapping;
+
struct bt_field_class_enumeration {
struct bt_field_class_integer common;
typedef struct bt_event_header_field bt_event_header_field;
typedef struct bt_field bt_field;
typedef struct bt_field_class bt_field_class;
-typedef struct bt_field_class_signed_enumeration_mapping_ranges bt_field_class_signed_enumeration_mapping_ranges;
-typedef struct bt_field_class_unsigned_enumeration_mapping_ranges bt_field_class_unsigned_enumeration_mapping_ranges;
+typedef struct bt_field_class_enumeration_mapping bt_field_class_enumeration_mapping;
+typedef struct bt_field_class_signed_enumeration_mapping bt_field_class_signed_enumeration_mapping;
+typedef struct bt_field_class_unsigned_enumeration_mapping bt_field_class_unsigned_enumeration_mapping;
typedef struct bt_field_class_structure_member bt_field_class_structure_member;
typedef struct bt_field_class_variant_option bt_field_class_variant_option;
typedef struct bt_field_path bt_field_path;
return (uint64_t) enum_fc->mappings->len;
}
-void bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
- const struct bt_field_class *fc, uint64_t index,
- const char **name,
- const struct bt_field_class_unsigned_enumeration_mapping_ranges **ranges)
+const struct bt_field_class_unsigned_enumeration_mapping *
+bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+ const struct bt_field_class *fc, uint64_t index)
{
const struct bt_field_class_enumeration *enum_fc = (const void *) fc;
- const struct bt_field_class_enumeration_mapping *mapping;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
- BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
BT_ASSERT_PRE_VALID_INDEX(index, enum_fc->mappings->len);
BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
"Field class");
- mapping = BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
- *name = mapping->label->str;
- *ranges = (void *) mapping;
+ return (const void *) BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
}
-void bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
- const struct bt_field_class *fc, uint64_t index,
- const char **name,
- const struct bt_field_class_signed_enumeration_mapping_ranges **ranges)
+const struct bt_field_class_signed_enumeration_mapping *
+bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
+ const struct bt_field_class *fc, uint64_t index)
{
const struct bt_field_class_enumeration *enum_fc = (const void *) fc;
- const struct bt_field_class_enumeration_mapping *mapping;
BT_ASSERT_PRE_NON_NULL(fc, "Field class");
- BT_ASSERT_PRE_NON_NULL(name, "Name (output)");
- BT_ASSERT_PRE_NON_NULL(ranges, "Ranges (output)");
BT_ASSERT_PRE_VALID_INDEX(index, enum_fc->mappings->len);
BT_ASSERT_PRE_FC_HAS_ID(fc, BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
"Field class");
- mapping = BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
- *name = mapping->label->str;
- *ranges = (void *) mapping;
+ return (const void *) BT_FIELD_CLASS_ENUM_MAPPING_AT_INDEX(fc, index);
}
-static inline
-uint64_t get_enumeration_field_class_mapping_range_count(
+const char *bt_field_class_enumeration_mapping_get_label(
const struct bt_field_class_enumeration_mapping *mapping)
{
- BT_ASSERT_PRE_NON_NULL(mapping, "Ranges");
- return (uint64_t) mapping->ranges->len;
-}
-
-uint64_t bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
- const struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges)
-{
- return get_enumeration_field_class_mapping_range_count(
- (const void *) ranges);
+ BT_ASSERT_PRE_NON_NULL(mapping, "Enumeration field class mapping");
+ return mapping->label->str;
}
-uint64_t bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
- const struct bt_field_class_signed_enumeration_mapping_ranges *ranges)
+uint64_t bt_field_class_enumeration_mapping_get_range_count(
+ const struct bt_field_class_enumeration_mapping *mapping)
{
- return get_enumeration_field_class_mapping_range_count(
- (const void *) ranges);
+ BT_ASSERT_PRE_NON_NULL(mapping, "Enumeration field class mapping");
+ return (uint64_t) mapping->ranges->len;
}
static inline
*upper = range->upper.u;
}
-void bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
- const struct bt_field_class_unsigned_enumeration_mapping_ranges *ranges,
+void bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
+ const struct bt_field_class_unsigned_enumeration_mapping *ranges,
uint64_t index, uint64_t *lower, uint64_t *upper)
{
get_enumeration_field_class_mapping_range_at_index(
(const void *) ranges, index, lower, upper);
}
-void bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
- const struct bt_field_class_signed_enumeration_mapping_ranges *ranges,
+void bt_field_class_signed_enumeration_mapping_get_range_by_index(
+ const struct bt_field_class_signed_enumeration_mapping *ranges,
uint64_t index, int64_t *lower, int64_t *upper)
{
get_enumeration_field_class_mapping_range_at_index(
(uint64_t *) lower, (uint64_t *) upper);
}
-
-
enum bt_field_class_status
bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
const struct bt_field_class *fc, uint64_t value,
for (i = 0; i < bt_field_class_enumeration_get_mapping_count(ir_fc); i++) {
const char *label;
- const bt_field_class_unsigned_enumeration_mapping_ranges *u_ranges;
- const bt_field_class_signed_enumeration_mapping_ranges *i_ranges;
+ const bt_field_class_enumeration_mapping *mapping;
+ const bt_field_class_unsigned_enumeration_mapping *u_mapping;
+ const bt_field_class_signed_enumeration_mapping *i_mapping;
uint64_t range_count;
uint64_t range_i;
if (is_signed) {
- bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
- ir_fc, i, &label, &i_ranges);
- range_count = bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
- i_ranges);
+ i_mapping = bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
+ ir_fc, i);
+ mapping = bt_field_class_signed_enumeration_mapping_as_mapping_const(
+ i_mapping);
} else {
- bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
- ir_fc, i, &label, &u_ranges);
- range_count = bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
- u_ranges);
+ u_mapping = bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+ ir_fc, i);
+ mapping = bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
+ u_mapping);
}
+ label = bt_field_class_enumeration_mapping_get_label(
+ mapping);
+ range_count =
+ bt_field_class_enumeration_mapping_get_range_count(
+ mapping);
+
for (range_i = 0; range_i < range_count; range_i++) {
append_indent(ctx);
if (is_signed) {
int64_t lower, upper;
- bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
- i_ranges, range_i,
+ bt_field_class_signed_enumeration_mapping_get_range_by_index(
+ i_mapping, range_i,
&lower, &upper);
if (lower == upper) {
} else {
uint64_t lower, upper;
- bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
- u_ranges, range_i,
+ bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
+ u_mapping, range_i,
&lower, &upper);
if (lower == upper) {
enum_mapping_count = bt_field_class_enumeration_get_mapping_count(in_field_class);
for (i = 0; i < enum_mapping_count; i++) {
const char *label;
- const bt_field_class_unsigned_enumeration_mapping_ranges *ranges;
+ const bt_field_class_unsigned_enumeration_mapping *u_mapping;
+ const bt_field_class_enumeration_mapping *mapping;
uint64_t range_index, range_count;
/* Get the ranges and the range count. */
- bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
- in_field_class, i, &label, &ranges);
+ u_mapping = bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+ in_field_class, i);
+ mapping = bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
+ u_mapping);
range_count =
- bt_field_class_unsigned_enumeration_mapping_ranges_get_range_count(
- ranges);
+ bt_field_class_enumeration_mapping_get_range_count(
+ mapping);
+ label = bt_field_class_enumeration_mapping_get_label(
+ mapping);
+
/*
* Iterate over all the ranges to add them to copied field
* class.
for (range_index = 0; range_index < range_count; range_index++) {
uint64_t lower, upper;
bt_field_class_status status;
- bt_field_class_unsigned_enumeration_mapping_ranges_get_range_by_index(
- ranges, range_index, &lower, &upper);
+ bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
+ u_mapping, range_index, &lower, &upper);
BT_LOGD("Copying range in enumeration field class: "
"label=%s, lower=%"PRId64", upper=%"PRId64,
bt_field_class_enumeration_get_mapping_count(in_field_class);
for (i = 0; i < enum_mapping_count; i++) {
const char *label;
- const bt_field_class_signed_enumeration_mapping_ranges *ranges;
+ const bt_field_class_signed_enumeration_mapping *i_mapping;
+ const bt_field_class_enumeration_mapping *mapping;
uint64_t range_index, range_count;
/* Get the ranges and the range count. */
- bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
- in_field_class, i, &label, &ranges);
+ i_mapping = bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
+ in_field_class, i);
+ mapping = bt_field_class_signed_enumeration_mapping_as_mapping_const(
+ i_mapping);
range_count =
- bt_field_class_signed_enumeration_mapping_ranges_get_range_count(
- ranges);
+ bt_field_class_enumeration_mapping_get_range_count(
+ mapping);
+ label = bt_field_class_enumeration_mapping_get_label(
+ mapping);
+
/*
* Iterate over all the ranges to add them to copied field
* class.
for (range_index = 0; range_index < range_count; range_index++) {
int64_t lower, upper;
bt_field_class_status status;
- bt_field_class_signed_enumeration_mapping_ranges_get_range_by_index(
- ranges, range_index, &lower, &upper);
+ bt_field_class_signed_enumeration_mapping_get_range_by_index(
+ i_mapping, range_index, &lower, &upper);
BT_LOGD("Copying range in enumeration field class: "
"label=%s, lower=%ld, upper=%ld",