summaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/node.c')
-rw-r--r--src/node.c96
1 files changed, 32 insertions, 64 deletions
diff --git a/src/node.c b/src/node.c
index 3d074a4..c771e40 100644
--- a/src/node.c
+++ b/src/node.c
@@ -1,5 +1,5 @@
/*
- Copyright 2007-2011 David Robillard <http://drobilla.net>
+ Copyright 2007-2014 David Robillard <http://drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -147,15 +147,13 @@ lilv_node_new_from_node(LilvWorld* world, const SordNode* node)
return result;
}
-LILV_API
-LilvNode*
+LILV_API LilvNode*
lilv_new_uri(LilvWorld* world, const char* uri)
{
return lilv_node_new(world, LILV_VALUE_URI, uri);
}
-LILV_API
-LilvNode*
+LILV_API LilvNode*
lilv_new_file_uri(LilvWorld* world, const char* host, const char* path)
{
char* abs_path = lilv_path_absolute(path);
@@ -168,15 +166,13 @@ lilv_new_file_uri(LilvWorld* world, const char* host, const char* path)
return ret;
}
-LILV_API
-LilvNode*
+LILV_API LilvNode*
lilv_new_string(LilvWorld* world, const char* str)
{
return lilv_node_new(world, LILV_VALUE_STRING, str);
}
-LILV_API
-LilvNode*
+LILV_API LilvNode*
lilv_new_int(LilvWorld* world, int val)
{
char str[32];
@@ -186,8 +182,7 @@ lilv_new_int(LilvWorld* world, int val)
return ret;
}
-LILV_API
-LilvNode*
+LILV_API LilvNode*
lilv_new_float(LilvWorld* world, float val)
{
char str[32];
@@ -197,8 +192,7 @@ lilv_new_float(LilvWorld* world, float val)
return ret;
}
-LILV_API
-LilvNode*
+LILV_API LilvNode*
lilv_new_bool(LilvWorld* world, bool val)
{
LilvNode* ret = lilv_node_new(world, LILV_VALUE_BOOL,
@@ -207,8 +201,7 @@ lilv_new_bool(LilvWorld* world, bool val)
return ret;
}
-LILV_API
-LilvNode*
+LILV_API LilvNode*
lilv_node_duplicate(const LilvNode* val)
{
if (!val) {
@@ -223,8 +216,7 @@ lilv_node_duplicate(const LilvNode* val)
return result;
}
-LILV_API
-void
+LILV_API void
lilv_node_free(LilvNode* val)
{
if (val) {
@@ -233,8 +225,7 @@ lilv_node_free(LilvNode* val)
}
}
-LILV_API
-bool
+LILV_API bool
lilv_node_equals(const LilvNode* value, const LilvNode* other)
{
if (value == NULL && other == NULL)
@@ -261,8 +252,7 @@ lilv_node_equals(const LilvNode* value, const LilvNode* other)
return false; /* shouldn't get here */
}
-LILV_API
-char*
+LILV_API char*
lilv_node_get_turtle_token(const LilvNode* value)
{
const char* str = (const char*)sord_node_get_string(value->node);
@@ -299,45 +289,35 @@ lilv_node_get_turtle_token(const LilvNode* value)
return result;
}
-LILV_API
-bool
+LILV_API bool
lilv_node_is_uri(const LilvNode* value)
{
return (value && value->type == LILV_VALUE_URI);
}
-LILV_API
-const char*
+LILV_API const char*
lilv_node_as_uri(const LilvNode* value)
{
- assert(!value || lilv_node_is_uri(value));
- return value ? (const char*)sord_node_get_string(value->node) : NULL;
-}
-
-const SordNode*
-lilv_node_as_node(const LilvNode* value)
-{
- assert(lilv_node_is_uri(value));
- return value->node;
+ return (lilv_node_is_uri(value)
+ ? (const char*)sord_node_get_string(value->node)
+ : NULL);
}
-LILV_API
-bool
+LILV_API bool
lilv_node_is_blank(const LilvNode* value)
{
return (value && value->type == LILV_VALUE_BLANK);
}
-LILV_API
-const char*
+LILV_API const char*
lilv_node_as_blank(const LilvNode* value)
{
- assert(!value || lilv_node_is_blank(value));
- return value ? (const char*)sord_node_get_string(value->node) : NULL;
+ return (lilv_node_is_blank(value)
+ ? (const char*)sord_node_get_string(value->node)
+ : NULL);
}
-LILV_API
-bool
+LILV_API bool
lilv_node_is_literal(const LilvNode* value)
{
if (!value)
@@ -353,45 +333,37 @@ lilv_node_is_literal(const LilvNode* value)
}
}
-LILV_API
-bool
+LILV_API bool
lilv_node_is_string(const LilvNode* value)
{
return (value && value->type == LILV_VALUE_STRING);
}
-LILV_API
-const char*
+LILV_API const char*
lilv_node_as_string(const LilvNode* value)
{
return value ? (const char*)sord_node_get_string(value->node) : NULL;
}
-LILV_API
-bool
+LILV_API bool
lilv_node_is_int(const LilvNode* value)
{
return (value && value->type == LILV_VALUE_INT);
}
-LILV_API
-int
+LILV_API int
lilv_node_as_int(const LilvNode* value)
{
- assert(value);
- assert(lilv_node_is_int(value));
- return value->val.int_val;
+ return lilv_node_is_int(value) ? value->val.int_val : 0;
}
-LILV_API
-bool
+LILV_API bool
lilv_node_is_float(const LilvNode* value)
{
return (value && value->type == LILV_VALUE_FLOAT);
}
-LILV_API
-float
+LILV_API float
lilv_node_as_float(const LilvNode* value)
{
assert(lilv_node_is_float(value) || lilv_node_is_int(value));
@@ -402,18 +374,14 @@ lilv_node_as_float(const LilvNode* value)
}
}
-LILV_API
-bool
+LILV_API bool
lilv_node_is_bool(const LilvNode* value)
{
return (value && value->type == LILV_VALUE_BOOL);
}
-LILV_API
-bool
+LILV_API bool
lilv_node_as_bool(const LilvNode* value)
{
- assert(value);
- assert(lilv_node_is_bool(value));
- return value->val.bool_val;
+ return lilv_node_is_bool(value) ? value->val.bool_val : false;
}