TOC PREV NEXT INDEX


C++ Example


The C++ code generated for the example schema above is as follows:

class AOrBOrBothType_1 : public OSBaseType {
 
public:
 
   struct {
 
      unsigned bPresent : 1;
 
   } m;
 
   OSXMLStringClass a;
 
   OSXMLStringClass b;
 

 
   ...
 
} ;
 

 
class AOrBOrBothType : public OSBaseType {
 
public:
 
   // tag constants
 
   enum {
 
      T__seq1 = 1,
 
      T_b = 2
 
   } ;
 
   OSUINT16 t;
 
   union {
 
      /* t = 1 */
 
      AOrBOrBothType_1 *_seq1;
 
      /* t = 2 */
 
      OSXMLStringClass *b;
 
   } u;
 

 
   ...
 

 
   inline AOrBOrBothType_1* get__seq1 () {
 
      return u._seq1;
 
   }
 
   inline OSBOOL is__seq1 () {
 
      return (t == T__seq1);
 
   }
 
   void set__seq1 (const AOrBOrBothType_1& value);
 

 
   inline OSXMLStringClass* get_b () {
 
      return u.b;
 
   }
 
   inline OSBOOL is_b () {
 
      return (t == T_b);
 
   }
 
   void set_b (const OSXMLStringClass& value);
 
} ;
 

 
This shows the generated get/set methods as well as the generated member variables in the class. If the user wanted to set the class to the nested sequence value, the set__seq1 method could be used. If the user wanted to determine if the b element was selected in the class and then get the value, the following code snippet could be used (object is assumed to be an instance of the AOrBOrBothType class):

	if (object.is_b()) {
 
	   OSXMLStringClass* value = object.get_b();
 
	}
 


Copyright © Objective Systems 2002-2005
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.
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