XBinder XML Runtime  XBinder Version 3.0.x
rtXmlCppXSDElement.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003-2017 Objective Systems, Inc.
3  *
4  * This software is furnished under a license and may be used and copied
5  * only in accordance with the terms of such license and with the
6  * inclusion of the above copyright notice. This software or any other
7  * copies thereof may not be provided or otherwise made available to any
8  * other person. No title to and ownership of the software is hereby
9  * transferred.
10  *
11  * The information in this software is subject to change without notice
12  * and should not be construed as a commitment by Objective Systems, Inc.
13  *
14  * PROPRIETARY NOTICE
15  *
16  * This software is an unpublished work subject to a confidentiality agreement
17  * and is protected by copyright and trade secret law. Unauthorized copying,
18  * redistribution or other use of this work is prohibited.
19  *
20  * The above notice of copyright on this source code product does not indicate
21  * any actual or intended publication of such source code.
22  *
23  *****************************************************************************/
41 #ifndef _RTXMLCPPXSDELEMENT_H_
42 #define _RTXMLCPPXSDELEMENT_H_
43 
44 #include "rtxsrc/OSRTContext.h"
45 #include "rtxsrc/OSRTMsgBufIF.h"
46 #include "rtxsrc/rtxDiag.h"
47 #include "rtxsrc/rtxErrCodes.h"
48 #include "rtxmlsrc/osrtxml.h"
49 
57 class EXTERNXML OSXSDGlobalElement {
58  protected:
65  OSRTCtxtPtr mpContext;
66 
71  OSRTMessageBufferIF* mpMsgBuf;
72 
77  OSXSDGlobalElement () : mpContext (new OSRTContext()), mpMsgBuf (0) {}
78 
85  OSXSDGlobalElement (OSRTContext& ctxt) : mpContext (&ctxt), mpMsgBuf (0) {}
86 
93  void setMsgBuf (OSRTMessageBufferIF& msgBuf);
94 
95  public:
105  OSXSDGlobalElement (OSRTMessageBufferIF& msgBuf) : mpMsgBuf(&msgBuf) {
106  mpContext = msgBuf.getContext();
107  }
108 
117  mpContext (o.mpContext), mpMsgBuf (o.mpMsgBuf) { }
118 
123  virtual ~OSXSDGlobalElement () {}
124 
129  inline int decode () { return decodeFrom (*mpMsgBuf); }
130 
138  virtual int decodeFrom (OSRTMessageBufferIF&) { return 0; }
139 
144  inline int encode () { return encodeTo (*mpMsgBuf); }
145 
153  virtual int encodeTo (OSRTMessageBufferIF&) { return 0; }
154 
159  inline OSCTXT* getCtxtPtr () {
160  return (!mpContext.isNull ()) ? mpContext->getPtr() : 0;
161  }
162 
172  inline void* memAlloc (size_t numocts) {
173  return rtxMemAlloc (getCtxtPtr(), numocts);
174  }
175 
176 #if 0
177 
187  inline void* memRealloc (void* ptr, size_t oldnumocts, size_t numocts) {
188  return rtxMemRealloc (getCtxtPtr(), ptr, oldnumocts, numocts);
189  }
190 #endif
191 
200  inline void memFreePtr (void* ptr) {
201  rtxMemFreePtr (getCtxtPtr(), ptr);
202  }
203 
210  inline void setDefaultNamespace (const OSUTF8CHAR* uri) {
211  setNamespace (0, uri);
212  }
213 
219  inline void setDiag (OSBOOL value = TRUE) {
220  rtxSetDiag (getCtxtPtr(), value);
221  }
222 
229  inline void setEncXSINamespace (OSBOOL value = TRUE) {
230  rtXmlSetEncXSINamespace (getCtxtPtr(), value);
231  }
232 
240  inline void setNamespace (const OSUTF8CHAR* prefix, const OSUTF8CHAR* uri) {
241  mpMsgBuf->setNamespace (prefix, uri);
242  }
243 
250  inline void setNoNSSchemaLocation (const OSUTF8CHAR* uri) {
251  rtXmlSetNoNSSchemaLocation (mpContext->getPtr(), uri);
252  }
253 
260  inline void setSchemaLocation (const OSUTF8CHAR* uri) {
261  rtXmlSetSchemaLocation (mpContext->getPtr(), uri);
262  }
263 
270  inline void setXSIType (const OSUTF8CHAR* typeName) {
271  rtXmlSetXSITypeAttr (mpContext->getPtr(), typeName);
272  }
273 
278  inline int validate () { return validateFrom (*mpMsgBuf); }
279 
287  virtual int validateFrom (OSRTMessageBufferIF&)
288  { return RTERR_NOTSUPP; }
289 } ;
290 
291 #endif
virtual ~OSXSDGlobalElement()
The virtual destructor does nothing.
EXTERNXML int rtXmlSetNoNSSchemaLocation(OSCTXT *pctxt, const OSUTF8CHAR *schemaLocation)
This function sets the XML Schema Instance (xsi) no namespace schema location attribute to be added t...
void setNamespace(const OSUTF8CHAR *prefix, const OSUTF8CHAR *uri)
The setNamespace method adds or modifies the namespace with the given URI in the namespace list to co...
virtual int decodeFrom(OSRTMessageBufferIF &)
The decodeFrom method decodes a message from the given message buffer or stream argument.
int validate()
The validate method validates the message described by the encapsulated message buffer object...
void setSchemaLocation(const OSUTF8CHAR *uri)
The setSchemaLocation method adds an xsi:schemaLocation attribute to the document.
void setXSIType(const OSUTF8CHAR *typeName)
The setXSIType method sets a type name to be used in the xsi:type attribute in the top-level module e...
OSRTCtxtPtr mpContext
The mpContext member variable holds a reference-counted C runtime variable.
void * memAlloc(size_t numocts)
The memAlloc method allocates memory using the C runtime memory management functions.
void memFreePtr(void *ptr)
The memFreePtr method frees the memory at a specific location.
EXTERNXML int rtXmlSetEncXSINamespace(OSCTXT *pctxt, OSBOOL value)
This function sets a flag in the context that indicates the XSI namespace declaration (xmlns:xsi) sho...
virtual int encodeTo(OSRTMessageBufferIF &)
The encodeTo method encodes a message into the given message buffer or stream argument.
virtual int validateFrom(OSRTMessageBufferIF &)
The validateFrom method validates a message from the given message buffer or stream argument...
void setDefaultNamespace(const OSUTF8CHAR *uri)
The setDefaultNamespace method sets the default namespace for the element to the given value...
void setEncXSINamespace(OSBOOL value=TRUE)
The setEncXSINamespace method sets a flag in the internal context that indicates the xsi namespace at...
void setNoNSSchemaLocation(const OSUTF8CHAR *uri)
The setNoNSSchemaLocation method adds an xsi:noNamespaceSchemaLocation attribute to the document...
OSCTXT * getCtxtPtr()
The getCtxtPtr method returns the underlying C runtime context.
XML low-level C encode/decode functions.
OSXSDGlobalElement(OSRTContext &ctxt)
This constructor sets the message pointer member variable to NULL and initializes the context object ...
EXTERNXML int rtXmlSetSchemaLocation(OSCTXT *pctxt, const OSUTF8CHAR *schemaLocation)
This function sets the XML Schema Instance (xsi) schema location attribute to be added to an encoded ...
OSXSDGlobalElement()
The default constructor sets the message pointer member variable to NULL and creates a new context ob...
int encode()
The encode method encodes a message using the encoding rules specified by the derived message buffer ...
OSXSDGlobalElement(const OSXSDGlobalElement &o)
The copy constructor sets the internal message buffer pointer and context to point at the message buf...
EXTERNXML int rtXmlSetXSITypeAttr(OSCTXT *pctxt, const OSUTF8CHAR *xsiType)
This function sets the XML Schema Instance (xsi) type attribute value.
XSD global element base class.
void setDiag(OSBOOL value=TRUE)
The setDiag method turns diagnostic tracing on or off.
OSRTMessageBufferIF * mpMsgBuf
The mpMsgBuf member variable is a pointer to a derived message buffer or stream class that will manag...
OSXSDGlobalElement(OSRTMessageBufferIF &msgBuf)
This constructor sets the internal message buffer pointer to point at the given message buffer or str...
int decode()
The decode method decodes the message described by the encapsulated message buffer object...