Add --debug-info-target-prefix
[babeltrace.git] / include / babeltrace / values.h
index c0a3fa459aa4b857548f61a9e1c3757c4461b001..e13cc2020d6dbd9ec6656f968a2f1364501a1cb6 100644 (file)
@@ -52,9 +52,8 @@
  * \link bt_value_map_insert() inserting a value object into a map
  * value object\endlink, its reference count is incremented, as well as
  * when getting a value object back from those structures. The
- * bt_value_get() and bt_value_put() functions exist to deal with
- * reference counting. Once you are done with a value object, pass it to
- * bt_value_put().
+ * bt_get() and bt_put() functions are to be used to handle reference counting
+ * Once you are done with a value object, pass it to bt_put().
  *
  * Most functions of this API return a status code, one of the values in
  * #bt_value_status.
@@ -75,6 +74,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <stddef.h>
+#include <babeltrace/ref.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -158,7 +158,7 @@ extern struct bt_value *bt_value_null;
  * User function type for bt_value_map_foreach().
  *
  * \p object is a \em weak reference; you must pass it to
- * bt_value_get() to get your own reference.
+ * bt_get() to get your own reference.
  *
  * Return \c true to continue the loop, or \c false to break it.
  *
@@ -170,68 +170,12 @@ extern struct bt_value *bt_value_null;
 typedef bool (* bt_value_map_foreach_cb)(const char *key,
        struct bt_value *object, void *data);
 
-/**
- * Puts the value object \p _object (calls bt_value_put() on it), and
- * resets the variable to \c NULL.
- *
- * This is something that is often done when putting a value object;
- * resetting the variable to \c NULL makes sure it cannot be put a
- * second time later.
- *
- * @param _object      Value object to put
- *
- * @see BT_VALUE_MOVE() (moves a value object from one variable to the
- *                     other without putting it)
- */
-#define BT_VALUE_PUT(_object)                          \
-       do {                                            \
-               bt_value_put(_object);                  \
-               (_object) = NULL;                       \
-       } while (0)
-
-/**
- * Moves the value object referenced by the variable \p _src_object to
- * the \p _dst_object variable, then resets \p _src_object to \c NULL.
- *
- * The value object's reference count is <b>not changed</b>. Resetting
- * \p _src_object to \c NULL ensures the value object will not be put
- * twice later; its ownership is indeed \em moved from the source
- * variable to the destination variable.
- *
- * @param _src_object  Source value object variable
- * @param _dst_object  Destination value object variable
- */
-#define BT_VALUE_MOVE(_dst_object, _src_object)        \
-       do {                                            \
-               (_dst_object) = (_src_object);          \
-               (_src_object) = NULL;                   \
-       } while (0)
-
-/**
- * Increments the reference count of \p object.
- *
- * @param object       Value object of which to increment the reference count
- *
- * @see bt_value_put()
- */
-extern void bt_value_get(struct bt_value *object);
-
-/**
- * Decrements the reference count of \p object, destroying it when this
- * count reaches 0.
- *
- * @param object       Value object of which to decrement the reference count
- *
- * @see bt_value_get()
- */
-extern void bt_value_put(struct bt_value *object);
-
 /**
  * Recursively freezes the value object \p object.
  *
  * A frozen value object cannot be modified; it is considered immutable.
  * Reference counting still works on a frozen value object though: you
- * may pass a frozen value object to bt_value_get() and bt_value_put().
+ * may pass a frozen value object to bt_get() and bt_put().
  *
  * @param object       Value object to freeze
  * @returns            One of #bt_value_status values; if \p object
@@ -497,7 +441,7 @@ extern struct bt_value *bt_value_map_create(void);
  * @see bt_value_bool_set()
  */
 extern enum bt_value_status bt_value_bool_get(
-       const struct bt_value *bool_obj, bool *val);
+               const struct bt_value *bool_obj, bool *val);
 
 /**
  * Sets the boolean raw value of the boolean value object \p bool_obj
@@ -510,7 +454,7 @@ extern enum bt_value_status bt_value_bool_get(
  * @see bt_value_bool_get()
  */
 extern enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj,
