diff options
author | David Robillard <d@drobilla.net> | 2009-05-13 04:05:32 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-13 04:05:32 +0000 |
commit | 19928bb583e72802746b89e322f71ecc0fcb7427 (patch) | |
tree | 95912dc84d8c9dcf57939398514feaf148c1cd63 /src/serialisation | |
parent | 96f839e64de70a23210847e322d24690299287fe (diff) | |
download | ingen-19928bb583e72802746b89e322f71ecc0fcb7427.tar.gz ingen-19928bb583e72802746b89e322f71ecc0fcb7427.tar.bz2 ingen-19928bb583e72802746b89e322f71ecc0fcb7427.zip |
The great ID refactoring of 2009.
Path is now actually URI (scheme path: for now).
Therefore ingen nodes and such live in the same namespace as ... well, everything.
Including plugins.
Thar be profit, laddies.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1992 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r-- | src/serialisation/Parser.cpp | 12 | ||||
-rw-r--r-- | src/serialisation/Serialiser.cpp | 20 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index f64e96ab..c68d6ccf 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -180,7 +180,7 @@ Parser::parse_string( { Redland::Model model(*world->rdf_world, str.c_str(), str.length(), base_uri); - cout << "Parsing " << (data_path ? (string)*data_path : "*") << " from string"; + cout << "Parsing " << (data_path ? data_path->str() : "*") << " from string"; if (base_uri != "") cout << "(base " << base_uri << ")"; cout << endl; @@ -274,7 +274,7 @@ Parser::parse( const Redland::Node::Type res = Redland::Node::RESOURCE; const Glib::ustring query_str = data_path - ? Glib::ustring("SELECT DISTINCT ?t WHERE { <") + data_path->substr(1) + "> a ?t . }" + ? Glib::ustring("SELECT DISTINCT ?t WHERE { <") + data_path->chop_start("/") + "> a ?t . }" : Glib::ustring("SELECT DISTINCT ?s ?t WHERE { ?s a ?t . }"); Redland::Query query(*world->rdf_world, query_str); @@ -288,8 +288,8 @@ Parser::parse( const Redland::Node out_port_class (*world->rdf_world, res, NS_LV2 "OutputPort"); const Redland::Node lv2_class (*world->rdf_world, res, NS_LV2 "Plugin"); - const Redland::Node subject_node = (data_path && *data_path != "/") - ? Redland::Node(*world->rdf_world, res, data_path->substr(1)) + const Redland::Node subject_node = (data_path && !data_path->is_root()) + ? Redland::Node(*world->rdf_world, res, data_path->chop_start("/")) : model.base_uri(); std::string path_str; @@ -325,7 +325,7 @@ Parser::parse( string path = (parent && symbol) ? parent->base() + *symbol - : (parent ? parent->base() : "/") + path_str.substr(1); + : (parent ? parent->base() : "/") + path_str.substr(path_str.find("/")+1); if (!Path::is_valid(path)) { cerr << "WARNING: Invalid path '" << path << "' transformed to /" << endl; @@ -345,7 +345,7 @@ Parser::parse( return boost::optional<Path>(); } - if (data_path && subject.to_string() == *data_path) + if (data_path && subject.to_string() == data_path->str()) root_path = ret; } else if (is_plugin) { diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index a1f4f902..cb598eb7 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -145,7 +145,7 @@ Serialiser::to_string(SharedPtr<GraphObject> object, Redland::Resource base_rdf_node(_model->world(), base_uri); for (GraphObject::Properties::const_iterator v = extra_rdf.begin(); v != extra_rdf.end(); ++v) { if (v->first.find(":") != string::npos) { - _model->add_statement(base_rdf_node, v->first, + _model->add_statement(base_rdf_node, v->first.str(), AtomRDF::atom_to_node(_model->world(), v->second)); } else { cerr << "Warning: not serialising extra RDF with key '" << v->first << "'" << endl; @@ -227,7 +227,7 @@ Redland::Node Serialiser::instance_rdf_node(const Path& path) { assert(_model); - assert(path.substr(0, _root_path.length()) == _root_path); + assert(path.is_child_of(_root_path)); if (path == _root_path) return Redland::Resource(_model->world(), _base_uri); @@ -241,7 +241,7 @@ Redland::Node Serialiser::class_rdf_node(const Path& path) { assert(_model); - assert(path.substr(0, _root_path.length()) == _root_path); + assert(path.is_child_of(_root_path)); if (path == _root_path) return Redland::Resource(_model->world(), _base_uri); @@ -272,7 +272,7 @@ Serialiser::serialise(SharedPtr<GraphObject> object) throw (std::logic_error) SharedPtr<Shared::Node> node = PtrCast<Shared::Node>(object); if (node) { - const Redland::Resource plugin_id(_model->world(), node->plugin()->uri()); + const Redland::Resource plugin_id(_model->world(), node->plugin()->uri().str()); serialise_node(node, plugin_id, instance_rdf_node(node->path())); return; } @@ -305,7 +305,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& _model->add_statement(patch_id, "lv2:symbol", Redland::Literal(_model->world(), s->second.get_string())); // Otherwise take the one from our path (if possible) - } else if (patch->path() != "/") { + } else if (!patch->path().is_root()) { _model->add_statement(patch_id, "lv2:symbol", Redland::Literal(_model->world(), patch->path().name())); } else { @@ -329,7 +329,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& serialise_patch(patch, class_id); serialise_node(patch, class_id, node_id); } else if (node) { - const Redland::Resource class_id(_model->world(), node->plugin()->uri()); + const Redland::Resource class_id(_model->world(), node->plugin()->uri().str()); const Redland::Node node_id(instance_rdf_node(n->second->path())); _model->add_statement(patch_id, "ingen:node", node_id); serialise_node(node, class_id, node_id); @@ -364,7 +364,7 @@ Serialiser::serialise_plugin(const Shared::Plugin& plugin) { assert(_model); - const Redland::Node plugin_id = Redland::Resource(_model->world(), plugin.uri()); + const Redland::Node plugin_id = Redland::Resource(_model->world(), plugin.uri().str()); _model->add_statement(plugin_id, "rdf:type", Redland::Resource(_model->world(), plugin.type_uri())); @@ -480,7 +480,7 @@ Serialiser::serialise_properties(Redland::Node subject, const GraphObject::Prope for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) { if (v->first.find(":") && v->second.is_valid()) { const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second); - _model->add_statement(subject, v->first, value); + _model->add_statement(subject, v->first.str(), value); } else { cerr << "Warning: unable to serialize property \'" << v->first << "\'" << endl; } @@ -492,9 +492,9 @@ void Serialiser::serialise_variables(Redland::Node subject, const GraphObject::Properties& variables) { for (GraphObject::Properties::const_iterator v = variables.begin(); v != variables.end(); ++v) { - if (v->first.find(":") && v->first != "ingen:document") { + if (v->first.find(":") && v->first.str() != "ingen:document") { if (v->second.is_valid()) { - const Redland::Resource key(_model->world(), v->first); + const Redland::Resource key(_model->world(), v->first.str()); const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second); if (value.is_valid()) { _model->add_statement(subject, key, value); |