Initial commit
[SXSI/xpathcomp.git] / XMLDocShredder.h
1 /**************************************
2  * XMLDocShredder.h
3  * --------------------
4  * Header file for the shredder routine that invokes the XML parser and 
5  * calls the appropriate construction methods of the storage interface in
6  * correspondence with received parsing events.
7  * 
8  * Author: Greg Leighton
9  * Date: 02/11/08
10  */
11
12 #ifndef XMLDOCSHREDDER_H_
13 #define XMLDOCSHREDDER_H_
14
15 #include <libxml++/libxml++.h>
16 #include <libxml++/parsers/textreader.h>
17 #include <string>
18 #include <unordered_map>
19 #include "StorageInterface.h"
20
21 using namespace std;
22 using namespace xmlpp;
23 /* For Hashmap. Seems fairly well supported */
24 using namespace __gnu_cxx; 
25
26 typedef pair<int,string> cons_str;
27 typedef pair<string,int> cons_int;
28
29 class XMLDocShredder
30 {
31 public:
32         XMLDocShredder(const string inFileName);
33         XMLDocShredder(const unsigned char * data, TextReader::size_type size);
34         virtual ~XMLDocShredder();
35         virtual void processStartElement();
36         virtual void processEndElement();
37         virtual void processPCDATA();
38         virtual void processAttributes();
39         virtual void processSignificantWhitespace();
40         virtual void processStartDocument(const string docName);
41         virtual void processEndDocument();
42         virtual void processComment();
43         virtual void processProcessingInstruction();
44         virtual void processDocTypeDeclaration();
45         virtual void processUnknownNodeType();
46         virtual void processCDATASection();
47         virtual void parse();
48         virtual int tagID(string);
49         virtual string idTag(int);
50         
51         StorageInterface *storageIfc_;
52
53         
54 private:
55         TextReader *reader_;
56         void setProperties();
57         unordered_map<int,string> idTags_;
58         unordered_map<string,int> tagsID_;
59 };
60
61 #endif /*XMLDOCSHREDDER_H_*/