diff options
author | David Robillard <d@drobilla.net> | 2009-05-28 01:38:34 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-28 01:38:34 +0000 |
commit | c9a25fcc6150290790457f837355735b513b7239 (patch) | |
tree | 0b234edf54525fe2e7883ffe6c10b5e15788065c /src/serialisation | |
parent | 2f595631859574bfa7779ebb42f42b8590f5424c (diff) | |
download | ingen-c9a25fcc6150290790457f837355735b513b7239.tar.gz ingen-c9a25fcc6150290790457f837355735b513b7239.tar.bz2 ingen-c9a25fcc6150290790457f837355735b513b7239.zip |
Fix QNAMEs being serialised as URIs.
Remove vestigial variable stuff.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2017 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r-- | src/serialisation/Parser.cpp | 2 | ||||
-rw-r--r-- | src/serialisation/Serialiser.cpp | 55 |
2 files changed, 22 insertions, 35 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index d1e16664..647c90be 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -158,7 +158,7 @@ Parser::parse_document( = parse(world, target, model, document_uri, data_path, parent, symbol, data); if (parsed_path) { - target->set_property(*parsed_path, "ingen:document", Atom(document_uri.c_str())); + target->set_property(*parsed_path, "ingen:document", Atom(Atom::URI, document_uri.c_str())); } else { cerr << "WARNING: document URI lost" << endl; } diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 231d19fa..239ce22c 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -316,7 +316,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& cerr << "WARNING: Patch has no lv2:symbol" << endl; } - serialise_meta_properties(patch_id, patch->properties()); + serialise_properties(patch_id, patch->meta().properties()); for (GraphObject::const_iterator n = _store->children_begin(patch); n != _store->children_end(patch); ++n) { @@ -387,14 +387,14 @@ Serialiser::serialise_node(SharedPtr<Shared::Node> node, _model->add_statement(node_id, "lv2:symbol", Redland::Literal(_model->world(), node->path().name())); + serialise_properties(node_id, node->properties()); + for (uint32_t i=0; i < node->num_ports(); ++i) { Port* p = node->port(i); const Redland::Node port_id = instance_rdf_node(p->path()); serialise_port(p, port_id); _model->add_statement(node_id, "lv2:port", port_id); } - - serialise_properties(node_id, node->properties()); } @@ -452,7 +452,7 @@ Serialiser::serialise_port_meta(const Port* port, const Redland::Node& port_id) } } - serialise_meta_properties(port_id, port->properties()); + serialise_properties(port_id, port->meta().properties()); } @@ -463,8 +463,13 @@ Serialiser::serialise_connection(SharedPtr<GraphObject> parent, if (!_model) throw std::logic_error("serialise_connection called without serialization in progress"); - const Redland::Node src_node = class_rdf_node(connection->src_port_path()); - const Redland::Node dst_node = class_rdf_node(connection->dst_port_path()); + bool top = (parent->path() == _root_path); + const Redland::Node src_node = top + ? instance_rdf_node(connection->src_port_path()) + : class_rdf_node(connection->src_port_path()); + const Redland::Node dst_node = top + ? instance_rdf_node(connection->dst_port_path()) + : class_rdf_node(connection->dst_port_path()); const Redland::Node connection_node = _world.blank_id(); _model->add_statement(connection_node, "ingen:source", src_node); @@ -480,42 +485,24 @@ Serialiser::serialise_connection(SharedPtr<GraphObject> parent, void -Serialiser::serialise_meta_properties( - Redland::Node subject, - const GraphObject::Properties& properties) -{ - 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.str(), value); - } else { - cerr << "Warning: unable to serialize property \'" << v->first << "\'" << endl; - } - } -} - - -void Serialiser::serialise_properties( Redland::Node subject, const GraphObject::Properties& properties) { for (GraphObject::Properties::const_iterator v = properties.begin(); v != properties.end(); ++v) { - if (v->first.find(":") && v->first.str() != "ingen:document") { - if (v->second.is_valid()) { - 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); - } else { - cerr << "WARNING: can not serialise variable '" << v->first << "' :: " - << (int)v->second.type() << endl; - } + if (v->second.is_valid()) { + 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()) { + cerr << "serialise property '" << v->first << "' = " << value << " :: " + << (int)v->second.type() << endl; + _model->add_statement(subject, key, value); } else { - cerr << "WARNING: variable '" << v->first << "' has no value" << endl; + cerr << "WARNING: can not serialise variable '" << v->first << "' :: " + << (int)v->second.type() << endl; } } else { - cerr << "Not serialising special variable '" << v->first << "'" << endl; + cerr << "WARNING: property '" << v->first << "' has no value" << endl; } } } |