C++ Code Generated for XSD Types

For C++, a class definition is generated for each XSD type. This class is derived from either the OSRTBaseTyperun-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 toStringmethod 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.