rtXmlCppMsgBuf.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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