librcsb-core-wrapper  1.005
PdbMlParserHandler.h
Go to the documentation of this file.
1 // File: PdbMlParserHandler.h
2 // Updated: Oct 13, 2005 J. Westbrook
3 //
4 // Skeleton PdbMl parser example class...
5 //
6 //
7 
8 
9 #ifndef PDBML_PARSER_HANDLER_H
10 #define PDBML_PARSER_HANDLER_H
11 
12 
13 #include <vector>
14 #include <map>
15 
16 #include <xercesc/sax2/DefaultHandler.hpp>
17 #include <xercesc/sax2/Attributes.hpp>
18 
19 #include <rcsb/TableFile.h>
20 
21 
22 XERCES_CPP_NAMESPACE_USE
23 
24 
25 static const string ELEMENT_DATABLOCK = "datablock";
26 static const string ATTRIBUTE_DATABLOCK = "datablockName";
27 static const string TABLE_CONTAINER_SUFFIX = "Category";
28 
29 
30 class PdbMlParserHandler : public DefaultHandler
31 {
32 
33  public:
35 
37 
38  void startElement(const XMLCh *const uri,
39  const XMLCh *const localname,
40  const XMLCh *const qname,
41  const Attributes& attrs);
42 
43  void endElement(const XMLCh *const uri,
44  const XMLCh *const localname,
45  const XMLCh *const qname);
46 
47 #if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR == 8 && XERCES_VERSION_REVISION == 0
48  void characters(const XMLCh *const chars,
49  const unsigned int length);
50 #else
51  void characters(const XMLCh *const chars,
52  const XMLSize_t length);
53 #endif
54 
55  void warning(const SAXParseException& exception);
56  void error(const SAXParseException& exception);
57  void fatalError(const SAXParseException& exception);
58 
59  void printState(const string& element);
60 
61  private:
62  bool _inDataBlock;
63  bool _inTable;
64  bool _inRow;
65  bool _inCell;
66 
67  std::vector<string> _currRowNames;
68  std::vector<string> _currRowValues;
69 
70  string _currCellName;
71  string _currBlockName;
72 
73  TableFile& _tableFile;
74  ISTable* _isTableP;
75  // VLAD IMPROVE: THINK OF STORING THE KEY COLUMN INDICES IN THE
76  // ISTABLE OBJECT, BUT LEAVING THE OPTION NOT TO CREATE THE INDEX
77  // EVEN IF KEY IS SPECIFIED
78  vector<string> _keyColNames;
79 
80  void Clear();
81 
82  void _GetAttributes(const Attributes& attrs);
83  string _GetDataBlockName(const Attributes& attrs);
84  string _ExtractTableName(const string& tableContName);
85 
86  void _SaveRow();
87  void _SaveTable();
88 
89  void _ErrMessage(const string& err, const string& element);
90 
91 };
92 
93 // Note that the above semicolon after the closing curly brace is a must,
94 // otherwise the code will not compile. This is probably due to the Xerces
95 // macro XERCES_CPP_NAMESPACE_USE that indicates using Xerces namespace.
96 
97 
98 #endif
static const string ATTRIBUTE_DATABLOCK
Definition: PdbMlParserHandler.h:26
static XERCES_CPP_NAMESPACE_USE const string ELEMENT_DATABLOCK
Definition: PdbMlParserHandler.h:25
static const string TABLE_CONTAINER_SUFFIX
Definition: PdbMlParserHandler.h:27
Header file for Block and TableFile classes.
Public class that respresents a two-dimensional table of strings.
Definition: ISTable.h:54
Definition: PdbMlParserHandler.h:31
void printState(const string &element)
void error(const SAXParseException &exception)
void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
PdbMlParserHandler(TableFile &tableFile)
void fatalError(const SAXParseException &exception)
void startElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname, const Attributes &attrs)
void warning(const SAXParseException &exception)
void characters(const XMLCh *const chars, const XMLSize_t length)
Public class that represents a file composed of blocks with tables.
Definition: TableFile.h:362