From 94921caf9ca327d35adcb941f51ba4b1a776f768 Mon Sep 17 00:00:00 2001 From: Comment Date: Wed, 6 Nov 2013 01:09:39 +0000 Subject: json loader issue --- rotord/Makefile | 2 +- rotord/src/graph.cpp | 20 +++++++++++--------- rotord/src/rotor.h | 1 + 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/rotord/Makefile b/rotord/Makefile index 55d2970..70c6acb 100644 --- a/rotord/Makefile +++ b/rotord/Makefile @@ -44,7 +44,7 @@ HDREXTS = .h .H .hh .hpp .HPP .h++ .hxx .hp # The pre-processor and compiler options. # Users can override those variables from the command line. -CFLAGS = -g -O2 +CFLAGS = -g -O3 CXXFLAGS= CXX = colorgcc diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index e34ddec..9544446 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -324,13 +324,18 @@ bool Graph::parseJson(string &data,string &media_path){ Node* node=factory.create(settings); for (uint32_t m=0;mattributes.find(attribute)!=node->attributes.end()){ Attribute *attr=node->attributes.find(attribute)->second; if (attr->type=="enum"){ - string val=jnodes[i]["attributes"][m]["value"].asString(); - attr->init(val); + val=jnodes[i]["attributes"][m]["value"].asString(); + attr->init(val); } - else if (attr->type=="array"){ + if (attr->type=="string") { + val=jnodes[i]["attributes"][m]["value"].asString(); + attr->value=val; + } + if (attr->type=="array"){ std::vector vals; for (uint32_t i5 = 0; i5 < jnodes[i]["attributes"][m]["value"].size(); i5++ ) @@ -338,15 +343,12 @@ bool Graph::parseJson(string &data,string &media_path){ vals.push_back(jnodes[i]["attributes"][m]["value"][i5].asString()); } attr->init(vals); - - } - else { - string val=jnodes[i]["attributes"][m]["value"].asString(); - attr->value=val; } + //cerr << "Rotor: setting attribute '"<type<<" to "<type<<" to "< _vals={},std::string _type="string") { + if (_vals.size()&&_type!="array") _type="enum"; //hack for incomplete attribute types attributes[_attr]=new Attribute(_desc,_title,_value,_vals,_type); }; void create_attribute(string *alias,const string &_attr,const string &_desc,const string &_title,const string &_value,std::vector _vals={},std::string _type="string") { -- cgit v1.2.3