diff --git a/impl/cpp/main.cpp b/impl/cpp/main.cpp index 4c0fe0c..3b8e806 100644 --- a/impl/cpp/main.cpp +++ b/impl/cpp/main.cpp @@ -63,11 +63,6 @@ int main(int argc, char** argv) { rapidjson::Document s; s.Parse(sch.c_str()); schema_validator(&d, &s); - rapidjson::Document f=get_interaction(&d,"partner=Hfq,Bbh,micF; type=basepairing"); - cout << f.Size() << endl; - f[0]["ID"]=12; - schema_validator(&f, &s); - write_json(&f,"/homes/brauerei2/guillaume/Documents/RNA/json/rna-interaction-specification/examples/" , "test"); } cout << endl << "The End !" << endl; return 0; diff --git a/impl/cpp/update.cpp b/impl/cpp/update.cpp index 4f68052..516cec1 100644 --- a/impl/cpp/update.cpp +++ b/impl/cpp/update.cpp @@ -61,7 +61,7 @@ std::vector> read_query(std::string q) //to use one of the methods below, better make sure first that the json document given as input is valid with regard to the schema (with schema_validator()). Things will probably not work otherwise. -int find_interaction(rapidjson::Document *doc, int ref) +int find_interaction(rapidjson::Document *doc, std::string ref) //searches an interaction from its ID, returns its position in the list of partners (or -1 if the partner is not found). { int s=(*doc).Size(); @@ -69,7 +69,7 @@ int find_interaction(rapidjson::Document *doc, int ref) int c=0; while(c==0 && i subset_interaction(rapidjson::Document *doc, std::string q) for(int j=0; j subset_interaction(rapidjson::Document *doc, std::string q) } } } - } - else if (std::string(nm)=="class" || std::string(nm)=="type") + }*/ + if (std::string(nm)=="ID" || std::string(nm)=="class" || std::string(nm)=="type") { for(int k=1; k<(qr[j]).size(); k++) { @@ -193,7 +193,7 @@ rapidjson::Document get_interaction(rapidjson::Document *doc, std::string q) void add_interaction(rapidjson::Document *doc, rapidjson::Value v) //adds a new interaction, but first checks that there is not already an interaction with same ID. Does not add the new interaction if this is the case. And does not check that the updated document remains valid with regards to the schema { - int ref=(v["ID"]).GetInt(); + std::string ref=(v["ID"]).GetString(); int i=find_interaction(doc, ref); if(i==-1) { @@ -206,7 +206,7 @@ void add_interaction(rapidjson::Document *doc, rapidjson::Value v) } } -void remove_interaction(rapidjson::Document *doc, int ref) +void remove_interaction(rapidjson::Document *doc, std::string ref) //as name says { int i=find_interaction(doc, ref); diff --git a/impl/cpp/update.h b/impl/cpp/update.h index 0655ddc..c8b39c3 100644 --- a/impl/cpp/update.h +++ b/impl/cpp/update.h @@ -9,7 +9,7 @@ #include "include/rapidjson/stringbuffer.h" #include "include/rapidjson/prettywriter.h" -int find_interaction(rapidjson::Document *doc, int ref); +int find_interaction(rapidjson::Document *doc, std::string ref); std::vector subset_interaction(rapidjson::Document *doc, std::string q); @@ -17,6 +17,6 @@ rapidjson::Document get_interaction(rapidjson::Document *doc, std::string q); void add_interaction(rapidjson::Document *doc, rapidjson::Value v); -void remove_interaction(rapidjson::Document *doc, int ref); +void remove_interaction(rapidjson::Document *doc, std::string ref); #endif /* UPDATE_H_ */