removed cruft, fixed ptset.ml
[SXSI/xpathcomp.git] / SXSIStorageInterface.cpp
1 /*******************************************
2  * SXSIStorageInterface.cpp
3  * ------------------------
4  *
5  * 
6  * Author: Kim Nguyen
7  * Date: 04/11/08
8  */
9
10
11 #include "SXSIStorageInterface.h"
12 #include "Utils.h"
13
14 SXSIStorageInterface::SXSIStorageInterface(int sf,bool iet,bool dtc)
15 {
16   tree = new XMLTree();
17   tree->OpenDocument(iet,sf,dtc);
18 }
19
20 SXSIStorageInterface::~SXSIStorageInterface()
21 {
22 }
23
24 void SXSIStorageInterface::newChild(string name)
25
26   _new_child++;
27   tree->NewOpenTag((unsigned char*) name.c_str());
28 }
29
30
31 void SXSIStorageInterface::newText(string text)
32 {
33
34   if (text.empty()) {
35     _new_empty_text++;
36     tree->NewEmptyText();
37   }
38   else {
39     _new_text++;
40     _length_text += text.size();
41     tree->NewText((unsigned char*) text.c_str());  
42   }
43 }
44
45
46 void SXSIStorageInterface::nodeFinished(string name)
47 {  
48   tree->NewClosingTag((unsigned char*) name.c_str());
49
50 }             
51               
52   void SXSIStorageInterface::parsingFinished()
53 {
54
55   tree->CloseDocument();
56         
57 }
58
59 void *SXSIStorageInterface::returnDocument(){
60 #ifdef DEBUG
61   printStats();
62 #endif
63   return ((void *) tree);
64   
65 }
66
67 void SXSIStorageInterface::printStats(){
68   std::cerr << "Parsing stats :  \n";
69   std::cerr << _new_child << " calls to newOpenTag/newClosingTag\n";
70   std::cerr << _new_text << " calls to newText\n";
71   std::cerr << _new_empty_text << " calls to newEmptyText\n";
72   std::cerr << _length_text << " bytes (=" << _length_text/1024 << "kb ) added to TextCollection\n";
73   return;
74 }