Code

data: Add basic support for a boolean type.
[sysdb.git] / src / include / core / data.h
index c037fb00e2a1f8f91ea09d057b7a5064be2f91ca..558e1668272e327f4719ac041c9faa28af8a80e7 100644 (file)
@@ -43,6 +43,7 @@ extern "C" {
 
 enum {
        SDB_TYPE_NULL = 0,
+       SDB_TYPE_BOOLEAN,
        SDB_TYPE_INTEGER,
        SDB_TYPE_DECIMAL,
        SDB_TYPE_STRING,
@@ -55,12 +56,15 @@ enum {
 };
 
 #define SDB_TYPE_TO_STRING(t) \
-       (((t) == SDB_TYPE_INTEGER) ? "INTEGER" \
+       (((t) == SDB_TYPE_NULL) ? "NULL" \
+               : ((t) == SDB_TYPE_BOOLEAN) ? "BOOLEAN" \
+               : ((t) == SDB_TYPE_INTEGER) ? "INTEGER" \
                : ((t) == SDB_TYPE_DECIMAL) ? "DECIMAL" \
                : ((t) == SDB_TYPE_STRING) ? "STRING" \
                : ((t) == SDB_TYPE_DATETIME) ? "DATETIME" \
                : ((t) == SDB_TYPE_BINARY) ? "BINARY" \
                : ((t) == SDB_TYPE_REGEX) ? "REGEX" \
+               : ((t) == (SDB_TYPE_ARRAY | SDB_TYPE_BOOLEAN)) ? "[]BOOLEAN" \
                : ((t) == (SDB_TYPE_ARRAY | SDB_TYPE_INTEGER)) ? "[]INTEGER" \
                : ((t) == (SDB_TYPE_ARRAY | SDB_TYPE_DECIMAL)) ? "[]DECIMAL" \
                : ((t) == (SDB_TYPE_ARRAY | SDB_TYPE_STRING)) ? "[]STRING" \
@@ -73,6 +77,7 @@ union sdb_datum;
 typedef union sdb_datum sdb_datum_t;
 
 union sdb_datum {
+       bool        boolean;  /* SDB_TYPE_BOOLEAN */
        int64_t     integer;  /* SDB_TYPE_INTEGER */
        double      decimal;  /* SDB_TYPE_DECIMAL */
        char       *string;   /* SDB_TYPE_STRING  */
@@ -289,9 +294,8 @@ enum {
  *  - the number of characters written to the buffer (excluding the terminated
  *    null byte) or the number of characters which would have been written in
  *    case the output was truncated
- *  - a negative value else
  */
-int
+size_t
 sdb_data_format(const sdb_data_t *datum, char *buf, size_t buflen, int quoted);
 
 /*