UCommon
xml.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 //
3 // This file is part of GNU uCommon C++.
4 //
5 // GNU uCommon C++ is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // GNU uCommon C++ is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
17 
23 #ifndef _UCOMMON_STRING_H_
24 #include <ucommon/string.h>
25 #endif
26 
27 #ifndef _UCOMMON_PROTOCOLS_H_
28 #include <ucommon/protocols.h>
29 #endif
30 
31 #ifndef _UCOMMON_XML_H_
32 #define _UCOMMON_XML_H_
33 
34 namespace ucommon {
35 
47 class __EXPORT XMLParser
48 {
49 private:
50  int ecount, dcount;
51  enum {TAG, CDATA, COMMENT, DTD, AMP, NONE, END} state;
52  char *buffer;
53  unsigned bufpos, bufsize;
54  __LOCAL bool parseTag(void);
55  __LOCAL void putBuffer(char c);
56  __LOCAL void clearBuffer(void);
57 
58 protected:
63  XMLParser(unsigned size = 8192);
64 
68  virtual ~XMLParser();
69 
75  virtual void comment(caddr_t text, size_t size);
76 
82  virtual void characters(caddr_t text, size_t size);
83 
87  virtual void startDocument(void);
88 
92  virtual void endDocument(void);
93 
99  virtual void startElement(caddr_t name, caddr_t *attr) = 0;
100 
105  virtual void endElement(caddr_t name) = 0;
106 
116  bool partial(const char *address, size_t size);
117 
127  bool parse(CharacterProtocol& stream);
128 
138  bool parse(FILE *file);
139 
144  bool end(void) const
145  {return state == END;}
146 };
147 
148 } // namespace ucommon
149 
150 #endif
Abstract interfaces and support.
XML streaming parser.
Definition: xml.h:47
Common namespace for all ucommon objects.
Common character processing protocol.
Definition: protocols.h:174
bool end(void) const
End of document check.
Definition: xml.h:144
Access standard files through character protocol.
Definition: file.h:59
A common string class and character string support functions.