ir: add bt_ctf_field_string_append()
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 15 Apr 2015 20:18:34 +0000 (16:18 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 20 Apr 2015 14:28:16 +0000 (10:28 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-fields.c
include/babeltrace/ctf-ir/event-fields.h

index a93cf695c6c5a86c50c41889cd254177b4563640..92c06da8b0ec8a7bf58ae3cd76d8e0aea38e2bef 100644 (file)
@@ -919,6 +919,33 @@ end:
        return ret;
 }
 
+int bt_ctf_field_string_append(struct bt_ctf_field *field,
+               const char *value)
+{
+       int ret = 0;
+       struct bt_ctf_field_string *string_field;
+
+       if (!field || !value ||
+               bt_ctf_field_type_get_type_id(field->type) !=
+                       CTF_TYPE_STRING) {
+               ret = -1;
+               goto end;
+       }
+
+       string_field = container_of(field, struct bt_ctf_field_string, parent);
+
+       if (string_field->payload) {
+               g_string_append(string_field->payload, value);
+       } else {
+               string_field->payload = g_string_new(value);
+       }
+
+       string_field->parent.payload_set = 1;
+
+end:
+       return ret;
+}
+
 BT_HIDDEN
 int bt_ctf_field_validate(struct bt_ctf_field *field)
 {
index f0dd825ceb24485ddf034d7f99e2ee2d0e51ee90..489c2bf8ee0a5f9c2722b90dfb4bcf21af409965 100644 (file)
@@ -288,6 +288,22 @@ extern const char *bt_ctf_field_string_get_value(
 extern int bt_ctf_field_string_set_value(struct bt_ctf_field *string_field,
                const char *value);
 
+/*
+ * bt_ctf_field_string_append: append a string to a string field's
+ * current value.
+ *
+ * Append a string to the current value of a string field. If the string
+ * field was never set using bt_ctf_field_string_set_value(), it is
+ * first set to an empty string, and then the concatenation happens.
+ *
+ * @param string_field String field instance.
+ * @param value String to append to the current string field's value.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_string_append(struct bt_ctf_field *string_field,
+               const char *value);
+
 /*
  * bt_ctf_field_get_type: get a field's type
  *
This page took 0.025973 seconds and 4 git commands to generate.