PdbMlParserHandler.h

Go to the documentation of this file.
00001 //  File:        PdbMlParserHandler.h
00002 //  Updated:     Oct 13, 2005 J. Westbrook
00003 //
00004 //  Skeleton PdbMl parser example class...  
00005 //
00006 //
00007 
00008 
00009 #ifndef PDBML_PARSER_HANDLER_H
00010 #define PDBML_PARSER_HANDLER_H
00011 
00012 
00013 #include <vector>
00014 #include <map>
00015 
00016 #include <sax2/DefaultHandler.hpp>
00017 #include <sax2/Attributes.hpp>
00018 
00019 #include "TableFile.h"
00020 
00021 
00022 using namespace std;
00023 XERCES_CPP_NAMESPACE_USE
00024 
00025 
00026 static const string ELEMENT_DATABLOCK      = "datablock";
00027 static const string ATTRIBUTE_DATABLOCK    = "datablockName";
00028 static const string TABLE_CONTAINER_SUFFIX = "Category";
00029 
00030 
00031 class PdbMlParserHandler : public DefaultHandler
00032 {
00033 
00034   public:
00035     PdbMlParserHandler(TableFile& tableFile);
00036 
00037     ~PdbMlParserHandler();
00038 
00039     void startElement(const XMLCh *const uri,
00040                       const XMLCh *const localname,
00041                       const XMLCh *const qname,
00042                       const Attributes& attrs);
00043 
00044     void endElement(const XMLCh *const uri, 
00045                     const XMLCh *const localname, 
00046                     const XMLCh *const qname);
00047 
00048     void characters(const XMLCh *const chars,
00049                     const unsigned int length);
00050 
00051     void warning(const SAXParseException& exception);
00052     void error(const SAXParseException& exception);
00053     void fatalError(const SAXParseException& exception);
00054 
00055     void printState(const string& element);
00056 
00057   private:
00058     bool _inDataBlock;
00059     bool _inTable;
00060     bool _inRow;
00061     bool _inCell;
00062 
00063     std::vector<string> _currRowNames;
00064     std::vector<string> _currRowValues;
00065     int _currRowIndex;
00066 
00067     string _currCellName;
00068     string _currBlockName;
00069 
00070     TableFile& _tableFile;
00071     ISTable* _isTableP;
00072     // VLAD IMPROVE: THINK OF STORING THE KEY COLUMN INDICES IN THE
00073     // ISTABLE OBJECT, BUT LEAVING THE OPTION NOT TO CREATE THE INDEX
00074     // EVEN IF KEY IS SPECIFIED
00075     vector<string> _keyColNames;
00076 
00077     void Clear();
00078 
00079     void _GetAttributes(const Attributes& attrs);
00080     string _GetDataBlockName(const Attributes& attrs);
00081     string _ExtractTableName(const string& tableContName);
00082 
00083     void _SaveRow();
00084     void _SaveTable();
00085 
00086     void _ErrMessage(const string& err, const string& element);
00087 
00088 };
00089 
00090 // Note that the above semicolon after the closing curly brace is a must,
00091 // otherwise the code will not compile. This is probably due to the Xerces
00092 // macro XERCES_CPP_NAMESPACE_USE that indicates using Xerces namespace.
00093 
00094 
00095 #endif

Generated on Tue Apr 3 09:40:32 2007 for pdbml-parser-v2.0 by  doxygen 1.5.1