Add option -nw control the wrapping of results in an <xml_result/> node.
authorKim Nguyễn <kn@lri.fr>
Fri, 19 Oct 2012 19:13:06 +0000 (21:13 +0200)
committerKim Nguyễn <kn@lri.fr>
Fri, 19 Oct 2012 19:19:58 +0000 (21:19 +0200)
src/main.ml
src/nodeSet.ml
src/nodeSet.mli
src/options.ml
src/options.mli

index 96e835e..2030452 100644 (file)
@@ -28,7 +28,7 @@ let mk_runtime run auto doc arg count print outfile =
     match outfile with
        None -> ()
       | Some file ->
-       time ~count:1 ~msg:"Serialization time" (print file doc) r
+       time ~count:1 ~msg:"Serialization time" (print file !Options.no_wrap_results doc) r
 ;;
 
 let main v query_string output =
index c2265b2..fc0bb0e 100644 (file)
@@ -24,7 +24,7 @@ module type S =
     val iter : ( elt -> unit) -> t -> unit
     val fold : ( elt -> 'a -> 'a) -> t -> 'a -> 'a
     val length : t -> int
-    val serialize : string -> Tree.t -> t -> unit
+    val serialize : string -> bool -> Tree.t -> t -> unit
 
   end
 
@@ -52,11 +52,12 @@ module Count : S with type t = int =
     let fold _ _ _ = failwith "fold not implemented"
     let map _ _ = failwith "map not implemented"
     let length x = x
-    let serialize f _ x =
+    let serialize f _ x =
       let o = open_out f in
-      output_string o "<xml_result>\n";
+      if not b then output_string o "<xml_result>\n";
       output_string o (string_of_int x);
-      output_string o "\n</xml_result>\n";
+      output_char o '\n';
+      if not b then output_string o "</xml_result>\n";
       close_out o
   end
 
@@ -191,19 +192,19 @@ module Mat : S with type t = Tree.node mat =
 
     let length l = l.length
 
-    let serialize name v l =
+    let serialize name v l =
       let fd, finish =
        if name = "-" then Unix.stdout, ignore
        else
          Unix.openfile name [ Unix.O_WRONLY; Unix.O_TRUNC; Unix.O_CREAT ] 0o666,
          Unix.close
       in
-      ignore (Unix.write fd "<xml_result>\n" 0 13);
+      if not b then ignore (Unix.write fd "<xml_result>\n" 0 13);
       if l.length > 0 then begin
        iter (fun node -> Tree.print_xml v node fd) l;
        Tree.flush v fd;
       end;
-      ignore (Unix.write fd "</xml_result>\n" 0 14);
+      if not b then ignore (Unix.write fd "</xml_result>\n" 0 14);
       finish fd
 
   end
index 2417ede..d9215ac 100644 (file)
@@ -21,7 +21,7 @@ module type S =
     val iter : ( elt -> unit) -> t -> unit
     val fold : ( elt -> 'a -> 'a) -> t -> 'a -> 'a
     val length : t -> int
-    val serialize : string -> Tree.t -> t -> unit
+    val serialize : string -> bool -> Tree.t -> t -> unit
 
 
 
index 6dfaaef..4a7a0c7 100644 (file)
@@ -21,6 +21,7 @@ let do_perf = ref false
 let twopass = ref false
 let repeat = ref 1
 let docstats = ref false
+let no_wrap_results = ref false
 
 let set_index_type = function
   | "default" -> text_index_type := 0
@@ -84,6 +85,7 @@ let spec = Arg.align
 
     "-nc", Arg.Set(no_cache), " disable caching";
 
+    "-nw", Arg.Set(no_wrap_results), " do not wrap results in <xml_results/>";
 
     "-p",  Arg.Set(do_perf), " dump perf counters (Linux only)";
 
index 6267853..4626e57 100644 (file)
@@ -18,3 +18,4 @@ val do_perf : bool ref
 val twopass : bool ref
 val repeat : int ref
 val docstats : bool ref
+val no_wrap_results : bool ref