#include "basics.h"\r
-//#include <cstring>\r
-#include <stack>\r
#include "XMLTree.h"\r
#include "timings.h"\r
#include <errno.h>\r
+using std::cout;\r
+using std::endl;\r
+using std::min;\r
+using std::string;\r
+\r
// functions to convert tag positions to the corresponding tree node and viceversa. \r
// These are implemented in order to be able to change the tree and Tags representations, \r
// without affecting the code so much.\r
XMLTree *XML_Tree;\r
int i;\r
\r
-\r
+ buffer[1023] = '\0';\r
\r
fp = fdopen(fd, "r");\r
\r
PRINTTIME("Loading parenthesis struct", Loading);\r
STARTTIMER();\r
\r
- XML_Tree->TagName = new vector<string>();\r
- XML_Tree->tIdMap = new std::unordered_map<string,int>();\r
- \r
- string s;\r
+ XML_Tree->TagName = new std::vector<std::string>();\r
+ XML_Tree->tIdMap = new std::unordered_map<std::string,int>();\r
+ std::string s;\r
int ntags;\r
\r
// Load the tag names\r
ufread(&ntags, sizeof(int), 1, fp);\r
\r
for (i=0; i<ntags;i++) {\r
- char * r = fgets(buffer,1023,fp);\r
- if (r==NULL)\r
+ if (fgets(buffer,1022,fp) != buffer)\r
throw "Cannot read tag list";\r
- s = (const char*) buffer;\r
+ s = buffer;\r
// remove the trailing \n\r
s.erase(s.size()-1); \r
- XML_Tree->TagName->push_back(s);\r
+ XML_Tree->TagName->push_back(s); \r
XML_Tree->tIdMap->insert(std::make_pair(s,i));\r
\r
};\r
}\r
else return x; \r
}\r
-value XMLTree::CamlFirstElement(value x)\r
-{\r
- return Val_int(FirstElement(Int_val(x)));\r
-}\r
-value XMLTree::CamlNextElement(value x)\r
-{\r
- return Val_int(NextElement(Int_val(x)));\r
-}\r
-\r
-extern "C" value caml_cpp_fast_first_element(value xmltree, value node){\r
- return XMLTREE(xmltree)->CamlFirstElement(node);\r
-}\r
-\r
-extern "C" value caml_cpp_fast_next_element(value xmltree, value node){\r
- return XMLTREE(xmltree)->CamlNextElement(node);\r
-}\r
\r
// LastChild(x): returns the last child of node x.\r
treeNode XMLTree::LastChild(treeNode x)\r