[xsd-users] Purpose of as_double?

Boris Kolpackov boris at codesynthesis.com
Mon Apr 4 06:49:19 EDT 2011


Hi Ray,

Ray Lischner <rlischner at proteuseng.com> writes:

> Using Code Synthesis 3.3.0, I am puzzled as to the purpose of 
> xsd::cxx::tree::as_double<>, in serialization.hxx.

There are two built-in types in XML Schema, xs:double and xs:decimal,
that are naturally mapped to C++ double (that's the default mapping).
However, the lexical representation of these types is very different:
xs:double can be stored in scientific or standard notations and can
contain special values such as inf, nan, etc. On the other hand,
xs:decimal can only be written in the standard notation and does not
support special values. Since these two types are often mapped to the
same C++ type, the as_double/as_decimal wrappers are used to distinguish
between the two cases.


> Everything in double.hxx take as_double<double> as arguments, so if
> I customize the implementation of double, I need to reimplement all
> of the functions in double.hxx, anyway.

No, all you need to do is implement parsing and serialization functions.
See the 'custom/double' example for details.

Boris



More information about the xsd-users mailing list