rtXmlCppXSDElement.h

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