File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ void Store::JsonParser(std::string input){
6868 int type=0 ;
6969 std::string key=" " ;
7070 std::string value=" " ;
71+ int bracket_counter=0 ;
7172
7273 for (std::string::size_type i = 0 ; i < input.size (); ++i) {
7374
@@ -101,9 +102,11 @@ void Store::JsonParser(std::string input){
101102 }
102103 else if (type==3 && !(input[i]==' ' || input[i]==' {' || input[i]==' [' )) value+=input[i];
103104 else if (type==3 && input[i]==' {' ){ value+=input[i]; type=6 ; }
104- else if (type==6 && input[i]==' }' ){ value+=input[i]; type=5 ; }
105+ else if (type==6 && input[i]==' {' ){ value+=input[i]; bracket_counter++; }
106+ else if (type==6 && input[i]==' }' ){ value+=input[i]; bracket_counter--;if (bracket_counter==-1 ){ type=5 ; bracket_counter=0 ;} }
105107 else if (type==3 && input[i]==' [' ){ value+=input[i]; type=7 ; }
106- else if (type==7 && input[i]==' ]' ){ value+=input[i]; type=5 ; }
108+ else if (type==7 && input[i]==' [' ){ value+=input[i]; bracket_counter++; }
109+ else if (type==7 && input[i]==' ]' ){ value+=input[i]; bracket_counter--;if (bracket_counter==-1 ){ type=5 ; bracket_counter=0 ;} }
107110 else if (type==4 || type==6 || type==7 ) value+=input[i];
108111 }
109112
@@ -197,3 +200,11 @@ std::string Store::StringStrip(std::string in){
197200 return in;
198201
199202}
203+
204+ bool Store::Destring (std::string key){
205+
206+ if (!m_variables.count (key)) return false ;
207+ m_variables[key]=StringStrip (m_variables[key]);
208+ return true ;
209+
210+ }
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ namespace ToolFramework{
3131 void Delete (); // /< Deletes all entries in the Store.
3232 bool Has (std::string key); // /<Returns bool based on if store contains entry given by sting @param string key to comapre.
3333 std::vector<std::string> Keys (); // returns a vector of the keys
34+ bool Destring (std::string key); // convers an element from a string by stripping the speachmarks @param string key to comapre.
3435
3536 /* *
3637 Templated getter function for sore content. Assignment is templated and via reference.
@@ -214,8 +215,8 @@ namespace ToolFramework{
214215
215216 }
216217
217- std::map<std::string, std::string>::const_iterator begin () { return m_variables.begin (); }
218- std::map<std::string, std::string>::const_iterator end () { return m_variables.end (); }
218+ std::map<std::string, std::string>::iterator begin () { return m_variables.begin (); }
219+ std::map<std::string, std::string>::iterator end () { return m_variables.end (); }
219220
220221
221222 private:
You can’t perform that action at this time.
0 commit comments