Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

SAXParser.hpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           SAXParser.hpp  -  description
00003                              -------------------
00004     begin                : Fri Apr 11 2003
00005     copyright            : (C) 2003 by Tim Hawes
00006     email                : thawes@althusius.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 /*
00019  * Unhappy with other SAX Parsers for C++, I am writing my own
00020  * implementation.
00021  */
00022 
00023 #ifndef SAXPARSER_HPP
00024 #define SAXPARSER_HPP
00025 
00026 #include <iostream>
00027 #include <vector>
00028 #include <map>
00029 #include <string>
00030 #include <sstream>
00031 #include <stack>
00032 
00033 typedef std::map<std::string,std::string> Attributes_t;
00034 
00035 class SAXParser
00036   {
00037     private:
00038       // Data
00042       std::stack<int> isComment;
00043 
00044       // Functions
00048       inline std::string whiteSpace(std::string& str);
00049       inline std::string whiteSpace(char* str);
00050 
00054       inline char SAXParser::uppercase(const char &c);
00055 
00059       bool match_nocase(std::string &s1, std::string &s2);
00060 
00061     protected:
00068       bool variable_replacement;
00069 
00070     public:
00071       SAXParser();
00072       void Init(const char* file);
00073       void Init(std::ostringstream &osstr);
00074       virtual ~SAXParser();
00075 
00076       void parse(std::istream& istr);
00077       void parse(std::ostringstream& osstr);
00078       void parse(std::string& str);
00079 
00088       virtual void print_tag(std::string tag);
00089 
00094       virtual void characters
00095         (
00096           const std::string& name,
00097           const std::string& chars
00098         );
00099 
00105       virtual void startElement
00106         (
00107           const std::string& name,
00108           Attributes_t& attr,
00109           bool standalone = false
00110         );
00111 
00116       virtual void endElement(const std::string& name,
00117                               bool standalone = false);
00118 
00119       /*
00120        * Returns the attributes within a tag in the
00121        * form of map<string,string> typedefed as "Attributes_t".
00122        */
00123       Attributes_t tokens(const std::string& s);
00124       
00125       virtual void processingInstruction
00126         (
00127           std::string& tag,
00128           Attributes_t& attr
00129         );
00130   };
00131 
00132 #endif // SAXPARSER_HPP
00133 

Generated on Mon Jul 21 20:05:31 2003 for HTMLTemplate by doxygen1.2.18