Ejemplo n.º 1
0
Archivo: node.c Proyecto: falkTX/Carla
LILV_API const char*
lilv_node_as_blank(const LilvNode* value)
{
	return (lilv_node_is_blank(value)
	        ? (const char*)sord_node_get_string(value->node)
	        : NULL);
}
Ejemplo n.º 2
0
LILV_API
LilvState*
lilv_state_new_from_world(LilvWorld*          world,
                          const LV2_URID_Map* map,
                          const LilvNode*     node)
{
	if (!lilv_node_is_uri(node) && !lilv_node_is_blank(node)) {
		LILV_ERRORF("Subject `%s' is not a URI or blank node.\n",
		            lilv_node_as_string(node));
		return NULL;
	}

	LilvState* state = new_state_from_model(
		world, map, world->model, node->node, NULL);

	return state;
}
Ejemplo n.º 3
0
LILV_API
LilvState*
lilv_state_new_from_file(LilvWorld*          world,
                         const LV2_URID_Map* map,
                         const LilvNode*     subject,
                         const char*         path)
{
	if (subject && !lilv_node_is_uri(subject)
	    && !lilv_node_is_blank(subject)) {
		LILV_ERRORF("Subject `%s' is not a URI or blank node.\n",
		            lilv_node_as_string(subject));
		return NULL;
	}

	uint8_t*    abs_path = (uint8_t*)lilv_path_absolute(path);
	SerdNode    node     = serd_node_new_file_uri(abs_path, NULL, NULL, 0);
	SerdEnv*    env      = serd_env_new(&node);
	SordModel*  model    = sord_new(world->world, SORD_SPO, false);
	SerdReader* reader   = sord_new_reader(model, env, SERD_TURTLE, NULL);

	serd_reader_read_file(reader, node.buf);

	SordNode* subject_node = (subject)
		? subject->node
		: sord_node_from_serd_node(world->world, env, &node, NULL, NULL);

	char* dirname   = lilv_dirname(path);
	char* real_path = lilv_realpath(dirname);
	LilvState* state = new_state_from_model(
		world, map, model, subject_node, real_path);
	free(dirname);
	free(real_path);

	serd_node_free(&node);
	free(abs_path);
	serd_reader_free(reader);
	sord_free(model);
	serd_env_free(env);
	return state;
}