Home > Support > Documentation

rtXmlCppXSDElement.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2003-2006 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  *****************************************************************************/
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