00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00041 #ifndef _RTXMLCPPXSDELEMENT_H_
00042 #define _RTXMLCPPXSDELEMENT_H_
00043
00044 #include "rtxsrc/OSRTContext.h"
00045 #include "rtxsrc/OSRTMsgBufIF.h"
00046 #include "rtxsrc/rtxDiag.h"
00047 #include "rtxsrc/rtxErrCodes.h"
00048 #include "rtxmlsrc/osrtxml.h"
00049
00057 class EXTERNXML OSXSDGlobalElement {
00058 protected:
00065 OSRTCtxtPtr mpContext;
00066
00071 OSRTMessageBufferIF* mpMsgBuf;
00072
00077 OSXSDGlobalElement () : mpContext (new OSRTContext()), mpMsgBuf (0) {}
00078
00085 OSXSDGlobalElement (OSRTContext& ctxt) : mpContext (&ctxt), mpMsgBuf (0) {}
00086
00093 void setMsgBuf (OSRTMessageBufferIF& msgBuf);
00094
00095 public:
00105 OSXSDGlobalElement (OSRTMessageBufferIF& msgBuf) : mpMsgBuf(&msgBuf) {
00106 mpContext = msgBuf.getContext();
00107 }
00108
00116 OSXSDGlobalElement (const OSXSDGlobalElement& o) :
00117 mpContext (o.mpContext), mpMsgBuf (o.mpMsgBuf) { }
00118
00123 virtual ~OSXSDGlobalElement () {}
00124
00129 inline int decode () { return decodeFrom (*mpMsgBuf); }
00130
00138 virtual int decodeFrom (OSRTMessageBufferIF&) { return 0; }
00139
00144 inline int encode () { return encodeTo (*mpMsgBuf); }
00145
00153 virtual int encodeTo (OSRTMessageBufferIF&) { return 0; }
00154
00159 inline OSCTXT* getCtxtPtr () {
00160 return (!mpContext.isNull ()) ? mpContext->getPtr() : 0;
00161 }
00162
00172 inline void* memAlloc (size_t numocts) {
00173 return rtxMemAlloc (getCtxtPtr(), numocts);
00174 }
00175
00176 #if 0
00177
00187 inline void* memRealloc (void* ptr, size_t oldnumocts, size_t numocts) {
00188 return rtxMemRealloc (getCtxtPtr(), ptr, oldnumocts, numocts);
00189 }
00190 #endif
00191
00200 inline void memFreePtr (void* ptr) {
00201 rtxMemFreePtr (getCtxtPtr(), ptr);
00202 }
00203
00210 inline void setDefaultNamespace (const OSUTF8CHAR* uri) {
00211 setNamespace (0, uri);
00212 }
00213
00219 inline void setDiag (OSBOOL value = TRUE) {
00220 rtxSetDiag (getCtxtPtr(), value);
00221 }
00222
00229 inline void setEncXSINamespace (OSBOOL value = TRUE) {
00230 rtXmlSetEncXSINamespace (getCtxtPtr(), value);
00231 }
00232
00240 inline void setNamespace (const OSUTF8CHAR* prefix, const OSUTF8CHAR* uri) {
00241 mpMsgBuf->setNamespace (prefix, uri);
00242 }
00243
00250 inline void setNoNSSchemaLocation (const OSUTF8CHAR* uri) {
00251 rtXmlSetNoNSSchemaLocation (mpContext->getPtr(), uri);
00252 }
00253
00260 inline void setSchemaLocation (const OSUTF8CHAR* uri) {
00261 rtXmlSetSchemaLocation (mpContext->getPtr(), uri);
00262 }
00263
00270 inline void setXSIType (const OSUTF8CHAR* typeName) {
00271 rtXmlSetXSITypeAttr (mpContext->getPtr(), typeName);
00272 }
00273
00278 inline int validate () { return validateFrom (*mpMsgBuf); }
00279
00287 virtual int validateFrom (OSRTMessageBufferIF&)
00288 { return RTERR_NOTSUPP; }
00289 } ;
00290
00291 #endif