diff options
author | David Robillard <d@drobilla.net> | 2021-01-13 16:13:46 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 16:27:02 -0500 |
commit | 413b4d1f58bdf1d6aed785ae9b076c7b7b9a7350 (patch) | |
tree | 454cf92d9668431cbdcff8889e7597fcf162bf41 /include/serd | |
parent | cd89a74a2f7bf8c3efc3ecf1597cf39d6295db00 (diff) | |
download | serd-413b4d1f58bdf1d6aed785ae9b076c7b7b9a7350.tar.gz serd-413b4d1f58bdf1d6aed785ae9b076c7b7b9a7350.tar.bz2 serd-413b4d1f58bdf1d6aed785ae9b076c7b7b9a7350.zip |
Simplify literal construction API
Diffstat (limited to 'include/serd')
-rw-r--r-- | include/serd/node.h | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/include/serd/node.h b/include/serd/node.h index 2f4384bd..5a3990b0 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -115,15 +115,23 @@ SERD_API SerdNode* SERD_ALLOCATED serd_new_string(SerdStringView string); /** - Create a new literal node from `str`. + Create a new plain literal node from `str` with `lang`. - Either `datatype_uri` or `lang` can be given, but not both, unless - `datatype_uri` 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 empty, in which case this is equivalent to `serd_new_string()`. */ SERD_API SerdNode* SERD_ALLOCATED -serd_new_literal(SerdStringView string, - SerdStringView datatype_uri, - SerdStringView lang); +serd_new_plain_literal(SerdStringView str, SerdStringView 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_ALLOCATED +serd_new_typed_literal(SerdStringView str, SerdStringView datatype_uri); /** Create a new node from a blank node label. @@ -159,7 +167,7 @@ SERD_API SerdNode* SERD_ALLOCATED serd_new_file_uri(SerdStringView path, SerdStringView hostname); /** - Create a new node by serialising `d` into an xsd:decimal string. + Create a new canonical xsd:decimal literal. The resulting node will always contain a '.', start with a digit, and end with a digit (i.e. will have a leading and/or trailing '0' if necessary). @@ -180,7 +188,7 @@ serd_new_decimal(double d, const SerdNode* SERD_NULLABLE datatype); /** - Create a new node by serialising `i` into an xsd:integer string. + Create a new canonical xsd:integer literal. @param i Integer value to serialise. @param datatype Datatype of node, or NULL for xsd:integer. @@ -189,7 +197,7 @@ SERD_API SerdNode* SERD_ALLOCATED serd_new_integer(int64_t i, const SerdNode* SERD_NULLABLE datatype); /** - Create a node by serialising `buf` into an xsd:base64Binary string. + Create a new canonical xsd:base64Binary literal. This function can be used to make a serialisable node out of arbitrary binary data, which can be decoded using serd_base64_decode(). |