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 
00066     string _currCellName;
00067     string _currBlockName;
00068 
00069     TableFile& _tableFile;
00070     ISTable* _isTableP;
00071     // VLAD IMPROVE: THINK OF STORING THE KEY COLUMN INDICES IN THE
00072     // ISTABLE OBJECT, BUT LEAVING THE OPTION NOT TO CREATE THE INDEX
00073     // EVEN IF KEY IS SPECIFIED
00074     vector<string> _keyColNames;
00075 
00076     void Clear();
00077 
00078     void _GetAttributes(const Attributes& attrs);
00079     string _GetDataBlockName(const Attributes& attrs);
00080     string _ExtractTableName(const string& tableContName);
00081 
00082     void _SaveRow();
00083     void _SaveTable();
00084 
00085     void _ErrMessage(const string& err, const string& element);
00086 
00087 };
00088 
00089 // Note that the above semicolon after the closing curly brace is a must,
00090 // otherwise the code will not compile. This is probably due to the Xerces
00091 // macro XERCES_CPP_NAMESPACE_USE that indicates using Xerces namespace.
00092 
00093 
00094 #endif

Generated on Fri Feb 8 11:23:07 2008 for pdbml-parser-v2.0 by  doxygen 1.5.1