XBinder XML Runtime  XBinder Version 3.0.x
rtSaxCppParserIF.h
1 /*
2  * Copyright (c) 2003-2022 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
24 
25 #ifndef __RTSAXCPPPARSERIF_H_
26 #define __RTSAXCPPPARSERIF_H_
27 
28 #include "rtxsrc/rtxErrCodes.h"
29 #include "rtxsrc/OSRTInputStreamIF.h"
30 #include "rtxmlsrc/osrtxml.h"
31 #include "rtxmlsrc/rtSaxDefs.h"
32 
33 
34 class EXTXMLCLASS OSXMLErrorInfo {
35  public:
36  virtual ~OSXMLErrorInfo () {}
37  virtual void resetErrorInfo () = 0;
38  virtual void setErrorInfo (int status, const char* file = 0, int line = 0) = 0;
39  virtual int getErrorInfo (int* status, const char** file, int* line) = 0;
40 };
41 
42 class EXTERNXML OSXMLErrorHandler
43 {
44  public:
45  virtual ~OSXMLErrorHandler () {}
46 
61  virtual void warning() = 0;
62 
79  virtual void error() = 0;
80 
95  virtual void fatalError() = 0;
96 
104  virtual void resetErrors() = 0;
106 };
107 
112 class EXTERNXML OSXMLContentHandler
113 {
114  public:
115  virtual ~OSXMLContentHandler() {}
116 
133  virtual int characters
134  (
135  const OSUTF8CHAR* const chars,
136  unsigned int length
137  ) = 0;
138 
151  virtual int endElement
152  (
153  const OSUTF8CHAR* const uri,
154  const OSUTF8CHAR* const localname,
155  const OSUTF8CHAR* const qname
156  ) = 0;
157 
175  virtual int startElement
176  (
177  const OSUTF8CHAR* const uri,
178  const OSUTF8CHAR* const localname,
179  const OSUTF8CHAR* const qname,
180  const OSUTF8CHAR* const* attrs
181  ) = 0;
182 
184 };
185 
186 class EXTXMLCLASS OSXMLBase {
187 protected:
188  OSXMLBase () {}
189 
190  virtual ~OSXMLBase () {}
191 public:
192  virtual void release () = 0;
193 };
194 
195 #define DECLARE_XMLBASEIMP \
196 public: void release () { delete this; }
197 
198 class EXTERNXML OSXMLReaderClass : public OSXMLBase
199 {
200  public:
201 
202  virtual int parse () = 0;
219  virtual int parse (OSRTInputStreamIF& source) = 0;
220 
227  virtual int parse
228  (
229  const char* const pBuffer,
230  size_t bufSize
231  ) = 0;
232 
247  virtual int parse
248  (
249  const char* const systemId
250  ) = 0;
251 };
252 
260 class EXTERNXML OSXMLDefaultHandlerIF :
261  public OSXMLContentHandler, public OSXMLErrorInfo
262 {
263  public:
264  virtual ~OSXMLDefaultHandlerIF () {}
265 #if 0
266  // These are already defined in OSXMLContentHandler
267  virtual int startElement
268  (const OSUTF8CHAR* const uri,
269  const OSUTF8CHAR* const localname,
270  const OSUTF8CHAR* const qname,
271  const OSUTF8CHAR* const* attrs) = 0;
272 
273  virtual int characters
274  (const OSUTF8CHAR* const chars, unsigned int length) = 0;
275 
276  virtual int endElement
277  (const OSUTF8CHAR* const uri,
278  const OSUTF8CHAR* const localname,
279  const OSUTF8CHAR* const qname) = 0;
280 #endif
281  virtual void startDocument() = 0;
282  virtual void endDocument () = 0;
283 
284  virtual int finalize () = 0;
285 } ;
286 
287 class EXTXMLCLASS OSXMLParserCtxtIF {
288  public:
289  virtual ~OSXMLParserCtxtIF () {}
290  virtual OSRTInputStreamIF* createInputStream () = 0;
291  virtual OSRTInputStreamIF* createFileInputStream
292  (const char* const filename) = 0;
293  virtual OSRTInputStreamIF* createMemoryInputStream
294  (OSOCTET* pMemBuf, size_t bufSize) = 0;
295  virtual OSCTXT* getContext () = 0;
296  virtual const OSUTF8CHAR* parseQName (const OSUTF8CHAR* const qname) = 0;
297 };
298 
299 #ifdef __cplusplus
300 extern "C" {
301 #endif
302 
310 OSXMLReaderClass* rtSaxCppCreateXmlReader
311 (OSXMLParserCtxtIF* pContext, OSXMLDefaultHandlerIF* pSaxHandler);
312 
318 int rtSaxCppEnableThreadSafety ();
319 
330 void rtSaxCppLockXmlLibrary ();
331 
337 void rtSaxCppUnlockXmlLibrary ();
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 #endif /* __RTSAXCPPPARSERIF_H_ */
344 
This class is derived from the SAX class DefaultHandler base class.
XML low-level C encode/decode functions.
Receive notification of general document events.