Node

const SerdNode SERD_NODE_NULL
SerdNode serd_node_from_string(SerdType type, const uint8_t *str)

Make a (shallow) node from str.

This measures, but does not copy, str. No memory is allocated.

SerdNode serd_node_from_substring(SerdType type, const uint8_t *str, size_t len)

Make a (shallow) node from a prefix of str.

This measures, but does not copy, str. No memory is allocated. Note that the returned node may not be null terminated.

SerdNode serd_node_new_uri_from_node(const SerdNode *uri_node, const SerdURI *base, SerdURI *out)

Simple wrapper for serd_node_new_uri() to resolve a URI node.

SerdNode serd_node_new_uri_from_string(const uint8_t *str, const SerdURI *base, SerdURI *out)

Simple wrapper for serd_node_new_uri() to resolve a URI string.

SerdNode serd_node_new_file_uri(const uint8_t *path, const uint8_t *hostname, SerdURI *out, bool escape)

Create a new file URI node from a file system path and optional hostname.

Backslashes in Windows paths will be converted and ‘’ will always be percent encoded. If escape is true, all other invalid characters will be percent encoded as well.

If path is relative, hostname is ignored. If out is not NULL, it will be set to the parsed URI.

SerdNode serd_node_new_uri(const SerdURI *uri, const SerdURI *base, SerdURI *out)

Create a new node by serialising uri into a new string.

Parameters
  • uri – The URI to serialise.

  • base – Base URI to resolve uri against (or NULL for no resolution).

  • out – Set to the parsing of the new URI (i.e. points only to memory owned by the new returned node).

SerdNode serd_node_new_relative_uri(const SerdURI *uri, const SerdURI *base, const SerdURI *root, SerdURI *out)

Create a new node by serialising uri into a new relative URI.

Parameters
  • uri – The URI to serialise.

  • base – Base URI to make uri relative to, if possible.

  • root – Root URI for resolution (see serd_uri_serialise_relative()).

  • out – Set to the parsing of the new URI (i.e. points only to memory owned by the new returned node).

SerdNode serd_node_new_decimal(double d, unsigned frac_digits)

Create a new node by serialising d into an xsd:decimal string.

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). It will never be in scientific notation. A maximum of frac_digits digits will be written after the decimal point, but trailing zeros will automatically be omitted (except one if d is a round integer).

Note that about 16 and 8 fractional digits are required to precisely represent a double and float, respectively.

Parameters
  • d – The value for the new node.

  • frac_digits – The maximum number of digits after the decimal place.

SerdNode serd_node_new_integer(int64_t i)

Create a new node by serialising i into an xsd:integer string.

SerdNode serd_node_new_blob(const void *buf, size_t size, bool wrap_lines)

Create a node by serialising buf into an xsd:base64Binary string.

This function can be used to make a serialisable node out of arbitrary binary data, which can be decoded using serd_base64_decode().

Parameters
  • buf – Raw binary input data.

  • size – Size of buf.

  • wrap_lines – Wrap lines at 76 characters to conform to RFC 2045.

SerdNode serd_node_copy(const SerdNode *node)

Make a deep copy of node.

Returns

a node that the caller must free with serd_node_free().

bool serd_node_equals(const SerdNode *a, const SerdNode *b)

Return true iff a is equal to b

void serd_node_free(SerdNode *node)

Free any data owned by node.

Note that if node is itself dynamically allocated (which is not the case for nodes created internally by serd), it will not be freed.