ulxr_xmlparse_base.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                     ulxr_xmlparse_base.h  -  parse xml files
00003                              -------------------
00004     begin                : Fri Jan 09 2004
00005     copyright            : (C) 2002-2007 by Ewald Arnold
00006     email                : ulxmlrpcpp@ewald-arnold.de
00007 
00008     $Id: ulxr_xmlparse_base.h 940 2006-12-30 18:22:05Z ewald-arnold $
00009 
00010  ***************************************************************************/
00011 
00012 /**************************************************************************
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU Lesser General Public License as
00016  * published by the Free Software Foundation; either version 2 of the License,
00017  * or (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00027  *
00028  ***************************************************************************/
00029 
00030 #ifndef ULXR_XMLPARSE_BASE
00031 #define ULXR_XMLPARSE_BASE
00032 
00033 #ifdef HAVE_XMLPARSE_H
00034 #include <xmlparse.h>
00035 #else
00036 #include <expat.h>
00037 #undef  XMLPARSEAPI
00038 #define XMLPARSEAPI
00039 #endif
00040 
00041 #include <ulxmlrpcpp/ulxmlrpcpp.h>  // always first header
00042 
00043 #include <stack>
00044 
00045 
00046 namespace ulxr {
00047 
00048 
00052 class ULXR_API_DECL0 XmlParserBase
00053 {
00054  public:
00055 
00058    XmlParserBase();
00059 
00063    virtual ~XmlParserBase();
00064 
00069    bool isComplete() const;
00070 
00074    void setComplete(bool comp);
00075 
00082    virtual int parse(const char* buffer, int len, int isFinal) = 0;
00083 
00087    virtual unsigned getErrorCode() const = 0;
00088 
00093    virtual CppString getErrorString(unsigned code) const = 0;
00094 
00100    virtual int getCurrentLineNumber() const = 0;
00101 
00106    virtual int mapToFaultCode(int xpatcode) const = 0;
00107 
00108    enum State
00109    {
00110      eNone,               
00111      eUnknown,            
00112      eXmlParserLast       
00113    };
00114 
00117   class ULXR_API_DECL0 ParserState
00118   {
00119    public:
00120 
00124      ParserState (unsigned st);
00125 
00128      virtual ~ParserState();
00129 
00133      unsigned getParserState() const;
00134 
00138      unsigned getPrevParserState() const;
00139 
00143      void setPrevParserState(unsigned prev);
00144 
00149      virtual CppString getStateName() const;
00150 
00156      void appendCharData(const XML_Char *s, int len);
00157 
00162      void appendCharData(const std::string &s);
00163 
00167      CppString getCharData() const;
00168 
00169    private:
00170 
00171      ParserState(const ParserState&); // forbid this
00172      ParserState& operator= (const ParserState&);
00173 
00174      CppString  cdata;
00175      unsigned   state;
00176      unsigned   prevstate;
00177   };
00178 
00179  protected:
00180 
00183    void clearStates();
00184 
00185  protected:
00186 
00187    std::stack<ParserState*>  states;
00188 
00189  private:
00190 
00191    bool complete;
00192 };
00193 
00194 
00195 }  // namespace ulxr
00196 
00197 
00198 #endif // ULXR_XMLPARSE_BASE

Generated on Sun Aug 19 20:08:58 2007 for ulxmlrpcpp by  doxygen 1.5.1