Rename: "float value" -> "real value"
[babeltrace.git] / include / babeltrace / values.h
index d4a2214b1f35ff355ceeebadefa0f33a381c3c23..0e03596ad8faef15de11d1c254c916e77c5dac82 100644 (file)
 
 #include <stdint.h>
 #include <stddef.h>
-#include <babeltrace/ref.h>
+
+/* For bt_bool */
 #include <babeltrace/types.h>
 
+/* For bt_get() */
+#include <babeltrace/ref.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -72,14 +76,6 @@ values of #bt_value_status.
 You can create a deep copy of any value object with bt_value_copy(). You
 can compare two value objects with bt_value_compare().
 
-You can \em freeze a value object with bt_value_freeze(). You can get
-the raw value of a frozen value object, but you cannot modify it.
-Reference counting still works on frozen value objects. You can copy
-a frozen value object: the returned copy is not frozen. You can also
-compare a frozen value object to another value object (frozen or not).
-Freezing a value object is typically used to make it immutable after
-it's built by its initial owner.
-
 The following matrix shows some categorized value object functions
 to use for each value object type:
 
@@ -174,11 +170,8 @@ to use for each value object type:
 @brief Status codes.
 */
 enum bt_value_status {
-       /// Value object cannot be altered because it's frozen.
-       BT_VALUE_STATUS_FROZEN =        -4,
-
-       /// Operation cancelled.
-       BT_VALUE_STATUS_CANCELLED =     -3,
+       /// Operation canceled.
+       BT_VALUE_STATUS_CANCELED =      -3,
 
        /* -22 for compatibility with -EINVAL */
        /// Invalid argument.
@@ -229,9 +222,6 @@ extern struct bt_value *bt_value_null;
 @brief Value object type.
 */
 enum bt_value_type {
-       /// Unknown value object, used as an error code.
-       BT_VALUE_TYPE_UNKNOWN =         -1,
-
        /// Null value object.
        BT_VALUE_TYPE_NULL =            0,
 
@@ -242,7 +232,7 @@ enum bt_value_type {
        BT_VALUE_TYPE_INTEGER =         2,
 
        /// Floating point number value object (holds a \c double raw value).
-       BT_VALUE_TYPE_FLOAT =           3,
+       BT_VALUE_TYPE_REAL =            3,
 
        /// String value object.
        BT_VALUE_TYPE_STRING =          4,
@@ -352,9 +342,9 @@ bt_bool bt_value_is_integer(const struct bt_value *object)
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bt_bool bt_value_is_float(const struct bt_value *object)
+bt_bool bt_value_is_real(const struct bt_value *object)
 {
-       return bt_value_get_type(object) == BT_VALUE_TYPE_FLOAT;
+       return bt_value_get_type(object) == BT_VALUE_TYPE_REAL;
 }
 
 /**
@@ -418,46 +408,6 @@ bt_bool bt_value_is_map(const struct bt_value *object)
 @{
 */
 
-/**
-@brief Recursively freezes the value object \p object.
-
-You cannot modify a frozen value object: it is considered immutable.
-Reference counting still works on a frozen value object, however: you
-can pass a frozen value object to bt_get() and bt_put().
-
-If \p object is an array value object or a map value object, this
-function also freezes all its children recursively.
-
-Freezing a value object is typically used to make it immutable after
-it's built by its initial owner.
-
-@param[in] object      Value object to freeze.
-@returns               Status code. If \p object
-                       is already frozen, however, #BT_VALUE_STATUS_OK
-                       is returned anyway (that is, this function never
-                       returns #BT_VALUE_STATUS_FROZEN).
-
-@prenotnull{object}
-@postrefcountsame{object}
-@post <strong>On success</strong>, \p object and all its children
-       are frozen.
-
-@sa bt_value_is_frozen(): Returns whether or not a value object is
-       frozen.
-*/
-extern enum bt_value_status bt_value_freeze(struct bt_value *object);
-
-/**
-@brief Returns whether or not the value object \p object is frozen.
-
-@param[in] object      Value object to check.
-@returns               #BT_TRUE if \p object is frozen.
-
-@prenotnull{object}
-@postrefcountsame{object}
-*/
-extern bt_bool bt_value_is_frozen(const struct bt_value *object);
-
 /**
 @brief Creates a \em deep copy of the value object \p object.
 
@@ -664,7 +614,7 @@ The created floating point number value object's initial raw value is 0.
 @sa bt_value_float_create_init(): Creates an initialized floating
        point number value object.
 */
-extern struct bt_value *bt_value_float_create(void);
+extern struct bt_value *bt_value_real_create(void);
 
 /**
 @brief Creates a floating point number value object with its initial raw
@@ -679,7 +629,7 @@ extern struct bt_value *bt_value_float_create(void);
 @sa bt_value_float_create(): Creates a default floating point number
        value object.
 */
-extern struct bt_value *bt_value_float_create_init(double val);
+extern struct bt_value *bt_value_real_create_init(double val);
 
 /**
 @brief Returns the floating point number raw value of the floating point
@@ -698,8 +648,8 @@ extern struct bt_value *bt_value_float_create_init(double val);
 @sa bt_value_float_set(): Sets the raw value of a given floating
        point number value object.
 */
-extern enum bt_value_status bt_value_float_get(
-               const struct bt_value *float_obj, double *val);
+extern enum bt_value_status bt_value_real_get(
+               const struct bt_value *real_obj, double *val);
 
 /**
 @brief Sets the floating point number raw value of the floating point
@@ -718,8 +668,8 @@ extern enum bt_value_status bt_value_float_get(
 @sa bt_value_float_get(): Returns the raw value of a floating point
        number value object.
 */
-extern enum bt_value_status bt_value_float_set(
-               struct bt_value *float_obj, double val);
+extern enum bt_value_status bt_value_real_set(
+               struct bt_value *real_obj, double val);
 
 /** @} */
 
@@ -861,6 +811,9 @@ extern int64_t bt_value_array_size(const struct bt_value *array_obj);
 */
 extern bt_bool bt_value_array_is_empty(const struct bt_value *array_obj);
 
+extern struct bt_value *bt_value_array_borrow(const struct bt_value *array_obj,
+               uint64_t index);
+
 /**
 @brief Returns the value object contained in the array value object
        \p array_obj at the index \p index.
@@ -878,8 +831,12 @@ extern bt_bool bt_value_array_is_empty(const struct bt_value *array_obj);
        \ref bt_value_null</strong>, its reference count is incremented.
 @postrefcountsame{array_obj}
 */
-extern struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
-               uint64_t index);
+static inline
+struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
+               uint64_t index)
+{
+       return bt_get(bt_value_array_borrow(array_obj, index));
+}
 
 /**
 @brief Appends the value object \p element_obj to the array value
@@ -978,7 +935,7 @@ point number value object before appending it.
 @sa bt_value_array_append(): Appends a value object to a given
        array value object.
 */
-extern enum bt_value_status bt_value_array_append_float(
+extern enum bt_value_status bt_value_array_append_real(
                struct bt_value *array_obj, double val);
 
 /**
@@ -1127,6 +1084,9 @@ extern int64_t bt_value_map_size(const struct bt_value *map_obj);
 */
 extern bt_bool bt_value_map_is_empty(const struct bt_value *map_obj);
 
+extern struct bt_value *bt_value_map_borrow(const struct bt_value *map_obj,
+               const char *key);
+
 /**
 @brief Returns the value object associated with the key \p key within
        the map value object \p map_obj.
@@ -1143,8 +1103,12 @@ extern bt_bool bt_value_map_is_empty(const struct bt_value *map_obj);
 @post <strong>On success, if the returned value object is not
        \ref bt_value_null</strong>, its reference count is incremented.
 */
-extern struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
-               const char *key);
+static inline
+struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
+               const char *key)
+{
+       return bt_get(bt_value_map_borrow(map_obj, key));
+}
 
 /**
 @brief User function type to use with bt_value_map_foreach().
@@ -1186,8 +1150,8 @@ The user function \em must return #BT_TRUE to continue the traversal of
 @param[in] cb          User function to call back.
 @param[in] data                User data passed to the user function.
 @returns               Status code. More
-                       specifically, #BT_VALUE_STATUS_CANCELLED is
-                       returned if the loop was cancelled by the user
+                       specifically, #BT_VALUE_STATUS_CANCELED is
+                       returned if the loop was canceled by the user
                        function.
 
 @prenotnull{map_obj}
@@ -1342,7 +1306,7 @@ On success, \p key is copied.
 @sa bt_value_map_insert(): Inserts a value object into a given map
        value object.
 */
-extern enum bt_value_status bt_value_map_insert_float(
+extern enum bt_value_status bt_value_map_insert_real(
                struct bt_value *map_obj, const char *key, double val);
 
 /**
This page took 0.027138 seconds and 4 git commands to generate.