sink.ctf.fs: write boolean field classes and fields
[babeltrace.git] / src / plugins / ctf / fs-sink / fs-sink-ctf-meta.h
index ff73eb5e58bbc5f7817f093b9747571e7220c0e2..a96cbad8e5c30bedf4e53106be4394e8c1f9aaeb 100644 (file)
@@ -26,6 +26,7 @@
 #include <ctype.h>
 
 enum fs_sink_ctf_field_class_type {
+       FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL,
        FS_SINK_CTF_FIELD_CLASS_TYPE_INT,
        FS_SINK_CTF_FIELD_CLASS_TYPE_FLOAT,
        FS_SINK_CTF_FIELD_CLASS_TYPE_STRING,
@@ -52,6 +53,10 @@ struct fs_sink_ctf_field_class_bit_array {
        unsigned int size;
 };
 
+struct fs_sink_ctf_field_class_bool {
+       struct fs_sink_ctf_field_class_bit_array base;
+};
+
 struct fs_sink_ctf_field_class_int {
        struct fs_sink_ctf_field_class_bit_array base;
        bool is_signed;
@@ -236,6 +241,25 @@ void _fs_sink_ctf_named_field_class_fini(
        named_fc->fc = NULL;
 }
 
+static inline
+struct fs_sink_ctf_field_class_bool *fs_sink_ctf_field_class_bool_create(
+               const bt_field_class *ir_fc, uint64_t index_in_parent)
+{
+       struct fs_sink_ctf_field_class_bool *fc =
+               g_new0(struct fs_sink_ctf_field_class_bool, 1);
+
+       BT_ASSERT(fc);
+
+       /*
+        * CTF 1.8 has no boolean field class type, so this component
+        * translates it to an 8-bit unsigned integer field class.
+        */
+       _fs_sink_ctf_field_class_bit_array_init((void *) fc,
+               FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL, ir_fc,
+               8, index_in_parent);
+       return fc;
+}
+
 static inline
 struct fs_sink_ctf_field_class_int *fs_sink_ctf_field_class_int_create(
                const bt_field_class *ir_fc, uint64_t index_in_parent)
@@ -366,6 +390,15 @@ void _fs_sink_ctf_field_class_fini(struct fs_sink_ctf_field_class *fc)
        BT_ASSERT(fc);
 }
 
+static inline
+void _fs_sink_ctf_field_class_bool_destroy(
+               struct fs_sink_ctf_field_class_int *fc)
+{
+       BT_ASSERT(fc);
+       _fs_sink_ctf_field_class_fini((void *) fc);
+       g_free(fc);
+}
+
 static inline
 void _fs_sink_ctf_field_class_int_destroy(
                struct fs_sink_ctf_field_class_int *fc)
@@ -490,6 +523,9 @@ void fs_sink_ctf_field_class_destroy(struct fs_sink_ctf_field_class *fc)
        }
 
        switch (fc->type) {
+       case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
+               _fs_sink_ctf_field_class_bool_destroy((void *) fc);
+               break;
        case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
                _fs_sink_ctf_field_class_int_destroy((void *) fc);
                break;
This page took 0.024271 seconds and 4 git commands to generate.