TOC PREV NEXT INDEX


C++ Code Generated for XSD Types


For C++, a class definition is generated for each XSD type. This class is derived from either the OSRTBaseType run-time class or from a descendent of this class. The class may contain a constructor for initialization of member variables and a destructor to free dynamic memory held by the class. Method declarations will also be generated instead of C function prototypes for encoding, decoding, printing, and generation of test data. For some types, additional helper methods may also be declared (for example, enumerated type definitions contain a toString method declaration).
A sample section from a C++ header file corresponding to the XSD Name type defined above is as follows:

/**************************************************************/
 
/*                                                            */
 
/*  Name                                                      */
 
/*                                                            */
 
/**************************************************************/
 

 
class EXTERN Name : public OSXSDComplexType {
 
public:
 
   OSXMLStringClass givenName;
 
   OSXMLStringClass initial;
 
   OSXMLStringClass familyName;
 

 
   Name ();
 
   Name (const Name&);
 

 
   virtual int encodeXML (OSRTMessageBufferIF& msgbuf, 
 
      const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix);
 

 
   virtual int decodeXML (OSCTXT* pctxt);
 

 
   static int validateXML (OSCTXT* pctxt);
 

 
   virtual void print (const char* name);
 

 
   OSRTBaseType* clone () const {
 
      return new Name (*this);
 
   }
 

 
   Name& operator= (const Name&);
 

 
} ;
 

 
If you compare this to what was generated for C above, you will notice that all of the items are now encapsulated within a class definition. This includes the element declarations as well as the functions which are now methods in the class.

Copyright © Objective Systems 2002-2008
This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included.

Objective Systems, Inc.

55 Dowlin Forge Road
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com

TOC PREV NEXT INDEX