summaryrefslogtreecommitdiff
path: root/rotord/src
diff options
context:
space:
mode:
authorComment <tim@gray.(none)>2013-08-22 09:51:50 +0100
committerComment <tim@gray.(none)>2013-08-22 09:51:50 +0100
commit3ca766e0a5a9472000d463ce9edbb6c5abcc8565 (patch)
tree94e3cfaf308c1eab25e4eb3275b2dab253f37cf2 /rotord/src
parent2abcafea32611988168f119bd7687dca5278dd9b (diff)
working on json loader
Diffstat (limited to 'rotord/src')
-rw-r--r--rotord/src/graph.cpp29
-rwxr-xr-xrotord/src/rotor.h2
2 files changed, 26 insertions, 5 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp
index 026325f..b799a59 100644
--- a/rotord/src/graph.cpp
+++ b/rotord/src/graph.cpp
@@ -66,12 +66,31 @@ bool Graph::load(string data,string media_path){
return false;
}
bool Graph::loadFile(string &filename,string media_path){
- if (loaded)
- printf("loading graph: %s\n",filename.c_str());
- if(xml.loadFile(filename) ){
- return parseXml(media_path);
+ //if (loaded)
+ printf("loading graph: %s\n",(filename).c_str());
+
+ //if(xml.loadFile(filename) ){
+ // return parseXml(media_path);
+ //}
+ Poco::FileInputStream fis(filename);
+ std::string read;
+ cerr<<fis;
+ cerr<<read.size()<<" json chars found"<<endl;
+ return false;
+}
+bool Graph::parseJson(string &data,string &media_path){
+ Json::Value root; // will contains the root value after parsing.
+ Json::Reader reader;
+ bool parsingSuccessful = reader.parse( data, root );
+ if ( !parsingSuccessful )
+ {
+ // report to the user the failure and their locations in the document.
+ std::cout << "Failed to parse configuration\n"
+ << reader.getFormattedErrorMessages();
+ return false;
}
- else return false;
+ cerr<<root["audio"]<<endl;
+ return true;
}
bool Graph::parseXml(string media_path){
if (loaded) nodes.clear();
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h
index 9427d83..cd4edb0 100755
--- a/rotord/src/rotor.h
+++ b/rotord/src/rotor.h
@@ -16,6 +16,7 @@
#include "Poco/Logger.h"
#include "Poco/Path.h"
#include "Poco/Base64Encoder.h"
+#include "Poco/FileStream.h"
#include "xmlIO.h"
#include "utils.h"
@@ -1050,6 +1051,7 @@ namespace Rotor {
bool load(string data,string media_path);
bool loadFile(string &filename,string media_path);
bool parseXml(string media_path);
+ bool parseJson(string &data,string &media_path);
bool set_resolution(int w,int h);
bool loaded;
float duration;