lib: decouple variant FC option names from selector FC mapping names
[babeltrace.git] / src / plugins / ctf / fs-sink / fs-sink-ctf-meta.h
index 7585ac745735c5f75a97aa1e9c76c4fd42405303..19912afb7b5aa2ad1bbdfb6026c01e0fe787fa0a 100644 (file)
@@ -18,7 +18,7 @@
 #include <babeltrace2/babeltrace.h>
 #include "common/common.h"
 #include "common/assert.h"
-#include "compat/uuid.h"
+#include "common/uuid.h"
 #include <glib.h>
 #include <stdint.h>
 #include <string.h>
@@ -133,6 +133,7 @@ struct fs_sink_ctf_stream_class {
        const bt_clock_class *default_clock_class;
 
        GString *default_clock_class_name;
+       bool has_packets;
        bool packets_have_ts_begin;
        bool packets_have_ts_end;
        bool has_discarded_events;
@@ -162,7 +163,7 @@ struct fs_sink_ctf_trace {
        /* Weak */
        const bt_trace_class *ir_tc;
 
-       unsigned char uuid[BABELTRACE_UUID_LEN];
+       bt_uuid_t uuid;
 
        /* Array of `struct fs_sink_ctf_stream_class *` (owned by this) */
        GPtrArray *stream_classes;
@@ -310,8 +311,8 @@ struct fs_sink_ctf_field_class_variant *fs_sink_ctf_field_class_variant_create_e
        fc->tag_ref = g_string_new(NULL);
        BT_ASSERT(fc->tag_ref);
        fc->tag_is_before =
-               bt_field_class_variant_borrow_selector_field_path_const(ir_fc) ==
-               NULL;
+               bt_field_class_get_type(fc->base.ir_fc) ==
+               BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR;
        return fc;
 }
 
@@ -739,6 +740,7 @@ struct fs_sink_ctf_stream_class *fs_sink_ctf_stream_class_create(
        sc->event_classes_from_ir = g_hash_table_new(g_direct_hash,
                g_direct_equal);
        BT_ASSERT(sc->event_classes_from_ir);
+       sc->has_packets = bt_stream_class_supports_packets(ir_sc);
        sc->packets_have_ts_begin =
                bt_stream_class_packets_have_beginning_default_clock_snapshot(
                        ir_sc);
@@ -823,11 +825,7 @@ struct fs_sink_ctf_trace *fs_sink_ctf_trace_create(const bt_trace *ir_trace)
 
        BT_ASSERT(trace);
 
-       if (bt_uuid_generate(trace->uuid)) {
-               fs_sink_ctf_trace_destroy(trace);
-               trace = NULL;
-               goto end;
-       }
+       bt_uuid_generate(trace->uuid);
 
        trace->ir_trace = ir_trace;
        trace->ir_tc = bt_trace_borrow_class_const(ir_trace);
@@ -835,95 +833,7 @@ struct fs_sink_ctf_trace *fs_sink_ctf_trace_create(const bt_trace *ir_trace)
                (GDestroyNotify) fs_sink_ctf_stream_class_destroy);
        BT_ASSERT(trace->stream_classes);
 
-end:
        return trace;
 }
 
-static inline
-bool fs_sink_ctf_ist_valid_identifier(const char *name)
-{
-       const char *at;
-       uint64_t i;
-       bool ist_valid = true;
-       static const char *reserved_keywords[] = {
-               "align",
-               "callsite",
-               "const",
-               "char",
-               "clock",
-               "double",
-               "enum",
-               "env",
-               "event",
-               "floating_point",
-               "float",
-               "integer",
-               "int",
-               "long",
-               "short",
-               "signed",
-               "stream",
-               "string",
-               "struct",
-               "trace",
-               "typealias",
-               "typedef",
-               "unsigned",
-               "variant",
-               "void",
-               "_Bool",
-               "_Complex",
-               "_Imaginary",
-       };
-
-       /* Make sure the name is not a reserved keyword */
-       for (i = 0; i < sizeof(reserved_keywords) / sizeof(*reserved_keywords);
-                       i++) {
-               if (strcmp(name, reserved_keywords[i]) == 0) {
-                       ist_valid = false;
-                       goto end;
-               }
-       }
-
-       /* Make sure the name is not an empty string */
-       if (strlen(name) == 0) {
-               ist_valid = false;
-               goto end;
-       }
-
-       /* Make sure the name starts with a letter or `_` */
-       if (!isalpha(name[0]) && name[0] != '_') {
-               ist_valid = false;
-               goto end;
-       }
-
-       /* Make sure the name only contains letters, digits, and `_` */
-       for (at = name; *at != '\0'; at++) {
-               if (!isalnum(*at) && *at != '_') {
-                       ist_valid = false;
-                       goto end;
-               }
-       }
-
-end:
-       return ist_valid;
-}
-
-static inline
-int fs_sink_ctf_protect_name(GString *name)
-{
-       int ret = 0;
-
-       if (!fs_sink_ctf_ist_valid_identifier(name->str)) {
-               ret = -1;
-               goto end;
-       }
-
-       /* Prepend `_` to protect it */
-       g_string_prepend_c(name, '_');
-
-end:
-       return ret;
-}
-
 #endif /* BABELTRACE_PLUGIN_CTF_FS_SINK_FS_SINK_CTF_META_H */
This page took 0.025943 seconds and 4 git commands to generate.