Make bt_ctf_field_structure_set_field public
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 2 Mar 2017 22:06:14 +0000 (17:06 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:39 +0000 (12:57 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/fields-internal.h
include/babeltrace/ctf-ir/fields.h
lib/ctf-ir/fields.c

index 720b88848b776f10d1de6d1563d542e488b28c73..75769fdf9bd3f6277d387127f768eadb9f2bfc88 100644 (file)
@@ -89,13 +89,6 @@ struct bt_ctf_field_string {
        GString *payload;
 };
 
-/*
- * Set a field's value with an already allocated field instance.
- */
-BT_HIDDEN
-int bt_ctf_field_structure_set_field(struct bt_ctf_field *structure,
-               const char *name, struct bt_ctf_field *value);
-
 /* Validate that the field's payload is set (returns 0 if set). */
 BT_HIDDEN
 int bt_ctf_field_validate(struct bt_ctf_field *field);
index 2ce3b633745ecfa712f125894697353dd2b1d7a0..5120d9e41739f665335c4947311c8112a0b41a1f 100644 (file)
@@ -88,6 +88,9 @@ yet:
 - bt_ctf_field_sequence_get_field()
 - bt_ctf_field_variant_get_field()
 
+If you already have a field object, you can also assign it to a specific
+name within a @structfield with bt_ctf_field_structure_set_field().
+
 You can get a reference to the @ft which was used to create a field with
 bt_ctf_field_get_type(). You can get the
 \link #bt_ctf_type_id type ID\endlink of this field type directly with
@@ -824,7 +827,9 @@ different @fts, and which is described by a @structft.
 
 To set the value of a specific field of a structure field, you need to
 first get the field with bt_ctf_field_structure_get_field() or
-bt_ctf_field_structure_get_field_by_index().
+bt_ctf_field_structure_get_field_by_index(). If you already have a
+field object, you can assign it to a specific name within a structure
+field with bt_ctf_field_structure_set_field().
 
 @sa ctfirstructfieldtype
 @sa ctfirfields
@@ -854,6 +859,8 @@ exist.
 
 @sa bt_ctf_field_structure_get_field_by_index(): Returns the field of a
        given structure field by index.
+@sa bt_ctf_field_structure_set_field(): Sets the field of a given
+       structure field.
 */
 extern struct bt_ctf_field *bt_ctf_field_structure_get_field(
                struct bt_ctf_field *struct_field, const char *name);
@@ -878,10 +885,55 @@ extern struct bt_ctf_field *bt_ctf_field_structure_get_field(
 
 @sa bt_ctf_field_structure_get_field(): Returns the field of a
        given structure field by name.
+@sa bt_ctf_field_structure_set_field(): Sets the field of a given
+       structure field.
 */
 extern struct bt_ctf_field *bt_ctf_field_structure_get_field_by_index(
                struct bt_ctf_field *struct_field, int index);
 
+/**
+@brief Sets the field of the @structfield \p struct_field named \p name
+       to the @field \p field.
+
+If \p struct_field already contains a field named \p name, then its
+reference count is decremented, and \p field replaces it.
+
+The field type of \p field, as returned by bt_ctf_field_get_type(),
+\em must be equivalent to the field type returned by
+bt_ctf_field_type_structure_get_field_type_by_name() with the field
+type of \p struct_field and the same name, \p name.
+
+bt_ctf_trace_get_packet_header_type() for the parent trace class of
+\p packet.
+
+@param[in] struct_field        Structure field of which to set the field
+                       named \p name.
+@param[in] name                Name of the field to set in \p struct_field.
+@param[in] field       Field named \p name to set in \p struct_field.
+@returns               0 on success, or -1 on error.
+
+@prenotnull{struct_field}
+@prenotnull{name}
+@prenotnull{field}
+@prehot{struct_field}
+@preisstructfield{struct_field}
+@pre \p field has a field type equivalent to the field type returned by
+       bt_ctf_field_type_structure_get_field_type_by_name() for the
+       field type of \p struct_field with the name \p name.
+@postrefcountsame{struct_field}
+@post <strong>On success, if there's an existing field in
+       \p struct_field named \p name</strong>, its reference count is
+       decremented.
+@postsuccessrefcountinc{field}
+
+@sa bt_ctf_field_structure_get_field_by_index(): Returns the field of a
+       given structure field by index.
+@sa bt_ctf_field_structure_get_field(): Returns the field of a
+       given structure field by name.
+*/
+extern int bt_ctf_field_structure_set_field(struct bt_ctf_field *struct_field,
+               const char *name, struct bt_ctf_field *field);
+
 /** @} */
 
 /**
index eb98259a51e7077f177267d7b8e6c64712471370..48dce5669a7090facd0aee08eb75d30e442fb2fc 100644 (file)
@@ -576,7 +576,6 @@ error:
        return ret_field;
 }
 
-BT_HIDDEN
 int bt_ctf_field_structure_set_field(struct bt_ctf_field *field,
                const char *name, struct bt_ctf_field *value)
 {
This page took 0.02614 seconds and 4 git commands to generate.