summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--README2
-rw-r--r--sord/sordmm.hpp34
-rw-r--r--wscript2
4 files changed, 37 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index b45110d..66c710c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,8 +1,9 @@
sord (0.10.5) unstable;
* Update to waf 1.7.8 and autowaf r90 (install docs to versioned directory)
+ * Add convenient numeric constructors for decimal and integer literals
- -- David Robillard <d@drobilla.net> Sat, 22 Dec 2012 20:15:47 -0500
+ -- David Robillard <d@drobilla.net> Mon, 14 Jan 2013 00:19:49 -0500
sord (0.10.4) stable;
diff --git a/README b/README
index 93a678a..85ad305 100644
--- a/README
+++ b/README
@@ -1,5 +1,5 @@
Sord
-----
+====
Sord is a lightweight C library for storing RDF statements in memory.
diff --git a/sord/sordmm.hpp b/sord/sordmm.hpp
index 4f3b609..d839d1b 100644
--- a/sord/sordmm.hpp
+++ b/sord/sordmm.hpp
@@ -151,6 +151,7 @@ public:
inline Node(World& world, Type t, const std::string& s);
inline Node(World& world);
inline Node(World& world, const SordNode* node);
+ inline Node(World& world, SordNode* node, bool copy=false);
inline Node(const Node& other);
inline ~Node();
@@ -240,6 +241,30 @@ class Literal : public Node {
public:
inline Literal(World& world, const std::string& s)
: Node(world, Node::LITERAL, s) {}
+
+ static inline Node decimal(World& world, double d, unsigned frac_digits) {
+ const SerdNode val = serd_node_new_decimal(d, 7);
+ const SerdNode type = serd_node_from_string(
+ SERD_URI, (const uint8_t*)SORD_NS_XSD "decimal");
+
+ return Node(
+ world,
+ sord_node_from_serd_node(
+ world.c_obj(), world.prefixes().c_obj(), &val, &type, NULL),
+ false);
+ }
+
+ static inline Node integer(World& world, int64_t i) {
+ const SerdNode val = serd_node_new_integer(i);
+ const SerdNode type = serd_node_from_string(
+ SERD_URI, (const uint8_t*)SORD_NS_XSD "integer");
+
+ return Node(
+ world,
+ sord_node_from_serd_node(
+ world.c_obj(), world.prefixes().c_obj(), &val, &type, NULL),
+ false);
+ }
};
inline
@@ -278,7 +303,14 @@ inline
Node::Node(World& world, const SordNode* node)
: _world(&world)
{
- _c_obj = node ? sord_node_copy(node) : NULL;
+ _c_obj = sord_node_copy(node);
+}
+
+inline
+Node::Node(World& world, SordNode* node, bool copy)
+ : _world(&world)
+{
+ _c_obj = copy ? sord_node_copy(node) : node;
}
inline
diff --git a/wscript b/wscript
index e263bbd..b98807d 100644
--- a/wscript
+++ b/wscript
@@ -10,7 +10,7 @@ import waflib.extras.autowaf as autowaf
# major increment <=> incompatible changes
# minor increment <=> compatible changes (additions)
# micro increment <=> no interface changes
-SORD_VERSION = '0.10.4'
+SORD_VERSION = '0.10.5'
SORD_MAJOR_VERSION = '0'
# Mandatory waf variables