aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/node.c26
-rw-r--r--src/static_nodes.h2
-rw-r--r--src/string.c2
3 files changed, 30 insertions, 0 deletions
diff --git a/src/node.c b/src/node.c
index 0d6eb19a..db183fc0 100644
--- a/src/node.c
+++ b/src/node.c
@@ -507,6 +507,32 @@ serd_new_custom_literal(const void* const user_data,
return node;
}
+SerdNode*
+serd_new_double(const double d)
+{
+ char buf[EXESS_MAX_DOUBLE_LENGTH + 1] = {0};
+
+ const ExessResult r = exess_write_double(d, sizeof(buf), buf);
+
+ return r.status
+ ? NULL
+ : serd_new_typed_literal(SERD_STRING_VIEW(buf, r.count),
+ SERD_STATIC_STRING(EXESS_XSD_URI "double"));
+}
+
+SerdNode*
+serd_new_float(const float f)
+{
+ char buf[EXESS_MAX_FLOAT_LENGTH + 1] = {0};
+
+ const ExessResult r = exess_write_float(f, sizeof(buf), buf);
+
+ return r.status
+ ? NULL
+ : serd_new_typed_literal(SERD_STRING_VIEW(buf, r.count),
+ SERD_STATIC_STRING(EXESS_XSD_URI "float"));
+}
+
static size_t
write_variant_literal(const void* const user_data,
const size_t buf_size,
diff --git a/src/static_nodes.h b/src/static_nodes.h
index 952c0634..adbb5849 100644
--- a/src/static_nodes.h
+++ b/src/static_nodes.h
@@ -34,6 +34,8 @@ typedef struct StaticNode {
DEFINE_XSD_NODE(base64Binary)
DEFINE_XSD_NODE(boolean)
DEFINE_XSD_NODE(decimal)
+DEFINE_XSD_NODE(double)
+DEFINE_XSD_NODE(float)
DEFINE_XSD_NODE(integer)
#endif // SERD_STATIC_NODES_H
diff --git a/src/string.c b/src/string.c
index 00b1e91a..6e28778b 100644
--- a/src/string.c
+++ b/src/string.c
@@ -21,6 +21,8 @@
#include <assert.h>
#include <math.h>
+#include <stdbool.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>