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 OSBaseType 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 OSBaseType {
 
public:
 
   OSXMLStringClass givenName;
 
   OSXMLStringClass initial;
 
   OSXMLStringClass familyName;
 

 
   int encodeXML (OSCTXT* pctxt, 
 
      const OSUTF8CHAR* elemName, const OSUTF8CHAR* nsPrefix);
 

 
   void print (const char* 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 and well as the functions which are now methods in the class.

Objective Systems, Inc.

102 Pickering Way, Suite #506
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