Nodes — Lilv 0.24.18 documentation

# Nodes

const char *lilv_uri_to_path(const char *uri)

  Convert a file URI string to a local path string.

  For example, “file://foo/bar/baz.ttl” returns “/foo/bar/baz.ttl”. Return value is shared and must not be deleted by caller. This function does not handle escaping correctly and should not be used for general file URIs. Use `lilv_file_uri_parse()` instead.

  Returns:

    `uri` converted to a path, or NULL on failure (URI is not local).

char *lilv_file_uri_parse(const char *uri, char **hostname)

  Convert a file URI string to a local path string.

  For example, “file://foo/bar%20one/baz.ttl” returns “/foo/bar one/baz.ttl”. Return value must be freed by caller with `lilv_free()`.

  Parameters:

    - uri – The file URI to parse.

    - hostname – If non-NULL, set to the hostname in the URI, if any.

  Returns:

    `uri` converted to a path, or NULL on failure (URI is not local).

LilvNode *lilv_new_uri(LilvWorld *world, const char *uri)

  Create a new URI value.

  Returned value must be freed by caller with `lilv_node_free()`.

LilvNode *lilv_new_file_uri(LilvWorld *world, const char *host, const char *path)

  Create a new file URI value.

  Relative paths are resolved against the current working directory. Note that this may yield unexpected results if `host` is another machine.

  Parameters:

    - world – The world.

    - host – Host name, or NULL.

    - path – Path on host.

  Returns:

    A new node that must be freed by caller.

LilvNode *lilv_new_string(LilvWorld *world, const char *str)

  Create a new string value (with no language).

  Returned value must be freed by caller with `lilv_node_free()`.

LilvNode *lilv_new_int(LilvWorld *world, int val)

  Create a new integer value.

  Returned value must be freed by caller with `lilv_node_free()`.

LilvNode *lilv_new_float(LilvWorld *world, float val)

  Create a new floating point value.

  Returned value must be freed by caller with `lilv_node_free()`.

LilvNode *lilv_new_bool(LilvWorld *world, bool val)

  Create a new boolean value.

  Returned value must be freed by caller with `lilv_node_free()`.

void lilv_node_free(LilvNode *val)

  Free a LilvNode.

  It is safe to call this function on NULL.

LilvNode *lilv_node_duplicate(const LilvNode *val)

  Duplicate a LilvNode.

bool lilv_node_equals(const LilvNode *value, const LilvNode *other)

  Return whether two values are equivalent.

char *lilv_node_get_turtle_token(const LilvNode *value)

  Return this value as a Turtle/SPARQL token.

  Returned value must be freed by caller with `lilv_free()`.

  Example tokens:

  - URI: <http://example.org/foo&gt;

  - QName: doap:name

  - String: “this is a string”

  - Float: 1.0

  - Integer: 1

  - Boolean: true

bool lilv_node_is_uri(const LilvNode *value)

  Return whether the value is a URI (resource).

const char *lilv_node_as_uri(const LilvNode *value)

  Return this value as a URI string, like “http://example.org/foo”.

  Valid to call only if `lilv_node_is_uri(value)` returns true. Returned value is owned by `value` and must not be freed by caller.

bool lilv_node_is_blank(const LilvNode *value)

  Return whether the value is a blank node (resource with no URI).

const char *lilv_node_as_blank(const LilvNode *value)

  Return this value as a blank node identifier, like “genid03”.

  Valid to call only if `lilv_node_is_blank(value)` returns true. Returned value is owned by `value` and must not be freed by caller.

bool lilv_node_is_literal(const LilvNode *value)

  Return whether this value is a literal (that is, not a URI).

  Returns true if `value` is a string or numeric value.

bool lilv_node_is_string(const LilvNode *value)

  Return whether this value is a string literal.

  Returns true if `value` is a string value (and not numeric).

const char *lilv_node_as_string(const LilvNode *value)

  Return `value` as a string.

char *lilv_node_get_path(const LilvNode *value, char **hostname)

  Return the path of a file URI node.

  Returns NULL if `value` is not a file URI. Returned value must be freed by caller with `lilv_free()`.

bool lilv_node_is_float(const LilvNode *value)

  Return whether this value is a decimal literal.

float lilv_node_as_float(const LilvNode *value)

  Return `value` as a float.

  Valid to call only if `lilv_node_is_float(value)` or `lilv_node_is_int(value)` returns true.

bool lilv_node_is_int(const LilvNode *value)

  Return whether this value is an integer literal.

int lilv_node_as_int(const LilvNode *value)

  Return `value` as an integer.

  Valid to call only if `lilv_node_is_int(value)` returns true.

bool lilv_node_is_bool(const LilvNode *value)

  Return whether this value is a boolean.

bool lilv_node_as_bool(const LilvNode *value)

  Return `value` as a bool.

  Valid to call only if `lilv_node_is_bool(value)` returns true.