Home > Support > Documentation

rtSaxCppParserIF.h

00001 /*
00002  * Copyright (c) 2003-2007 Objective Systems, Inc.
00003  *
00004  * This software is furnished under a license and may be used and copied
00005  * only in accordance with the terms of such license and with the
00006  * inclusion of the above copyright notice. This software or any other
00007  * copies thereof may not be provided or otherwise made available to any
00008  * other person. No title to and ownership of the software is hereby
00009  * transferred.
00010  *
00011  * The information in this software is subject to change without notice
00012  * and should not be construed as a commitment by Objective Systems, Inc.
00013  *
00014  * PROPRIETARY NOTICE
00015  *
00016  * This software is an unpublished work subject to a confidentiality agreement
00017  * and is protected by copyright and trade secret law.  Unauthorized copying,
00018  * redistribution or other use of this work is prohibited.
00019  *
00020  * The above notice of copyright on this source code product does not indicate
00021  * any actual or intended publication of such source code.
00022  *
00023  *****************************************************************************/
00024 
00025 #ifndef __RTSAXCPPPARSERIF_H_
00026 #define __RTSAXCPPPARSERIF_H_
00027 
00028 #include <string.h>
00029 #include <stdlib.h>
00030 
00031 #include "rtxsrc/rtxErrCodes.h"
00032 #include "rtxsrc/OSRTInputStreamIF.h"
00033 #include "rtxmlsrc/osrtxml.h"
00034 #include "rtxmlsrc/rtSaxDefs.h"
00035 
00036 
00037 class EXTERNXML OSXMLErrorInfo {
00038  public:
00039    virtual ~OSXMLErrorInfo () {}
00040    virtual void resetErrorInfo () = 0;
00041    virtual void setErrorInfo (int status, const char* file = 0, int line = 0) = 0;
00042    virtual int  getErrorInfo (int* status, const char** file, int* line) = 0;
00043 };
00044 
00045 class EXTERNXML OSXMLErrorHandler
00046 {
00047  public:
00048     virtual ~OSXMLErrorHandler () {}
00049 
00064    virtual void warning() = 0;
00065 
00082    virtual void error() = 0;
00083 
00098    virtual void fatalError() = 0;
00099    
00107    virtual void resetErrors() = 0;
00109 };
00110 
00115 class EXTERNXML OSXMLContentHandler
00116 {
00117  public:
00118    virtual ~OSXMLContentHandler() {}
00119 
00136    virtual int characters
00137    (
00138        const OSUTF8CHAR* const chars,
00139        unsigned int      length
00140    ) = 0;
00141 
00154    virtual int endElement
00155    (
00156       const OSUTF8CHAR* const uri, 
00157       const OSUTF8CHAR* const localname, 
00158       const OSUTF8CHAR* const qname
00159    ) = 0;
00160 
00178    virtual int startElement
00179    (
00180       const   OSUTF8CHAR* const  uri,
00181       const   OSUTF8CHAR* const  localname,
00182       const   OSUTF8CHAR* const  qname,
00183       const   OSUTF8CHAR* const* attrs
00184    ) = 0;
00185 
00187 };
00188 
00189 class EXTERNXML OSXMLBase {
00190 protected:
00191    OSXMLBase () {}
00192 
00193    virtual ~OSXMLBase () {}
00194 public:
00195    virtual void release () = 0;
00196 };
00197 
00198 #define DECLARE_XMLBASEIMP \
00199 public: void release () { delete this; }
00200 
00201 class EXTERNXML OSXMLReaderClass : public OSXMLBase
00202 {
00203  public:
00204 
00205    virtual int parse () = 0;
00222    virtual int parse (OSRTInputStreamIF& source) = 0;
00223 
00230    virtual int parse
00231    (
00232       const char* const pBuffer,
00233       size_t            bufSize
00234    ) = 0;
00235 
00250    virtual int parse
00251    (
00252        const char* const systemId
00253    ) = 0;
00254 };
00255 
00263 class EXTERNXML OSXMLDefaultHandlerIF : 
00264    public OSXMLContentHandler, public OSXMLErrorInfo
00265 {
00266  public:
00267    virtual ~OSXMLDefaultHandlerIF () {}
00268 #if 0
00269    // These are already defined in OSXMLContentHandler
00270    virtual int startElement 
00271       (const OSUTF8CHAR* const uri, 
00272        const OSUTF8CHAR* const localname, 
00273        const OSUTF8CHAR* const qname, 
00274        const OSUTF8CHAR* const* attrs) = 0;
00275 
00276    virtual int characters 
00277       (const OSUTF8CHAR* const chars, unsigned int length) = 0;
00278 
00279    virtual int endElement
00280       (const OSUTF8CHAR* const uri,
00281        const OSUTF8CHAR* const localname,
00282        const OSUTF8CHAR* const qname) = 0;
00283 #endif
00284    virtual void startDocument() = 0;
00285    virtual void endDocument () = 0;
00286 
00287    virtual int finalize () = 0;
00288 } ;
00289 
00290 class EXTERNXML OSXMLParserCtxtIF {
00291  public:
00292    virtual ~OSXMLParserCtxtIF () {}
00293    virtual OSRTInputStreamIF* createInputStream () = 0;
00294    virtual OSRTInputStreamIF* createFileInputStream 
00295       (const char* const filename) = 0;
00296    virtual OSRTInputStreamIF* createMemoryInputStream 
00297       (OSOCTET* pMemBuf, size_t bufSize) = 0;
00298    virtual OSCTXT* getContext () = 0;
00299    virtual const OSUTF8CHAR* parseQName (const OSUTF8CHAR* const qname) = 0;
00300 };
00301 
00302 #ifdef __cplusplus
00303 extern "C" {
00304 #endif
00305 
00313 OSXMLReaderClass* rtSaxCppCreateXmlReader 
00314 (OSXMLParserCtxtIF* pContext, OSXMLDefaultHandlerIF* pSaxHandler);
00315 
00321 int rtSaxCppEnableThreadSafety ();
00322 
00333 void rtSaxCppLockXmlLibrary ();
00334 
00340 void rtSaxCppUnlockXmlLibrary ();
00341 
00342 #ifdef __cplusplus
00343 }
00344 #endif
00345 
00346 #endif /* __RTSAXCPPPARSERIF_H_ */