Fixed parameters
[SXSI/XMLTree.git] / XMLTree.h
index d0a5c73..6d11d78 100644 (file)
--- a/XMLTree.h
+++ b/XMLTree.h
 \r
 #ifndef XMLTREE_H_\r
 #define XMLTREE_H_\r
-extern "C" {\r
-#define CAML_NAME_SPACE\r
-#include <caml/mlvalues.h>\r
-#include <caml/custom.h>\r
-#define XMLTREE(x) ((XMLTree *)(* (XMLTree**) Data_custom_val(x)))\r
-  //#define XMLTREE(x) ((XMLTree*) (x))\r
-}\r
+\r
+\r
 #include <unordered_set>\r
 #include <unordered_map>\r
 #include <sstream>\r
 #include "TextCollection/TextCollectionBuilder.h"\r
 \r
-#include <cstdio>\r
-#include <cstdlib>\r
-#include <cstring>\r
-\r
-\r
 #undef W\r
 #undef WW\r
 #undef Wminusone\r
@@ -50,7 +40,6 @@ using SXSI::TextCollection;
 using SXSI::TextCollectionBuilder;\r
 \r
 \r
-\r
 // this constant is used to efficiently compute the child operation in the tree\r
 #define OPTD 10\r
 \r
@@ -96,7 +85,7 @@ typedef struct {
 \r
 \r
 typedef std::unordered_set<int> TagIdSet;\r
-typedef std::unordered_map<string,int> TagIdMap;\r
+typedef std::unordered_map<std::string,int> TagIdMap;\r
 typedef TagIdMap::const_iterator TagIdMapIT;\r
 \r
 #define REGISTER_TAG(v,h,t) do { (h)->insert(std::make_pair((t),(v)->size()));\\r
@@ -123,7 +112,7 @@ class XMLTree {
    bp *Par;\r
  \r
    /** Mapping from tag identifer to tag name */  \r
-   vector<string> *TagName;\r
+   std::vector<std::string> *TagName;\r
    TagIdMap * tIdMap;\r
   \r
    /** Bit vector indicating with a 1 the positions of the non-empty texts. */\r
@@ -142,7 +131,7 @@ class XMLTree {
    \r
    FILE* stream;\r
    int   stream_fd; \r
-   string * buffer;\r
+   std::string * buffer;\r
    void myfputs(const char* s, FILE * fp){\r
      buffer->append(s);\r
      if (buffer->size() >= 100000){\r
@@ -162,11 +151,26 @@ class XMLTree {
      fputs(buffer->c_str(), fp);\r
      buffer->clear();\r
    }\r
+\r
+   size_t myfprintf(const char* s, FILE * fp){\r
+     if (s == NULL)\r
+       return 0;\r
+     size_t i = buffer->size();\r
+     buffer->append(s);\r
+     size_t j = buffer->size();\r
+     if (buffer->size() >= 100000){\r
+       fputs(buffer->c_str(),fp);\r
+       buffer->clear();\r
+     };\r
+     return (j-i);\r
+   }\r
+\r
+   void PrintNode(treeNode n, int fd);\r
    /** Data structure constructors */\r
    XMLTree(){ buffer = 0;};\r
 \r
    // non const pointer are freed by this method.\r
-  XMLTree( pb * const par, uint npar,  vector<string> * const TN,  TagIdMap * const tim, uint *empty_texts_bmp, TagType *tags,\r
+   XMLTree( pb * const par, uint npar,  std::vector<std::string> * const TN,  TagIdMap * const tim, uint *empty_texts_bmp, TagType *tags,\r
           TextCollection * const TC, bool dis_tc);\r
 \r
 public: \r
@@ -256,7 +260,7 @@ public:
     *    if none.\r
     */\r
    treeNode FirstElement(treeNode x);\r
-   value CamlFirstElement(value x);\r
+\r
    /** LastChild(x): returns the last child of node x.  */\r
    treeNode LastChild(treeNode x);\r
    \r
@@ -269,7 +273,7 @@ public:
     *    if none.\r
     */\r
    treeNode NextElement(treeNode x);\r
-   value CamlNextElement(value x);\r
+\r
    /** PrevSibling(x): returns the previous sibling of node x, assuming it \r
     * exists. */\r
 \r
@@ -458,7 +462,7 @@ public:
    uchar* GetText(DocID d) {\r
      \r
        uchar * s = Text->GetText(d);\r
-       return (s[0] == 1 ? (uchar*)"" : s);\r
+       return (s[0] == 1 ? (s+1) : s);\r
    }\r
 \r
    /** GetText(i, j): returns the texts corresponding to documents with\r
@@ -496,8 +500,6 @@ public:
 \r
 };\r
 \r
-extern "C" value caml_cpp_fast_first_element(value xmltree, value node);\r
-extern "C" value caml_cpp_fast_next_element(value xmltree, value node);\r
 \r
 \r
 \r