rtXmlCppXSDElement.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
00028 #ifndef _RTXMLCPPXSDELEMENT_H_
00029 #define _RTXMLCPPXSDELEMENT_H_
00030
00031 #include "rtxsrc/OSRTContext.h"
00032 #include "rtxsrc/OSRTMsgBufIF.h"
00033 #include "rtxsrc/rtxDiag.h"
00034 #include "rtxsrc/rtxErrCodes.h"
00035 #include "rtxmlsrc/osrtxml.h"
00036
00044 class EXTERNXML OSXSDGlobalElement {
00045 protected:
00052 OSRTCtxtPtr mpContext;
00053
00058 OSRTMessageBufferIF* mpMsgBuf;
00059
00064 OSXSDGlobalElement () : mpContext (new OSRTContext()), mpMsgBuf (0) {}
00065
00072 OSXSDGlobalElement (OSRTContext& ctxt) : mpContext (&ctxt), mpMsgBuf (0) {}
00073
00080 void setMsgBuf (OSRTMessageBufferIF& msgBuf);
00081
00082 public:
00092 OSXSDGlobalElement (OSRTMessageBufferIF& msgBuf) : mpMsgBuf(&msgBuf) {
00093 mpContext = msgBuf.getContext();
00094 }
00095
00103 OSXSDGlobalElement (const OSXSDGlobalElement& o) :
00104 mpContext (o.mpContext), mpMsgBuf (o.mpMsgBuf) { }
00105
00110 virtual ~OSXSDGlobalElement () {}
00111
00116 inline int decode () { return decodeFrom (*mpMsgBuf); }
00117
00125 virtual int decodeFrom (OSRTMessageBufferIF&) { return 0; }
00126
00131 inline int encode () { return encodeTo (*mpMsgBuf); }
00132
00140 virtual int encodeTo (OSRTMessageBufferIF&) { return 0; }
00141
00146 inline OSCTXT* getCtxtPtr () {
00147 return (!mpContext.isNull ()) ? mpContext->getPtr() : 0;
00148 }
00149
00159 inline void* memAlloc (size_t numocts) {
00160 return rtxMemAlloc (getCtxtPtr(), numocts);
00161 }
00162
00163 #if 0
00164
00174 inline void* memRealloc (void* ptr, size_t oldnumocts, size_t numocts) {
00175 return rtxMemRealloc (getCtxtPtr(), ptr, oldnumocts, numocts);
00176 }
00177 #endif
00178
00187 inline void memFreePtr (void* ptr) {
00188 rtxMemFreePtr (getCtxtPtr(), ptr);
00189 }
00190
00197 inline void setDefaultNamespace (const OSUTF8CHAR* uri) {
00198 setNamespace (0, uri);
00199 }
00200
00206 inline void setDiag (OSBOOL value = TRUE) {
00207 rtxSetDiag (getCtxtPtr(), value);
00208 }
00209
00217 inline void setNamespace (const OSUTF8CHAR* prefix, const OSUTF8CHAR* uri) {
00218 mpMsgBuf->setNamespace (prefix, uri);
00219 }
00220
00227 inline void setXSIType (const OSUTF8CHAR* typeName) {
00228 rtXmlSetXSITypeAttr (mpContext->getPtr(), typeName);
00229 }
00230
00235 inline int validate () { return validateFrom (*mpMsgBuf); }
00236
00244 virtual int validateFrom (OSRTMessageBufferIF&)
00245 { return RTERR_NOTSUPP; }
00246 } ;
00247
00248 #endif