From 21b1e2e485d9fa954ca742965d000f3273fcb862 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 12 Aug 2012 15:56:21 +0000 Subject: Stricter symbol construction and conversion. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4670 a436a847-0d15-0410-975c-d299462d15a1 --- src/serialisation/Parser.cpp | 4 ++-- src/serialisation/Serialiser.cpp | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/serialisation') diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index b8d0adbc..8407429f 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -167,7 +167,7 @@ get_port(Ingen::World* world, LOG(error) << "Port " << subject << " has no symbol" << endl; return -1; } - const Symbol port_sym = s->second.get_string(); + const Symbol port_sym(s->second.get_string()); const Path port_path = parent.child(port_sym); record = make_pair(port_path, props); @@ -330,7 +330,7 @@ parse_patch(Ingen::World* world, const Glib::ustring base_uri = model.base_uri().to_string(); - Raul::Symbol symbol = "_"; + Raul::Symbol symbol("_"); if (a_symbol) { symbol = *a_symbol; } else { diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 5ad62e7c..9e01eaf7 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -328,26 +328,27 @@ Serialiser::Impl::serialise_patch(SharedPtr patch, const URIs& uris = _world.uris(); // Always write a symbol (required by Ingen) - string symbol; + Raul::Symbol symbol("_"); GraphObject::Properties::const_iterator s = patch->properties().find(uris.lv2_symbol); if (s == patch->properties().end() || !s->second.type() == _world.forge().String || !Symbol::is_valid(s->second.get_string())) { - symbol = Glib::path_get_basename(_model->base_uri().to_c_string()); - symbol = Symbol::symbolify(symbol.substr(0, symbol.find('.'))); + const std::string base = Glib::path_get_basename( + _model->base_uri().to_c_string()); + symbol = Symbol::symbolify(base.substr(0, base.find('.'))); _model->add_statement( patch_id, Sord::Curie(world, "lv2:symbol"), - Sord::Literal(world, symbol)); + Sord::Literal(world, symbol.c_str())); } else { - symbol = s->second.get_string(); + symbol = Raul::Symbol::symbolify(s->second.get_string()); } // If the patch has no doap:name (required by LV2), use the symbol if (patch->properties().find(uris.doap_name) == patch->properties().end()) _model->add_statement(patch_id, Sord::URI(world, uris.doap_name.str()), - Sord::Literal(world, symbol)); + Sord::Literal(world, symbol.c_str())); const GraphObject::Properties props = patch->properties(Resource::INTERNAL); serialise_properties(patch_id, props); -- cgit v1.2.1