Home > Support > Documentation

rtXmlCppMsgBuf.h

Go to the documentation of this file.
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  *****************************************************************************/
00027 #ifndef _RTXMLCPPMSGBUF_H_
00028 #define _RTXMLCPPMSGBUF_H_
00029 
00030 #include "rtxsrc/OSRTMsgBuf.h"
00031 #include "rtxsrc/OSRTInputStream.h"
00032 #include "rtxsrc/OSRTOutputStream.h"
00033 #include "rtxmlsrc/osrtxml.h"
00034 #include "rtxmlsrc/rtSaxCppParser.h"
00035 
00044 class EXTERNXML OSXMLMessageBuffer : public OSRTMessageBuffer {
00045  protected:
00055    OSXMLMessageBuffer (Type bufferType, OSRTContext* pContext = 0);
00056 
00057  public:
00062    virtual void* getAppInfo ();
00063 
00070    int getIndent ();
00071 
00079    int getIndentChar ();
00080    
00090    virtual void setNamespace 
00091       (const OSUTF8CHAR* prefix, const OSUTF8CHAR* uri);
00092 
00100    virtual void setAppInfo (void* pXMLInfo);
00101 
00114    void setFormatting (OSBOOL doFormatting);
00115 
00121    void setIndent (OSUINT8 indent);
00122 
00128    void setIndentChar (char indentChar);
00129 
00130 } ;
00131 
00137 class EXTERNXML OSXMLEncodeBuffer : public OSXMLMessageBuffer {
00138  protected:
00139    OSXMLEncodeBuffer (OSRTContext* pContext) : 
00140       OSXMLMessageBuffer (XMLEncode, pContext) {}
00141  public:
00145    OSXMLEncodeBuffer ();
00146 
00157    OSXMLEncodeBuffer (OSOCTET* pMsgBuf, size_t msgBufLen);
00158 
00165    virtual size_t getMsgLen () { 
00166       return getByteIndex();
00167    }
00168 
00176    virtual int init ();
00177 
00193    virtual OSBOOL isA (int bufferType) {
00194       return bufferType == XMLEncode;
00195    }
00196 
00207    virtual long write (const char* filename);
00208 
00220    virtual long write (FILE* fp);
00221 } ;
00222 
00229 class EXTERNXML OSXMLEncodeStream : public OSXMLMessageBuffer {
00230  protected:
00232    OSRTOutputStream* mpStream;
00235    OSBOOL mbOwnStream;
00236  public:
00244    OSXMLEncodeStream (OSRTOutputStream& outputStream);
00245 
00255    OSXMLEncodeStream (OSRTOutputStream* pOutputStream, 
00256                       OSBOOL ownStream = TRUE);
00257 
00258    ~OSXMLEncodeStream ();
00259 
00275    virtual OSBOOL isA (int bufferType) {
00276       return bufferType == XMLEncode;
00277    }
00278 
00285    virtual const OSOCTET* getMsgPtr () { return 0; }
00286 } ;
00287 
00298 class EXTERNXML OSXMLDecodeBuffer : public OSXMLMessageBuffer {
00299  protected:
00302    union {
00303       const char* fileName;
00304       OSRTInputStream* pInputStream;
00305       struct {
00306          const OSOCTET* pMemBuf;
00307          size_t         bufSize;
00308       } memBuf;
00309    } mInput;
00310    
00313    enum {
00314       INPUT_FILE,
00315       INPUT_STREAM,
00316       INPUT_STREAM_ATTACHED,
00317       INPUT_MEMORY
00318    } mInputId;
00319 
00320    void initContextData ();
00321  public:
00322 
00329    OSXMLDecodeBuffer (const char* xmlFile);
00330 
00338    OSXMLDecodeBuffer (const OSOCTET* msgbuf, size_t bufsiz);
00339 
00347    OSXMLDecodeBuffer (OSRTInputStream& inputStream);
00348 
00349    ~OSXMLDecodeBuffer ();
00350 
00363    int decodeXML (OSXMLReaderClass* pReader);
00364 
00372    virtual int init ();
00373 
00385    int parseElementName (OSUTF8CHAR** ppName);
00386 
00398    int parseElemQName (OSXMLQName* pQName);
00399 
00407    OSUINT32 setMaxErrors (OSUINT32 maxErrors);
00408 
00415    inline const char* getXmlFileName() { 
00416       return (mInputId == INPUT_FILE) ? mInput.fileName : 0; 
00417    }
00418 
00435    virtual OSBOOL isA (int bufferType) {
00436       return bufferType == XMLDecode;
00437    }
00438 
00439 } ;
00440 
00441 #endif