From tessadriandrea at gmail.com Thu Mar 28 11:51:40 2019 From: tessadriandrea at gmail.com (Andrea Tessadri) Date: Fri Mar 29 10:25:13 2019 Subject: [xsde-users] SimpleType with restriction creates object with empty constructor Message-ID: For a schema containing a simpleType like this: The result of: xsde cxx-hybrid --generate-aggregate country.xsd will be country.hxx containing a structure like this one: class CountryCodeISO; // CountryCodeISO (fixed-length) // class CountryCodeISO: public ::std::string { public: CountryCodeISO (); }; In such case there is no way to create an object of type CountryCodeISO containing a string, since the only constructor available is the empty one. Version: xsde-3.2.0-x86_64-linux-gnu System: ubuntu 18.04 From boris at codesynthesis.com Fri Mar 29 11:01:22 2019 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Mar 29 11:19:04 2019 Subject: [xsde-users] SimpleType with restriction creates object with empty constructor In-Reply-To: References: Message-ID: Andrea Tessadri writes: > > > > > > > class CountryCodeISO: public ::std::string > { > public: > CountryCodeISO (); > }; > > In such case there is no way to create an object of type CountryCodeISO > containing a string, since the only constructor available is the empty one. In an effort to be minimal and to support usage without exceptions, XSD/e employs the "default-construct then assign" approach for initializing the object model. So you can do this: CountryCodeISO x; x = "ZA"; Or: x.assign ("ZA"); If you would like to use a more modern approach with proper constructors, then you may want to consider using XSD. From tessadriandrea at gmail.com Fri Mar 29 11:17:47 2019 From: tessadriandrea at gmail.com (Andrea Tessadri) Date: Mon Apr 1 09:46:46 2019 Subject: [xsde-users] SimpleType with restriction creates object with empty constructor In-Reply-To: References: Message-ID: Excellent! Thanks a lot, it works. On Fri, Mar 29, 2019 at 4:01 PM Boris Kolpackov wrote: > Andrea Tessadri writes: > > > > > > > > > > > > > > > class CountryCodeISO: public ::std::string > > { > > public: > > CountryCodeISO (); > > }; > > > > In such case there is no way to create an object of type CountryCodeISO > > containing a string, since the only constructor available is the empty > one. > > In an effort to be minimal and to support usage without exceptions, > XSD/e employs the "default-construct then assign" approach for > initializing the object model. So you can do this: > > CountryCodeISO x; > x = "ZA"; > > Or: > > x.assign ("ZA"); > > If you would like to use a more modern approach with proper constructors, > then you may want to consider using XSD. > From tessadriandrea at gmail.com Fri Mar 29 12:02:45 2019 From: tessadriandrea at gmail.com (Andrea Tessadri) Date: Mon Apr 1 09:46:46 2019 Subject: [xsde-users] Controlling double precision for xs:decimal In-Reply-To: References: Message-ID: For a schema containing a xs:decimal like this: The result of the serialization for: Latitude().base_value(-83.12345); will be: -83.123450000000005 How to control double precision ? Version: xsde-3.2.0-x86_64-linux-gnu System: ubuntu 18.04