From 4680fa5b41156d70f0fde69981f0d241184b19d9 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 16 Feb 2009 01:06:56 +0000 Subject: [PATCH] Implement CachedText git-svn-id: svn+ssh://idea.nguyen.vg/svn/sxsi/trunk/xpathcomp@181 3cdefd35-fc62-479d-8e8d-bae585ffb9ca --- OCamlDriver.cpp | 10 ++++++++++ tree.ml | 9 ++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/OCamlDriver.cpp b/OCamlDriver.cpp index e20a749..09175ba 100644 --- a/OCamlDriver.cpp +++ b/OCamlDriver.cpp @@ -132,6 +132,16 @@ extern "C" CAMLprim value caml_text_collection_get_text(value tree, value id){ delete (txt); CAMLreturn (str); } + +extern "C" CAMLprim value caml_text_collection_get_cached_text(value tree, value id){ + CAMLparam2(tree,id); + CAMLlocal1(str); + const char* txt = (const char*) XMLTREE(tree)->GetCachedText((DocID) Int_val(id)); + str = caml_copy_string(txt); + CAMLreturn (str); +} + + extern "C" CAMLprim value caml_text_collection_empty_text(value tree,value id){ CAMLparam2(tree,id); CAMLreturn ( Val_int((XMLTREE(tree))->EmptyText((DocID) Int_val(id)))); diff --git a/tree.ml b/tree.ml index d0cd550..16b32a3 100644 --- a/tree.ml +++ b/tree.ml @@ -77,14 +77,21 @@ struct let nil = nullt () external get_text : t -> [`Text] node -> string = "caml_text_collection_get_text" - let get_text t n = +(* let get_text t n = if equal nil n then "" else get_text t n +*) external is_empty : t -> [`Text ] node -> bool = "caml_text_collection_empty_text" let is_empty t n = (equal nil n) || is_empty t n + external get_cached_text : t -> [`Text ] node -> string = "caml_text_collection_get_cached_text" + + let get_text t n = + if (equal nil n) || is_empty t n then "" + else get_cached_text t n + external is_contains : t -> string -> bool = "caml_text_collection_is_contains" external count_contains : t -> string -> int = "caml_text_collection_count_contains" external contains : t -> string -> [`Text ] node array = "caml_text_collection_contains" -- 2.17.1