CAMLreturn (Val_unit);
}
-extern "C" CAMLprim value caml_xml_tree_load(value fd){
- CAMLparam1(fd);
+extern "C" CAMLprim value caml_xml_tree_load(value fd, value load_tc,value sf){
+ CAMLparam3(fd,load_tc,sf);
CAMLlocal1(doc);
XMLTree * tree;
try {
- tree = XMLTree::Load(Int_val(fd));
- doc = caml_alloc_custom(&ops,sizeof(XMLTree*),1,2);
- memcpy(Data_custom_val(doc),&tree,sizeof(XMLTree*));
- CAMLreturn(doc);
+ tree = XMLTree::Load(Int_val(fd),Bool_val(load_tc),Int_val(sf));
+ doc = caml_alloc_custom(&ops,sizeof(XMLTree*),1,2);
+ memcpy(Data_custom_val(doc),&tree,sizeof(XMLTree*));
+ CAMLreturn(doc);
}
catch (const xmlpp::internal_error& e){ CAMLRAISEMSG(e.what()); }
catch (const std::exception& e){ CAMLRAISEMSG(e.what()); }
}
bool docId_comp(DocID x, DocID y) { return x < y; };
+
extern "C" CAMLprim value caml_text_collection_contains(value tree,value str){
CAMLparam2(tree,str);
CAMLlocal1(resarray);
uchar * cstr = (uchar *) String_val(str);
std::vector<DocID> results;
results = XMLTREE(tree)->Contains(cstr);
- //free(cstr);
std::sort(results.begin(), results.end(), docId_comp);
size_t s = results.size();
resarray = caml_alloc_tuple(s);
CAMLreturn (resarray);
}
+extern "C" CAMLprim value caml_text_collection_equals(value tree,value str){
+ CAMLparam2(tree,str);
+ CAMLlocal1(resarray);
+ uchar * cstr = (uchar *) String_val(str);
+ std::vector<DocID> results;
+ results = XMLTREE(tree)->Equal(cstr);
+ std::sort(results.begin(), results.end(), docId_comp);
+ size_t s = results.size();
+ resarray = caml_alloc_tuple(s);
+
+ for (size_t i = 0; i < s ;i++){
+ caml_initialize(&Field(resarray,i),Val_int(results[i]));
+ };
+ CAMLreturn (resarray);
+}
+extern "C" CAMLprim value caml_text_collection_startswith(value tree,value str){
+ CAMLparam2(tree,str);
+ CAMLlocal1(resarray);
+ uchar * cstr = (uchar *) String_val(str);
+ std::vector<DocID> results;
+ results = XMLTREE(tree)->Prefix(cstr);
+ std::sort(results.begin(), results.end(), docId_comp);
+ size_t s = results.size();
+ resarray = caml_alloc_tuple(s);
+
+ for (size_t i = 0; i < s ;i++){
+ caml_initialize(&Field(resarray,i),Val_int(results[i]));
+ };
+ CAMLreturn (resarray);
+}
+extern "C" CAMLprim value caml_text_collection_endswith(value tree,value str){
+ CAMLparam2(tree,str);
+ CAMLlocal1(resarray);
+ uchar * cstr = (uchar *) String_val(str);
+ std::vector<DocID> results;
+ results = XMLTREE(tree)->Suffix(cstr);
+ std::sort(results.begin(), results.end(), docId_comp);
+ size_t s = results.size();
+ resarray = caml_alloc_tuple(s);
+
+ for (size_t i = 0; i < s ;i++){
+ caml_initialize(&Field(resarray,i),Val_int(results[i]));
+ };
+ CAMLreturn (resarray);
+}
+
+
+
extern "C" CAMLprim value caml_text_collection_unsorted_contains(value tree,value str){
CAMLparam2(tree,str);
+ CAMLlocal1(resarray);
uchar * cstr = (uchar *) String_val(str);
std::vector<DocID> results;
results = XMLTREE(tree)->Contains(cstr);
- CAMLreturn (Val_unit);
+ resarray = caml_alloc_tuple(results.size());
+ for (size_t i = 0; i < results.size() ;i++){
+ caml_initialize(&Field(resarray,i),Val_int(results[i]));
+ };
+ CAMLreturn (resarray);
}
CAMLreturn (Val_int(nextResult(r, Int_val(p))));
}
+extern "C" CAMLprim value caml_result_set_count(value result){
+ CAMLparam0();
+ results r;
+ r = *( (results *) result);
+ CAMLreturn (Val_int(countResult(r)));
+}
+
extern "C" CAMLprim value caml_xml_tree_print(value tree,value node,value fd){
CAMLparam3(tree,node,fd);
XMLTREE(tree)->Print(Int_val(fd),TREENODEVAL(node));