-       bool val);
+               bool val);
 
 /**
  * Gets the integer raw value of the integer value object
@@ -523,7 +467,7 @@ extern enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj,
  * @see bt_value_integer_set()
  */
 extern enum bt_value_status bt_value_integer_get(
-       const struct bt_value *integer_obj, int64_t *val);
+               const struct bt_value *integer_obj, int64_t *val);
 
 /**
  * Sets the integer raw value of the integer value object \p integer_obj
@@ -536,7 +480,7 @@ extern enum bt_value_status bt_value_integer_get(
  * @see bt_value_integer_get()
  */
 extern enum bt_value_status bt_value_integer_set(
-       struct bt_value *integer_obj, int64_t val);
+               struct bt_value *integer_obj, int64_t val);
 
 /**
  * Gets the floating point number raw value of the floating point number
@@ -549,7 +493,7 @@ extern enum bt_value_status bt_value_integer_set(
  * @see bt_value_float_set()
  */
 extern enum bt_value_status bt_value_float_get(
-       const struct bt_value *float_obj, double *val);
+               const struct bt_value *float_obj, double *val);
 
 /**
  * Sets the floating point number raw value of the floating point number
@@ -562,7 +506,7 @@ extern enum bt_value_status bt_value_float_get(
  * @see bt_value_float_get()
  */
 extern enum bt_value_status bt_value_float_set(
-       struct bt_value *float_obj, double val);
+               struct bt_value *float_obj, double val);
 
 /**
  * Gets the string raw value of the string value object \p string_obj.
@@ -577,7 +521,7 @@ extern enum bt_value_status bt_value_float_set(
  * @see bt_value_string_set()
  */
 extern enum bt_value_status bt_value_string_get(
-       const struct bt_value *string_obj, const char **val);
+               const struct bt_value *string_obj, const char **val);
 
 /**
  * Sets the string raw value of the string value object \p string_obj to
@@ -592,7 +536,7 @@ extern enum bt_value_status bt_value_string_get(
  * @see bt_value_string_get()
  */
 extern enum bt_value_status bt_value_string_set(struct bt_value *string_obj,
-       const char *val);
+               const char *val);
 
 /**
  * Gets the size of the array value object \p array_obj, that is, the
@@ -630,7 +574,7 @@ extern bool bt_value_array_is_empty(const struct bt_value *array_obj);
  *                     success, or \c NULL on error
  */
 extern struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
-       size_t index);
+               size_t index);
 
 /**
  * Appends the value object \p element_obj to the array value
@@ -647,11 +591,11 @@ extern struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
  * @see bt_value_array_append_integer()
  * @see bt_value_array_append_float()
  * @see bt_value_array_append_string()
- * @see bt_value_array_append_array()
- * @see bt_value_array_append_map()
+ * @see bt_value_array_append_empty_array()
+ * @see bt_value_array_append_empty_map()
  */
 extern enum bt_value_status bt_value_array_append(struct bt_value *array_obj,
-       struct bt_value *element_obj);
+               struct bt_value *element_obj);
 
 /**
  * Appends the boolean raw value \p val to the array value object
@@ -667,7 +611,7 @@ extern enum bt_value_status bt_value_array_append(struct bt_value *array_obj,
  * @see bt_value_array_append()
  */
 extern enum bt_value_status bt_value_array_append_bool(
-       struct bt_value *array_obj, bool val);
+               struct bt_value *array_obj, bool val);
 
 /**
  * Appends the integer raw value \p val to the array value object
@@ -683,7 +627,7 @@ extern enum bt_value_status bt_value_array_append_bool(
  * @see bt_value_array_append()
  */
 extern enum bt_value_status bt_value_array_append_integer(
-       struct bt_value *array_obj, int64_t val);
+               struct bt_value *array_obj, int64_t val);
 
 /**
  * Appends the floating point number raw value \p val to the array value
@@ -700,7 +644,7 @@ extern enum bt_value_status bt_value_array_append_integer(
  * @see bt_value_array_append()
  */
 extern enum bt_value_status bt_value_array_append_float(
-       struct bt_value *array_obj, double val);
+               struct bt_value *array_obj, double val);
 
 /**
  * Appends the string raw value \p val to the array value object
@@ -718,7 +662,7 @@ extern enum bt_value_status bt_value_array_append_float(
  * @see bt_value_array_append()
  */
 extern enum bt_value_status bt_value_array_append_string(
-       struct bt_value *array_obj, const char *val);
+               struct bt_value *array_obj, const char *val);
 
 /**
  * Appends an empty array value object to the array value object
@@ -732,8 +676,8 @@ extern enum bt_value_status bt_value_array_append_string(
  *
  * @see bt_value_array_append()
  */
-extern enum bt_value_status bt_value_array_append_array(
-       struct bt_value *array_obj);
+extern enum bt_value_status bt_value_array_append_empty_array(
+               struct bt_value *array_obj);
 
 /**
  * Appends an empty map value object to the array value object
@@ -747,8 +691,8 @@ extern enum bt_value_status bt_value_array_append_array(
  *
  * @see bt_value_array_append()
  */
-extern enum bt_value_status bt_value_array_append_map(
-       struct bt_value *array_obj);
+extern enum bt_value_status bt_value_array_append_empty_map(
+               struct bt_value *array_obj);
 
 /**
  * Replaces the value object at index \p index of the array
@@ -765,7 +709,7 @@ extern enum bt_value_status bt_value_array_append_map(
  * @returns            One of #bt_value_status values
  */
 extern enum bt_value_status bt_value_array_set(struct bt_value *array_obj,
-       size_t index, struct bt_value *element_obj);
+               size_t index, struct bt_value *element_obj);
 
 /**
  * Gets the size of a map value object, that is, the number of entries
@@ -803,15 +747,15 @@ extern bool bt_value_map_is_empty(const struct bt_value *map_obj);
  *                     on success, or \c NULL on error
  */
 extern struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
