Code

Move the timeseries serialize to the timeseries module.
[sysdb.git] / src / include / core / timeseries.h
index acfdaeff52094f9b37ff7d587ece03793d59a315..b19625d1ca21166e5eb75bcb65571f06c8286051 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "sysdb.h"
 #include "core/time.h"
+#include "utils/strbuf.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -70,6 +71,19 @@ typedef struct {
        sdb_time_t end;
 } sdb_timeseries_opts_t;
 
+/*
+ * sdb_timeseries_create:
+ * Allocate a time-series object, pre-populating the data_names information
+ * and allocating the data field.
+ *
+ * Returns:
+ *  - a newly allocated time-series object on success
+ *  - NULL else
+ */
+sdb_timeseries_t *
+sdb_timeseries_create(size_t data_names_len, const char * const *data_names,
+               size_t data_len);
+
 /*
  * sdb_timeseries_destroy:
  * Destroy a time-series object, freeing all of its memory.
@@ -77,6 +91,17 @@ typedef struct {
 void
 sdb_timeseries_destroy(sdb_timeseries_t *ts);
 
+/*
+ * sdb_timeseries_tojson:
+ * Serialize a time-series to JSON written to the specified string buffer.
+ *
+ * Returns:
+ *  - 0 on success
+ *  - a negative value else
+ */
+int
+sdb_timeseries_tojson(sdb_timeseries_t *ts, sdb_strbuf_t *buf);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif