librcsb-core-wrapper  1.000
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:
34  PdbMlParserHandler(TableFile& tableFile);
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  void characters(const XMLCh *const chars,
48  const unsigned int length);
49 
50  void warning(const SAXParseException& exception);
51  void error(const SAXParseException& exception);
52  void fatalError(const SAXParseException& exception);
53 
54  void printState(const string& element);
55 
56  private:
57  bool _inDataBlock;
58  bool _inTable;
59  bool _inRow;
60  bool _inCell;
61 
62  std::vector<string> _currRowNames;
63  std::vector<string> _currRowValues;
64 
65  string _currCellName;
66  string _currBlockName;
67 
68  TableFile& _tableFile;
69  ISTable* _isTableP;
70  // VLAD IMPROVE: THINK OF STORING THE KEY COLUMN INDICES IN THE
71  // ISTABLE OBJECT, BUT LEAVING THE OPTION NOT TO CREATE THE INDEX
72  // EVEN IF KEY IS SPECIFIED
73  vector<string> _keyColNames;
74 
75  void Clear();
76 
77  void _GetAttributes(const Attributes& attrs);
78  string _GetDataBlockName(const Attributes& attrs);
79  string _ExtractTableName(const string& tableContName);
80 
81  void _SaveRow();
82  void _SaveTable();
83 
84  void _ErrMessage(const string& err, const string& element);
85 
86 };
87 
88 // Note that the above semicolon after the closing curly brace is a must,
89 // otherwise the code will not compile. This is probably due to the Xerces
90 // macro XERCES_CPP_NAMESPACE_USE that indicates using Xerces namespace.
91 
92 
93 #endif
void error(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 unsigned int length)
static const string TABLE_CONTAINER_SUFFIX
Definition: PdbMlParserHandler.h:27
Definition: PdbMlParserHandler.h:30
void endElement(const XMLCh *const uri, const XMLCh *const localname, const XMLCh *const qname)
static const string ATTRIBUTE_DATABLOCK
Definition: PdbMlParserHandler.h:26
void printState(const string &element)
static XERCES_CPP_NAMESPACE_USE const string ELEMENT_DATABLOCK
Definition: PdbMlParserHandler.h:25
Public class that represents a file composed of blocks with tables.
Definition: TableFile.h:361
Header file for Block and TableFile classes.
PdbMlParserHandler(TableFile &tableFile)
void fatalError(const SAXParseException &exception)
Public class that respresents a two-dimensional table of strings.
Definition: ISTable.h:53