sink.text.details: print bit array field classes and fields
[babeltrace.git] / src / plugins / text / details / write.c
index f6d0eea813c22c6df1410208528af1ec9e1e000c..6f3d69d796b2d096fa019775324638f0d938d6e2 100644 (file)
@@ -230,6 +230,14 @@ void write_str_prop_value(struct details_write_ctx *ctx, const char *value)
                color_bold(ctx), value, color_reset(ctx));
 }
 
+static inline
+void write_none_prop_value(struct details_write_ctx *ctx, const char *value)
+{
+       g_string_append_printf(ctx->str, "%s%s%s%s",
+               color_bold(ctx), color_fg_magenta(ctx),
+               value, color_reset(ctx));
+}
+
 static inline
 void write_uint_str_prop_value(struct details_write_ctx *ctx, const char *value)
 {
@@ -772,6 +780,9 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
        case BT_FIELD_CLASS_TYPE_BOOL:
                type = "Boolean";
                break;
+       case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
+               type = "Bit array";
+               break;
        case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
                type = "Unsigned integer";
                break;
@@ -799,6 +810,9 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
        case BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY:
                type = "Dynamic array";
                break;
+       case BT_FIELD_CLASS_TYPE_OPTION:
+               type = "Option";
+               break;
        case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
                type = "Variant (no selector)";
                break;
@@ -912,6 +926,27 @@ void write_field_class(struct details_write_ctx *ctx, const bt_field_class *fc)
                        bt_field_class_array_borrow_element_field_class_const(fc));
                decr_indent(ctx);
                break;
+       case BT_FIELD_CLASS_TYPE_OPTION:
+       {
+               const bt_field_path *selector_field_path =
+                       bt_field_class_option_borrow_selector_field_path_const(fc);
+
+               if (selector_field_path) {
+                       g_string_append(ctx->str, " (Selector field path ");
+                       write_field_path(ctx, selector_field_path);
+                       g_string_append_c(ctx->str, ')');
+               }
+
+               g_string_append_c(ctx->str, ':');
+               write_nl(ctx);
+               incr_indent(ctx);
+               write_compound_member_name(ctx, "Content");
+               write_sp(ctx);
+               write_field_class(ctx,
+                       bt_field_class_option_borrow_field_class_const(fc));
+               decr_indent(ctx);
+               break;
+       }
        case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
@@ -1488,6 +1523,12 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field,
                write_sp(ctx);
                write_bool_prop_value(ctx, bt_field_bool_get_value(field));
                break;
+       case BT_FIELD_CLASS_TYPE_BIT_ARRAY:
+               format_uint(buf, bt_field_bit_array_get_value_as_integer(field),
+                       16);
+               write_sp(ctx);
+               write_uint_str_prop_value(ctx, buf);
+               break;
        case BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER:
        case BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION:
        case BT_FIELD_CLASS_TYPE_SIGNED_INTEGER:
@@ -1566,7 +1607,8 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field,
 
                        decr_indent(ctx);
                } else {
-                       g_string_append(ctx->str, " Empty");
+                       write_sp(ctx);
+                       write_none_prop_value(ctx, "Empty");
                }
 
                break;
@@ -1577,7 +1619,8 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field,
                uint64_t length = bt_field_array_get_length(field);
 
                if (length == 0) {
-                       g_string_append(ctx->str, " Empty");
+                       write_sp(ctx);
+                       write_none_prop_value(ctx, "Empty");
                } else {
                        g_string_append(ctx->str, " Length ");
                        write_uint_prop_value(ctx, length);
@@ -1599,6 +1642,20 @@ void write_field(struct details_write_ctx *ctx, const bt_field *field,
                decr_indent(ctx);
                break;
        }
+       case BT_FIELD_CLASS_TYPE_OPTION:
+       {
+               const bt_field *content_field =
+                       bt_field_option_borrow_field_const(field);
+
+               if (!content_field) {
+                       write_sp(ctx);
+                       write_none_prop_value(ctx, "None");
+               } else {
+                       write_field(ctx, content_field, NULL);
+               }
+
+               break;
+       }
        case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
        case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
This page took 0.026647 seconds and 4 git commands to generate.