Code

store: Added sdb_store_expr_attrvalue().
[sysdb.git] / src / include / core / store.h
index 90416a2cc0699cc3df67d50ac516a1d415a9f058..b9a8d0896eae6a3cad344464696f0479994a13a4 100644 (file)
@@ -241,7 +241,8 @@ sdb_store_fetch_timeseries(const char *hostname, const char *metric,
  * sdb_store_get_field:
  * Get the value of a stored object's queryable field. The caller is
  * responsible for freeing any dynamically allocated memory possibly stored in
- * the returned value.
+ * the returned value. If 'res' is NULL, the function will return whether the
+ * field exists.
  *
  * Note: Retrieving the backend this way is not currently supported.
  *
@@ -252,6 +253,20 @@ sdb_store_fetch_timeseries(const char *hostname, const char *metric,
 int
 sdb_store_get_field(sdb_store_obj_t *obj, int field, sdb_data_t *res);
 
+/*
+ * sdb_store_get_attr:
+ * Get the value of a stored object's attribute. The caller is responsible for
+ * freeing any dynamically allocated memory possibly stored in the returned
+ * value.If 'res' is NULL, the function will return whether the attribute
+ * exists.
+ *
+ * Returns:
+ *  - 0 if the attribute exists
+ *  - a negative value else
+ */
+int
+sdb_store_get_attr(sdb_store_obj_t *obj, const char *name, sdb_data_t *res);
+
 /*
  * Expressions specify arithmetic expressions.
  *
@@ -286,6 +301,18 @@ sdb_store_expr_create(int op, sdb_store_expr_t *left, sdb_store_expr_t *right);
 sdb_store_expr_t *
 sdb_store_expr_fieldvalue(int field);
 
+/*
+ * sdb_store_expr_attrvalue:
+ * Creates an expression which evaluates to the value of the specified
+ * attribute of a stored object.
+ *
+ * Returns:
+ *  - an expression object on success
+ *  - NULL else
+ */
+sdb_store_expr_t *
+sdb_store_expr_attrvalue(const char *name);
+
 /*
  * sdb_store_expr_constvalue:
  * Creates an expression which evaluates to the specified constant value.