Added quantiling UDAFs
[com/gs-lite.git] / src / tools / xml_t.h
index c17ad68..4d14a7f 100644 (file)
-/* ------------------------------------------------
-Copyright 2014 AT&T Intellectual Property
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
- ------------------------------------------- */
-
-#ifndef __XML_T_DEFINED_
-#define __XML_T_DEFINED_
-
-#include <stdio.h>
-#include<vector>
-#include<string>
-#include<map>
-#include<set>
-#include<algorithm>
-
-
-void xmlParser_setfileinput(FILE *f);
-void xmlParser_setstringinput(char *s);
-
-
-
-struct name_val_pair_t{
-       std::string name;
-       std::string val;
-
-       name_val_pair_t(const char *n, const char *v){
-               name = n;
-               val = v;
-       }
-};
-
-struct name_val_list_t{
-       std::vector<name_val_pair_t *> nvp_list;
-
-       name_val_list_t(){
-       }
-
-       name_val_list_t(name_val_pair_t *nvp){
-               nvp_list.push_back(nvp);
-       }
-
-       name_val_list_t *append(name_val_pair_t *nvp){
-               nvp_list.push_back(nvp);
-               return this;
-       }
-};
-
-struct tag_t{
-       std::string name;
-       std::vector<name_val_pair_t *> nvp_list;
-
-       tag_t(const char *n, name_val_list_t *nvl){
-               name=n;
-               nvp_list = nvl->nvp_list;
-       }
-};
-
-
-struct xml_list_t;
-
-struct xml_t{
-       std::string name;
-       std::string end_tag_name;
-       std::vector<name_val_pair_t *> attribs;
-
-       std::vector<xml_t *> subtrees;
-
-       xml_t(){}
-
-       xml_t(tag_t *s, xml_list_t *xl,const char *e);
-
-       xml_t(tag_t *s, char *e){
-               name=s->name;
-               attribs = s->nvp_list;
-               end_tag_name = e;
-       }
-
-       xml_t(const char *n, name_val_list_t *nvl){
-               name=n;
-               attribs=nvl->nvp_list;
-       }
-
-       std::string to_string(){
-               return to_string("");
-       }
-       std::string to_string(std::string indent){
-               std::string ret;
-               std::string whitespace;
-               int i;
-
-               ret += indent+"<"+name;
-               for(i=0;i<attribs.size();++i)
-                       ret += " "+attribs[i]->name+"="+attribs[i]->val;
-
-               if(subtrees.size()>0){
-                       ret+=">\n";
-                       for(i=0;i<subtrees.size();++i){
-                               ret += subtrees[i]->to_string(indent+"  ");
-                       }
-                       ret += indent + "</"+name+">\n";
-               }else{
-                       ret+=">\n";
-               }
-               return ret;
-       }
-
-       void get_roots(std::string type, std::vector<xml_t *> &ret);
-       void get_roots(std::set<std::string> type, std::vector<xml_t *> &ret);
-
-       bool get_attrib_val(std::string name, std::string &val){
-               val="";
-               int i;
-               for(i=0;i<attribs.size();++i){
-                       if(attribs[i]->name == name){
-                               val = attribs[i]->val;
-                               return true;
-                       }
-               }
-               return false;
-       }
-
-};
-
-struct xml_list_t{
-       std::vector<xml_t *> xlist;
-
-       xml_list_t(xml_t *x){
-               xlist.push_back(x);
-       }
-
-       xml_list_t *append(xml_t *x){
-               xlist.push_back(x);
-               return this;
-       }
-};
-
-#endif
-
+/* ------------------------------------------------\r
+Copyright 2014 AT&T Intellectual Property\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+     http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+ ------------------------------------------- */\r
+\r
+#ifndef __XML_T_DEFINED_\r
+#define __XML_T_DEFINED_\r
+\r
+#include <stdio.h>\r
+#include<vector>\r
+#include<string>\r
+#include<map>\r
+#include<set>\r
+#include<algorithm>\r
+\r
+\r
+void xmlParser_setfileinput(FILE *f);\r
+void xmlParser_setstringinput(char *s);\r
+\r
+\r
+\r
+struct name_val_pair_t{\r
+       std::string name;\r
+       std::string val;\r
+\r
+       name_val_pair_t(const char *n, const char *v){\r
+               name = n;\r
+               val = v;\r
+       }\r
+};\r
+\r
+struct name_val_list_t{\r
+       std::vector<name_val_pair_t *> nvp_list;\r
+\r
+       name_val_list_t(){\r
+       }\r
+\r
+       name_val_list_t(name_val_pair_t *nvp){\r
+               nvp_list.push_back(nvp);\r
+       }\r
+\r
+       name_val_list_t *append(name_val_pair_t *nvp){\r
+               nvp_list.push_back(nvp);\r
+               return this;\r
+       }\r
+};\r
+\r
+struct tag_t{\r
+       std::string name;\r
+       std::vector<name_val_pair_t *> nvp_list;\r
+\r
+       tag_t(const char *n, name_val_list_t *nvl){\r
+               name=n;\r
+               nvp_list = nvl->nvp_list;\r
+       }\r
+};\r
+\r
+\r
+struct xml_list_t;\r
+\r
+struct xml_t{\r
+       std::string name;\r
+       std::string end_tag_name;\r
+       std::vector<name_val_pair_t *> attribs;\r
+\r
+       std::vector<xml_t *> subtrees;\r
+\r
+       xml_t(){}\r
+\r
+       xml_t(tag_t *s, xml_list_t *xl,const char *e);\r
+\r
+       xml_t(tag_t *s, char *e){\r
+               name=s->name;\r
+               attribs = s->nvp_list;\r
+               end_tag_name = e;\r
+       }\r
+\r
+       xml_t(const char *n, name_val_list_t *nvl){\r
+               name=n;\r
+               attribs=nvl->nvp_list;\r
+       }\r
+\r
+       std::string to_string(){\r
+               return to_string("");\r
+       }\r
+       std::string to_string(std::string indent){\r
+               std::string ret;\r
+               std::string whitespace;\r
+               int i;\r
+\r
+               ret += indent+"<"+name;\r
+               for(i=0;i<attribs.size();++i)\r
+                       ret += " "+attribs[i]->name+"="+attribs[i]->val;\r
+\r
+               if(subtrees.size()>0){\r
+                       ret+=">\n";\r
+                       for(i=0;i<subtrees.size();++i){\r
+                               ret += subtrees[i]->to_string(indent+"  ");\r
+                       }\r
+                       ret += indent + "</"+name+">\n";\r
+               }else{\r
+                       ret+=">\n";\r
+               }\r
+               return ret;\r
+       }\r
+\r
+       void get_roots(std::string type, std::vector<xml_t *> &ret);\r
+       void get_roots(std::set<std::string> type, std::vector<xml_t *> &ret);\r
+\r
+       bool get_attrib_val(std::string name, std::string &val){\r
+               val="";\r
+               int i;\r
+               for(i=0;i<attribs.size();++i){\r
+                       if(attribs[i]->name == name){\r
+                               val = attribs[i]->val;\r
+                               return true;\r
+                       }\r
+               }\r
+               return false;\r
+       }\r
+\r
+};\r
+\r
+struct xml_list_t{\r
+       std::vector<xml_t *> xlist;\r
+\r
+       xml_list_t(xml_t *x){\r
+               xlist.push_back(x);\r
+       }\r
+\r
+       xml_list_t *append(xml_t *x){\r
+               xlist.push_back(x);\r
+               return this;\r
+       }\r
+};\r
+\r
+#endif\r
+\r