aboutsummaryrefslogtreecommitdiffstats
path: root/include/serd
diff options
context:
space:
mode:
Diffstat (limited to 'include/serd')
-rw-r--r--include/serd/serd.h54
1 files changed, 48 insertions, 6 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 52245077..e450f853 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -1014,6 +1014,17 @@ SerdWriteResult
serd_node_construct_integer(size_t buf_size,
void* SERD_NULLABLE buf,
int64_t value);
+/**
+ Construct a canonical xsd:hexBinary literal.
+
+ The constructed node will be an xsd:hexBinary literal like "534D", with
+ datatype xsd:hexBinary.
+*/
+SerdWriteResult
+serd_node_construct_hex(size_t buf_size,
+ void* SERD_NULLABLE buf,
+ size_t value_size,
+ const void* SERD_NONNULL value);
/**
Construct a canonical xsd:base64Binary literal.
@@ -1183,6 +1194,21 @@ SerdNode* SERD_ALLOCATED
serd_new_integer(SerdAllocator* SERD_NULLABLE allocator, int64_t i);
/**
+ Create a new canonical xsd:hexBinary literal.
+
+ This is a wrapper for serd_node_construct_hex() that allocates a new
+ node on the heap.
+
+ @return A newly allocated node that must be freed with serd_node_free(), or
+ null.
+*/
+SERD_API
+SerdNode* SERD_ALLOCATED
+serd_new_hex(SerdAllocator* SERD_NULLABLE allocator,
+ const void* SERD_NONNULL buf,
+ size_t size);
+
+/**
Create a new canonical xsd:base64Binary literal.
This is a wrapper for serd_node_construct_base64() that allocates a new
@@ -1237,16 +1263,20 @@ serd_get_value_as(const SerdNode* SERD_NONNULL node,
bool lossy);
/**
- Return the maximum size of a decoded base64 node in bytes.
+ Return the maximum size of a decoded hex or base64 binary node in bytes.
This returns an upper bound on the number of bytes that would be decoded by
- serd_get_base64(). This is calculated as a simple constant-time arithmetic
+ serd_get_blob(). This is calculated as a simple constant-time arithmetic
expression based on the length of the encoded string, so may be larger than
the actual size of the data due to things like additional whitespace.
+
+ @return The size of the decoded hex or base64 blob `node`, or zero if it
+ does not have datatype <http://www.w3.org/2001/XMLSchema#hexBinary> or
+ <http://www.w3.org/2001/XMLSchema#base64Binary>.
*/
SERD_PURE_API
size_t
-serd_get_base64_size(const SerdNode* SERD_NONNULL node);
+serd_get_blob_size(const SerdNode* SERD_NONNULL node);
/**
Decode a base64 node.
@@ -1265,9 +1295,9 @@ serd_get_base64_size(const SerdNode* SERD_NONNULL node);
*/
SERD_API
SerdWriteResult
-serd_get_base64(const SerdNode* SERD_NONNULL node,
- size_t buf_size,
- void* SERD_NONNULL buf);
+serd_get_blob(const SerdNode* SERD_NONNULL node,
+ size_t buf_size,
+ void* SERD_NONNULL buf);
/// Return a deep copy of `node`
SERD_API
@@ -1528,6 +1558,18 @@ const SerdNode* SERD_ALLOCATED
serd_nodes_integer(SerdNodes* SERD_NONNULL nodes, int64_t value);
/**
+ Make a canonical xsd:hexBinary node.
+
+ A new node will be constructed with serd_node_construct_hex() if an
+ equivalent one is not already in the set.
+*/
+SERD_API
+const SerdNode* SERD_ALLOCATED
+serd_nodes_hex(SerdNodes* SERD_NONNULL nodes,
+ const void* SERD_NONNULL value,
+ size_t value_size);
+
+/**
Make a canonical xsd:base64Binary node.
A new node will be constructed with serd_node_construct_base64() if an