%rename("_bt_ctf_writer_create") bt_ctf_writer_create(const char *path);
%rename("_bt_ctf_writer_create_stream") bt_ctf_writer_create_stream(struct bt_ctf_writer *writer, struct bt_ctf_stream_class *stream_class);
%rename("_bt_ctf_writer_add_environment_field") bt_ctf_writer_add_environment_field(struct bt_ctf_writer *writer, const char *name, const char *value);
+%rename("_bt_ctf_writer_add_environment_field_int64") bt_ctf_writer_add_environment_field_int64(struct bt_ctf_writer *writer, const char *name, int64_t value);
%rename("_bt_ctf_writer_add_clock") bt_ctf_writer_add_clock(struct bt_ctf_writer *writer, struct bt_ctf_clock *clock);
%newobject bt_ctf_writer_get_metadata_string;
%rename("_bt_ctf_writer_get_metadata_string") bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer);
struct bt_ctf_writer *bt_ctf_writer_create(const char *path);
struct bt_ctf_stream *bt_ctf_writer_create_stream(struct bt_ctf_writer *writer, struct bt_ctf_stream_class *stream_class);
int bt_ctf_writer_add_environment_field(struct bt_ctf_writer *writer, const char *name, const char *value);
+int bt_ctf_writer_add_environment_field_int64(struct bt_ctf_writer *writer, const char *name, int64_t value);
int bt_ctf_writer_add_clock(struct bt_ctf_writer *writer, struct bt_ctf_clock *clock);
char *bt_ctf_writer_get_metadata_string(struct bt_ctf_writer *writer);
void bt_ctf_writer_flush_metadata(struct bt_ctf_writer *writer);
Sets the CTF environment variable named *name* to value *value*
(converted to a string).
- :exc:`ValueError` is raised on error.
+ :exc:`ValueError` or `TypeError` is raised on error.
"""
- ret = nbt._bt_ctf_writer_add_environment_field(self._w, str(name),
- str(value))
+ if type(name) != str:
+ raise TypeError("Field name must be a string.")
+
+ t = type(value)
+
+ if t == str:
+ ret = nbt._bt_ctf_writer_add_environment_field(self._w, name,
+ value)
+ elif t == int:
+ ret = nbt._bt_ctf_writer_add_environment_field_int64(self._w,
+ name,
+ value)
+ else:
+ raise TypeError("Value type is not supported.")
if ret < 0:
raise ValueError("Could not add environment field to trace.")
return ret;
}
+int bt_ctf_writer_add_environment_field_int64(struct bt_ctf_writer *writer,
+ const char *name,
+ int64_t value)
+{
+ int ret = -1;
+
+ if (!writer || !name) {
+ goto end;
+ }
+
+ ret = bt_ctf_trace_set_environment_field_integer(writer->trace, name,
+ value);
+end:
+ return ret;
+}
+
int bt_ctf_writer_add_clock(struct bt_ctf_writer *writer,
struct bt_ctf_clock *clock)
{
const char *name,
const char *value);
+/*
+ * bt_ctf_writer_add_environment_field_int64: add an environment field to the trace.
+ *
+ * Add an environment field to the trace. The name and value parameters are
+ * copied.
+ *
+ * @param writer Writer instance.
+ * @param name Name of the environment field (will be copied).
+ * @param value Value of the environment field.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_writer_add_environment_field_int64(
+ struct bt_ctf_writer *writer,
+ const char *name,
+ int64_t value);
+
/*
* bt_ctf_writer_add_clock: add a clock to the trace.
*