1 /**************************************
4 * A Test Ocaml Driver which calls the C++ methods and
5 * adds a C wrapper interface with OCaml code.
11 /* OCaml memory managment */
13 #include <caml/mlvalues.h>
14 #include <caml/alloc.h>
15 #include <caml/memory.h>
16 #include <caml/callback.h>
17 #include <caml/fail.h>
20 #include "XMLDocShredder.h"
21 #define CAMLRAISECPP(e) (caml_failwith( ((e).what())))
22 #define NOT_IMPLEMENTED (caml_failwith("Not Implemented!!!"))
24 extern "C" CAMLprim value caml_call_shredder_uri(value uri){
27 char *fn = String_val(uri);
29 XMLDocShredder shredder(fn);
30 shredder.processStartDocument(fn);
32 shredder.processEndDocument();
33 doc = (value) shredder.storageIfc_->returnDocument();
37 catch (const std::exception& e){
43 extern "C" CAMLprim value caml_call_shredder_string(value data){
46 unsigned int ln = string_length(data);
47 unsigned char *fn = (unsigned char*) String_val(data);
50 XMLDocShredder shredder(fn,ln);
51 shredder.processStartDocument("");
53 shredder.processEndDocument();
54 doc = (value) shredder.storageIfc_->returnDocument();
58 catch (const std::exception& e) {
63 extern "C" CAMLprim value caml_text_collection_get_text(value tree, value id){
67 CAMLreturn (Val_unit);
69 extern "C" CAMLprim value caml_xml_tree_root(value tree){
73 CAMLreturn (Val_unit);
75 extern "C" CAMLprim value caml_xml_tree_text_collection(value tree, value id){
79 CAMLreturn (Val_unit);
81 extern "C" CAMLprim value caml_xml_tree_next_sibling(value tree, value id){
85 CAMLreturn (Val_unit);
87 extern "C" CAMLprim value caml_xml_tree_first_child(value tree, value id){
91 CAMLreturn (Val_unit);
93 extern "C" CAMLprim value caml_xml_tree_prev_text(value tree, value id){
97 CAMLreturn (Val_unit);
99 extern "C" CAMLprim value caml_xml_tree_next_text(value tree, value id){
103 CAMLreturn (Val_unit);
105 extern "C" CAMLprim value caml_xml_tree_my_text(value tree, value id){
109 CAMLreturn (Val_unit);
112 extern "C" CAMLprim value caml_xml_tree_text_xml_id(value tree, value id){
116 CAMLreturn (Val_unit);
118 extern "C" CAMLprim value caml_xml_tree_node_xml_id(value tree, value id){
122 CAMLreturn (Val_unit);
124 extern "C" CAMLprim value caml_xml_tree_tag(value tree, value id){
128 CAMLreturn (Val_unit);
130 extern "C" CAMLprim value caml_xml_tree_nullt(value unit){
132 CAMLreturn (Val_int(-1));