summaryrefslogtreecommitdiffstats
path: root/src/libs/serialisation
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/serialisation')
-rw-r--r--src/libs/serialisation/Loader.cpp8
-rw-r--r--src/libs/serialisation/Serialiser.cpp34
2 files changed, 25 insertions, 17 deletions
diff --git a/src/libs/serialisation/Loader.cpp b/src/libs/serialisation/Loader.cpp
index da2e6507..6708a0e3 100644
--- a/src/libs/serialisation/Loader.cpp
+++ b/src/libs/serialisation/Loader.cpp
@@ -212,8 +212,9 @@ Loader::load(Ingen::Shared::World* world,
const string port_name = (*i)["portname"].to_string();
const float val = (*i)["portval"].to_float();
- const Path port_path = patch_path.base() + Path::nameify(node_name)
- +"/"+ Path::nameify(port_name);
+ assert(Path::is_valid_name(node_name));
+ assert(Path::is_valid_name(port_name));
+ const Path port_path = patch_path.base() + node_name + "/" + port_name;
world->engine->set_port_value(port_path, "ingen:Float", sizeof(float), &val);
}
@@ -243,7 +244,8 @@ Loader::load(Ingen::Shared::World* world,
const string type = world->rdf_world->qualify((*i)["type"].to_string());
const string datatype = world->rdf_world->qualify((*i)["datatype"].to_string());
- const Path port_path = patch_path.base() + (string)name;
+ assert(Path::is_valid_name(name));
+ const Path port_path = patch_path.base() + name;
if (created.find(port_path) == created.end()) {
bool is_output = (type == "ingen:OutputPort"); // FIXME: check validity
diff --git a/src/libs/serialisation/Serialiser.cpp b/src/libs/serialisation/Serialiser.cpp
index a81c76f6..710a538c 100644
--- a/src/libs/serialisation/Serialiser.cpp
+++ b/src/libs/serialisation/Serialiser.cpp
@@ -100,9 +100,15 @@ Serialiser::start_to_filename(const string& filename)
{
setlocale(LC_NUMERIC, "C");
- _base_uri = "file://" + filename;
+ cout << "STARTING SERIALIZATION TO FILENAME: " << filename << endl;
+
+ assert(filename.find(":") == string::npos || filename.substr(0, 5) == "file:");
+ if (filename.find(":") == string::npos)
+ _base_uri = "file://" + filename;
+ else
+ _base_uri = filename;
_model = new Redland::Model(_world);
- _model->set_base_uri(string("file://" + filename));
+ _model->set_base_uri(_base_uri);
_mode = TO_FILE;
}
@@ -429,19 +435,19 @@ void
Serialiser::serialise_variables(Redland::Node subject, const GraphObject::Variables& variables)
{
for (GraphObject::Variables::const_iterator v = variables.begin(); v != variables.end(); ++v) {
- if (v->first.find(":") != string::npos) {
+ if (v->first.find(":") != string::npos && v->first != "ingen:document") {
if (v->second.is_valid()) {
- const Redland::Node var_id = _world.blank_id();
- const Redland::Node key(_model->world(), Redland::Node::RESOURCE, v->first);
- const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second);
- if (value) {
- _model->add_statement(subject, "ingen:variable", var_id);
- _model->add_statement(var_id, "ingen:key", key);
- _model->add_statement(var_id, "ingen:value", value);
- } else {
- cerr << "Warning: can not serialise value: key '" << v->first << "', type "
- << (int)v->second.type() << endl;
- }
+ const Redland::Node var_id = _world.blank_id();
+ const Redland::Node key(_model->world(), Redland::Node::RESOURCE, v->first);
+ const Redland::Node value = AtomRDF::atom_to_node(_model->world(), v->second);
+ if (value) {
+ _model->add_statement(subject, "ingen:variable", var_id);
+ _model->add_statement(var_id, "ingen:key", key);
+ _model->add_statement(var_id, "ingen:value", value);
+ } else {
+ cerr << "Warning: can not serialise value: key '" << v->first << "', type "
+ << (int)v->second.type() << endl;
+ }
} else {
cerr << "Warning: variable with no value: key '" << v->first << "'" << endl;
}