X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=SXSIStorageInterface.cpp;h=0a1a715eb0f4d736a03537e3c2cee44b31c6f19e;hb=451e60ad59e35344dff62da5ca27fcd5eec1bff9;hp=5df826bd3e3aaf68e3083c650ab917c662e5ec6f;hpb=496df5f7d3e6f8271763314f2067719cc2904c71;p=SXSI%2Fxpathcomp.git diff --git a/SXSIStorageInterface.cpp b/SXSIStorageInterface.cpp index 5df826b..0a1a715 100644 --- a/SXSIStorageInterface.cpp +++ b/SXSIStorageInterface.cpp @@ -11,11 +11,11 @@ #include "SXSIStorageInterface.h" #include "Utils.h" - -SXSIStorageInterface::SXSIStorageInterface() +SXSIStorageInterface::SXSIStorageInterface(int sf,bool iet,bool dtc) { - tree = new XMLTree(); - tree->OpenDocument(true,64); + tree = NULL; + tb = new XMLTreeBuilder(); + tb ->OpenDocument(iet,sf,dtc); } SXSIStorageInterface::~SXSIStorageInterface() @@ -24,33 +24,52 @@ SXSIStorageInterface::~SXSIStorageInterface() void SXSIStorageInterface::newChild(string name) { - tree->NewOpenTag((unsigned char*) name.c_str()); + _new_child++; + tb->NewOpenTag((unsigned char*) name.c_str()); } void SXSIStorageInterface::newText(string text) { - if (text.empty()) - tree->NewEmptyText(); - else - tree->NewText((unsigned char*) text.c_str()); + + if (text.empty()) { + _new_empty_text++; + tb->NewEmptyText(); + } + else { + _new_text++; + _length_text += text.size(); + tb->NewText((unsigned char*) text.c_str()); + } } - void SXSIStorageInterface::nodeFinished(string name) { - tree->NewClosingTag((unsigned char*) name.c_str()); - } + tb->NewClosingTag((unsigned char*) name.c_str()); + +} void SXSIStorageInterface::parsingFinished() { - tree->CloseDocument(); + + tree = tb->CloseDocument(); } void *SXSIStorageInterface::returnDocument(){ - +#ifdef DEBUG + printStats(); +#endif return ((void *) tree); } + +void SXSIStorageInterface::printStats(){ + std::cerr << "Parsing stats : \n"; + std::cerr << _new_child << " calls to newOpenTag/newClosingTag\n"; + std::cerr << _new_text << " calls to newText\n"; + std::cerr << _new_empty_text << " calls to newEmptyText\n"; + std::cerr << _length_text << " bytes (=" << _length_text/1024 << "kb ) added to TextCollection\n"; + return; +}