aboutsummaryrefslogtreecommitdiffstats
path: root/serd
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-06-13 15:18:27 -0400
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit06b775c1de2173720fe12abec2fbe225c353a12b (patch)
tree8d244b45091234136a47c038b33042a77f740134 /serd
parent897590f6408b9b2b1aae2a060465da6d0faf42be (diff)
downloadserd-06b775c1de2173720fe12abec2fbe225c353a12b.tar.gz
serd-06b775c1de2173720fe12abec2fbe225c353a12b.tar.bz2
serd-06b775c1de2173720fe12abec2fbe225c353a12b.zip
Shorten node constructor names
Diffstat (limited to 'serd')
-rw-r--r--serd/serd.h83
1 files changed, 60 insertions, 23 deletions
diff --git a/serd/serd.h b/serd/serd.h
index 382506f7..e576398b 100644
--- a/serd/serd.h
+++ b/serd/serd.h
@@ -347,7 +347,7 @@ serd_strtod(const char* str, size_t* end);
/**
Decode a base64 string.
This function can be used to deserialise a blob node created with
- serd_node_new_blob().
+ serd_new_blob().
@param str Base64 string to decode.
@param len The length of `str`.
@@ -525,61 +525,97 @@ serd_uri_serialise_relative(const SerdURI* uri,
*/
SERD_API
SerdNode*
-serd_node_new_simple_node(SerdType type, const char* str, size_t len);
+serd_new_simple_node(SerdType type, const char* str, size_t len);
/**
Create a new plain literal string node from `str`.
*/
SERD_API
SerdNode*
-serd_node_new_string(const char* str);
+serd_new_string(const char* str);
/**
Create a new plain literal string node from a prefix of `str`.
*/
SERD_API
SerdNode*
-serd_node_new_substring(const char* str, size_t len);
+serd_new_substring(const char* str, size_t len);
+
+/**
+ Create a new literal node from substrings.
+
+ This is a low-level constructor which can be used for constructing a literal
+ from slices of a buffer (for example, directly from a Turtle literal)
+ without copying. In most cases, applications should use the simpler
+ serd_new_plain_literal() or serd_new_typed_literal().
+
+ Either `datatype_uri` or `lang` can be given, but not both, unless
+ `datatype_uri` is rdf:langString in which case it is ignored.
+
+ @param str Literal body string.
+ @param str_len Length of `str` in bytes.
+ @param datatype_uri Full datatype URI, or NULL.
+ @param datatype_uri_len Length of `datatype_uri` in bytes.
+ @param lang Language string.
+ @param lang_len Length of `lang` in bytes.
+*/
+SERD_API
+SerdNode*
+serd_new_literal(const char* str,
+ size_t str_len,
+ const char* datatype_uri,
+ size_t datatype_uri_len,
+ const char* lang,
+ size_t lang_len);
/**
Create a new literal node from `str`.
- Either `datatype` or `lang` can be given, but not both, unless `datatype` is
- rdf:langString in which case it is ignored.
+ A plain literal has no datatype, but may have a language tag. The `lang`
+ may be NULL, in which case this is equivalent to `serd_new_string()`.
*/
SERD_API
SerdNode*
-serd_node_new_literal(const char* str,
- const SerdNode* datatype,
- const char* lang);
+serd_new_plain_literal(const char* str, const char* lang);
+
+/**
+ Create a new typed literal node from `str`.
+
+ A typed literal has no language tag, but may have a datatype. The
+ `datatype` may be NULL, in which case this is equivalent to
+ `serd_new_string()`.
+*/
+SERD_API
+SerdNode*
+serd_new_typed_literal(const char* str, const SerdNode* datatype);
/**
Create a new blank node.
*/
SERD_API
SerdNode*
-serd_node_new_blank(const char* str);
+serd_new_blank(const char* str);
/**
Create a new CURIE node.
*/
SERD_API
SerdNode*
-serd_node_new_curie(const char* str);
+serd_new_curie(const char* str);
/**
Create a new URI from a string.
*/
SERD_API
SerdNode*
-serd_node_new_uri(const char* str);
+serd_new_uri(const char* str);
/**
Create a new URI from a string, resolved against a base URI.
*/
SERD_API
SerdNode*
-serd_node_new_resolved_uri(const char* str, const SerdNode* base);
+serd_new_resolved_uri(const char* str, const SerdNode* base);
/**
Resolve `node` against `base`.
@@ -601,7 +637,7 @@ serd_node_resolve(const SerdNode* node, const SerdNode* base);
*/
SERD_API
SerdNode*
-serd_node_new_file_uri(const char* path, const char* hostname, bool escape);
+serd_new_file_uri(const char* path, const char* hostname, bool escape);
/**
Create a new URI from a string, relative to a base URI.
@@ -618,9 +654,9 @@ serd_node_new_file_uri(const char* path, const char* hostname, bool escape);
*/
SERD_API
SerdNode*
-serd_node_new_relative_uri(const char* str,
- const SerdNode* base,
- const SerdNode* root);
+serd_new_relative_uri(const char* str,
+ const SerdNode* base,
+ const SerdNode* root);
/**
Create a new node by serialising `d` into an xsd:decimal string.
@@ -643,7 +679,7 @@ serd_node_new_relative_uri(const char* str,
*/
SERD_API
SerdNode*
-serd_node_new_decimal(double d, unsigned frac_digits, const SerdNode* datatype);
+serd_new_decimal(double d, unsigned frac_digits, const SerdNode* datatype);
/**
Create a new node by serialising `i` into an xsd:integer string.
@@ -655,7 +691,7 @@ serd_node_new_decimal(double d, unsigned frac_digits, const SerdNode* datatype);
*/
SERD_API
SerdNode*
-serd_node_new_integer(int64_t i, const SerdNode* datatype);
+serd_new_integer(int64_t i, const SerdNode* datatype);
/**
Create a node by serialising `buf` into an xsd:base64Binary string.
@@ -672,10 +708,11 @@ serd_node_new_integer(int64_t i, const SerdNode* datatype);
type xsd:base64Binary.
*/
SERD_API
-SerdNode* serd_node_new_blob(const void* buf,
- size_t size,
- bool wrap_lines,
- const SerdNode* datatype);
+SerdNode*
+serd_new_blob(const void* buf,
+ size_t size,
+ bool wrap_lines,
+ const SerdNode* datatype);
/**
Return a deep copy of `node`.