a09216ef0096fee40110a870752928d614a0d273
[SXSI/xpathcomp.git] / src / lexindex_stub.cpp
1 #include <cstring>
2 #include <utility>
3 #include <algorithm>
4 #include <vector>
5 #include "xml-tree.hpp"
6 #include "utils_stub.hpp"
7
8
9 //define a type for the lexicographic index
10
11 class lex_index {
12 public:
13   //The tag ID
14   xml_tree::tag_t tag;
15   //The text data
16   std::vector<std::pair<std::string, xml_tree::node_t> > data;
17 };
18
19
20
21 using namespace SXSI;
22
23
24 static xml_tree*& XMLTREE(value v)
25 {
26   return Obj_val<xml_tree*>(v);
27 }
28
29 static lex_index*& LEXINDEX(value v)
30 {
31   return Obj_val<lex_index*>(v);
32 }
33
34 static xml_tree::node_t TREENODE(value i)
35 {
36   return static_cast<xml_tree::node_t>(Int_val(i));
37 }
38
39 static xml_tree::tag_t TAG(value i)
40 {
41   return static_cast<xml_tree::tag_t>(Int_val(i));
42 }
43
44
45
46
47 extern "C" value caml_build_lex_index(value vtree, value vtag)
48 {
49   CAMLparam2(vtree, vtag);
50   CAMLlocal1(vindex);
51   vindex = sxsi_alloc_custom<lex_index*>();
52   xml_tree * tree = XMLTREE(vtree);
53   xml_tree::tag_t tag = TAG(vtag);
54
55   //Uncomment the following and comment the failwith line
56   //LEXINDEX(vindex) = ... return a lex_index* ....
57
58
59   caml_failwith("build_lex_index not implemented");
60
61
62   CAMLreturn (vindex);
63 }
64
65 extern "C" value caml_print_lex_index(value vindex)
66 {
67   CAMLparam1(vindex);
68   lex_index* index = LEXINDEX(vindex);
69
70   //Print the index to the terminal
71
72   caml_failwith("print_lex_index not implemented");
73
74
75   CAMLreturn (Val_unit);
76 }