[xsd-users] XSD_CXX_TREE_DECIMAL_FIXED functionality.

jimson.james at intellitix.com jimson.james at intellitix.com
Fri Mar 15 01:33:41 EDT 2019


Guys,

 

Any simple way to ensure the 'decimal' presion is kept even when the decimal
is 0.00?

Right now I have patched the decimal serialization like below.

 

        template <typename C>

        std::basic_string<C>

        insert (const as_decimal<double>& d)

        {

          std::basic_ostringstream<C> os;

          os.imbue (std::locale::classic ());

          std::streamsize prec;

 

          const facet* f = d.facets ?

            facet::find (d.facets, facet::fraction_digits) : 0;

 

...

         // Remove the trailing zeros and the decimal point if necessary.

          //

          typename std::basic_string<C>::size_type size (r.size ()), n
(size);

 

          if (prec != 0)

          {

            for (; n > 0 && cr[n - 1] == '0'; --n)/*noop*/;

 

            if (n > 0 && cr[n - 1] == '.')

#if defined(XSD_CXX_TREE_DECIMAL_FIXED)

            n+=2;

#else

            --n;

#endif

 

...

 

 

Is it fair to fix it like this, or do I really need to use the customized
type functionality?

Thx



 



More information about the xsd-users mailing list