ucommon/xml.h

Go to the documentation of this file.
00001 // Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
00002 //
00003 // This file is part of GNU uCommon C++.
00004 //
00005 // GNU uCommon C++ is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published
00007 // by the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // GNU uCommon C++ is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.
00017 
00023 #ifndef _UCOMMON_STRING_H_
00024 #include <ucommon/string.h>
00025 #endif
00026 
00027 #ifndef _UCOMMON_PROTOCOLS_H_
00028 #include <ucommon/protocols.h>
00029 #endif
00030 
00031 #ifndef _UCOMMON_XML_H_
00032 #define _UCOMMON_XML_H_
00033 
00034 NAMESPACE_UCOMMON
00035 
00047 class __EXPORT XMLParser
00048 {
00049 private:
00050     int ecount, dcount;
00051     enum {TAG, CDATA, COMMENT, DTD, AMP, NONE, END} state;
00052     char *buffer;
00053     unsigned bufpos, bufsize;
00054     __LOCAL bool parseTag(void);
00055     __LOCAL void putBuffer(char c);
00056     __LOCAL void clearBuffer(void);
00057 
00058 protected:
00063     XMLParser(unsigned size = 8192);
00064 
00068     virtual ~XMLParser();
00069 
00075     virtual void comment(caddr_t text, size_t size);
00076 
00082     virtual void characters(caddr_t text, size_t size);
00083 
00087     virtual void startDocument(void);
00088 
00092     virtual void endDocument(void);
00093 
00099     virtual void startElement(caddr_t name, caddr_t *attr) = 0;
00100 
00105     virtual void endElement(caddr_t name) = 0;
00106 
00116     bool partial(const char *address, size_t size);
00117 
00127     bool parse(CharacterProtocol& stream);
00128 
00138     bool parse(FILE *file);
00139 
00144     bool end(void)
00145         {return state == END;};
00146 };
00147 
00148 END_NAMESPACE
00149 
00150 #endif

Generated on 14 Aug 2013 for UCommon by  doxygen 1.4.7