-       const char *key);
+               const char *key);
 
 /**
  * Calls a provided user function \p cb for each value object of the map
  * value object \p map_obj.
  *
  * The value object passed to the user function is a
- * <b>weak reference</b>: you must call bt_value_get() on it to obtain
- * your own reference.
+ * <b>weak reference</b>: you must call bt_get() on it to obtain your own
+ * reference.
  *
  * The key passed to the user function is only valid in the scope of
  * this user function call.
@@ -828,8 +772,8 @@ extern struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
  *                     function
  */
 extern enum bt_value_status bt_value_map_foreach(
-       const struct bt_value *map_obj, bt_value_map_foreach_cb cb,
-       void *data);
+               const struct bt_value *map_obj, bt_value_map_foreach_cb cb,
+               void *data);
 
 /**
  * Returns whether or not the map value object \p map_obj contains the
@@ -842,7 +786,7 @@ extern enum bt_value_status bt_value_map_foreach(
  *                     on error
  */
 extern bool bt_value_map_has_key(const struct bt_value *map_obj,
-       const char *key);
+               const char *key);
 
 /**
  * Inserts the value object \p element_obj associated with the key
@@ -865,12 +809,12 @@ extern bool bt_value_map_has_key(const struct bt_value *map_obj,
  * @see bt_value_map_insert_integer()
  * @see bt_value_map_insert_float()
  * @see bt_value_map_insert_string()
- * @see bt_value_map_insert_array()
- * @see bt_value_map_insert_map()
+ * @see bt_value_map_insert_empty_array()
+ * @see bt_value_map_insert_empty_map()
  */
 extern enum bt_value_status bt_value_map_insert(
-       struct bt_value *map_obj, const char *key,
-       struct bt_value *element_obj);
+               struct bt_value *map_obj, const char *key,
+               struct bt_value *element_obj);
 
 /**
  * Inserts the boolean raw value \p val associated with the key \p key
@@ -892,7 +836,7 @@ extern enum bt_value_status bt_value_map_insert(
  * @see bt_value_map_insert()
  */
 extern enum bt_value_status bt_value_map_insert_bool(
-       struct bt_value *map_obj, const char *key, bool val);
+               struct bt_value *map_obj, const char *key, bool val);
 
 /**
  * Inserts the integer raw value \p val associated with the key \p key
@@ -913,7 +857,7 @@ extern enum bt_value_status bt_value_map_insert_bool(
  * @see bt_value_map_insert()
  */
 extern enum bt_value_status bt_value_map_insert_integer(
-       struct bt_value *map_obj, const char *key, int64_t val);
+               struct bt_value *map_obj, const char *key, int64_t val);
 
 /**
  * Inserts the floating point number raw value \p val associated with
@@ -936,7 +880,7 @@ extern enum bt_value_status bt_value_map_insert_integer(
  * @see bt_value_map_insert()
  */
 extern enum bt_value_status bt_value_map_insert_float(
-       struct bt_value *map_obj, const char *key, double val);
+               struct bt_value *map_obj, const char *key, double val);
 
 /**
  * Inserts the string raw value \p val associated with the key \p key
@@ -957,7 +901,7 @@ extern enum bt_value_status bt_value_map_insert_float(
  * @see bt_value_map_insert()
  */
 extern enum bt_value_status bt_value_map_insert_string(
-       struct bt_value *map_obj, const char *key, const char *val);
+               struct bt_value *map_obj, const char *key, const char *val);
 
 /**
  * Inserts an empty array value object associated with the key \p key
@@ -975,8 +919,8 @@ extern enum bt_value_status bt_value_map_insert_string(
  *
  * @see bt_value_map_insert()
  */
-extern enum bt_value_status bt_value_map_insert_array(
-       struct bt_value *map_obj, const char *key);
+extern enum bt_value_status bt_value_map_insert_empty_array(
+               struct bt_value *map_obj, const char *key);
 
 /**
  * Inserts an empty map value object associated with the key \p key into
@@ -994,8 +938,8 @@ extern enum bt_value_status bt_value_map_insert_array(
  *
  * @see bt_value_map_insert()
  */
-extern enum bt_value_status bt_value_map_insert_map(
-       struct bt_value *map_obj, const char *key);
+extern enum bt_value_status bt_value_map_insert_empty_map(
+               struct bt_value *map_obj, const char *key);
 
 /**
  * Creates a deep copy of the value object \p object.
@@ -1023,7 +967,7 @@ extern struct bt_value *bt_value_copy(const struct bt_value *object);
  *                     error
  */
 extern bool bt_value_compare(const struct bt_value *object_a,
-       const struct bt_value *object_b);
+               const struct bt_value *object_b);
 
 #ifdef __cplusplus
 }
This page took 0.028481 seconds and 4 git commands to generate.