Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

xmltokenizer.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil c-basic-offset: 3 -*- */
00002 // vim:cindent:ts=3:sw=3:et:tw=80:sta:
00003 /*************************************************************** cppdom-cpr beg
00004  * 
00005  * cppdom was forked from the original xmlpp version 0.6 under the LGPL. This
00006  * new, branched xmlpp is under the same LGPL (of course) and is being
00007  * maintained by:
00008  *      Kevin Meinert   <subatomic@users.sourceforge.net>
00009  *      Allen Bierbaum  <allenb@users.sourceforge.net>
00010  *      Ben Scott       <nonchocoboy@users.sourceforge.net>
00011  *
00012  * -----------------------------------------------------------------
00013  *
00014  * xmlpp - an xml parser and validator written in C++
00015  * copyright (c) 2000-2001 Michael Fink
00016  *
00017  * This library is free software; you can redistribute it and/or
00018  * modify it under the terms of the GNU Library General Public
00019  * License as published by the Free Software Foundation; either
00020  * version 2 of the License, or (at your option) any later version.
00021  *
00022  * This library is distributed in the hope that it will be useful,
00023  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00024  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00025  * Library General Public License for more details.
00026  *
00027  * You should have received a copy of the GNU Library General Public
00028  * License along with this library; if not, write to the
00029  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00030  * Boston, MA 02111-1307, USA.
00031  *
00032  * -----------------------------------------------------------------
00033  * File:          $RCSfile: xmltokenizer.h,v $
00034  * Date modified: $Date: 2003/01/03 02:37:47 $
00035  * Version:       $Revision: 1.12 $
00036  * -----------------------------------------------------------------
00037  *
00038  ************************************************************ cppdom-cpr-end */
00045 // prevent multiple includes
00046 #ifndef CPPDOM_XML_TOKENIZER_H
00047 #define CPPDOM_XML_TOKENIZER_H
00048 
00049 // needed includes
00050 #include <string>
00051 #include <stack>
00052 #include <iosfwd>
00053 
00054 
00055 // namespace declaration
00056 namespace cppdom
00057 {
00059 
00061    class XMLToken
00062    {
00063       friend class xmlstream_iterator;
00064    public:
00065       XMLToken();
00066       XMLToken(char ch);
00067       XMLToken(const std::string& str);
00068 
00070       bool isLiteral() const;
00071 
00073       bool isEndOfStream() const;
00074 
00076       char getLiteral() const;
00077 
00079       const std::string& getGeneric() const;
00080 
00081       // operators
00082 
00084       bool operator==(char ch) const;
00085 
00087       bool operator!=(char ch) const;
00088 
00090       bool operator==(const std::string& str) const;
00091 
00093       bool operator!=(const std::string& str) const;
00094 
00096       XMLToken& operator=(const std::string& str);
00097 
00099       XMLToken& operator=(char ch);
00100 
00101    protected:
00103       bool mIsLiteral;
00104 
00106       char mLiteral;
00107 
00109       std::string mGeneric;
00110    };
00111 
00112 
00114 
00115    class XMLTokenizer
00116    {
00117    public:
00119       XMLTokenizer(std::istream& in, XMLLocation& loc);
00120       virtual ~XMLTokenizer();
00121 
00123       XMLToken& operator*();
00124 
00126       const XMLToken* operator->();
00127 
00129       XMLTokenizer& operator++();
00130 
00132       XMLTokenizer& operator++(int);
00133 
00135       XMLToken& get();
00136 
00138       void putBack(XMLToken& token);
00139 
00141       void putBack();
00142 
00143    protected:
00145       virtual void getNext() = 0;
00146 
00147       // data members
00148 
00150       std::istream& mInput;
00151 
00153       XMLLocation& mLocation;
00154 
00156       XMLToken mCurToken;
00157 
00159       std::stack<XMLToken> mTokenStack;
00160    };
00161 
00166    class xmlstream_iterator : public XMLTokenizer
00167    {
00168    public:
00170       xmlstream_iterator(std::istream& in, XMLLocation& loc);
00171 
00172    protected:
00173       void getNext();
00174 
00175       // internally used to recognize chars in the stream
00176       bool isLiteral(char c);
00177       bool isWhiteSpace(char c);
00178       bool isNewLine(char c);
00179       bool isStringDelimiter(char c); // start-/endchar of a string
00180 
00182       bool mCdataMode;
00183 
00185       char mPutbackChar;
00186    };
00187 
00192    class xmldtd_iterator: public XMLTokenizer
00193    {
00194    public:
00196       xmldtd_iterator(std::istream& in, XMLLocation& loc);
00197 
00198    protected:
00199       void getNext(){}
00200    };
00201 }
00202 
00203 #endif

Generated on Thu Jan 2 21:29:17 2003 for cppdom by doxygen1.2.15