[xsd-users] serialize problems: thousands separator in gyear_month and unsigned long

Sibinger Peter Peter.Sibinger at cpg.de
Wed Feb 25 10:08:40 EST 2015


Hi All,

Today I had problems to serialize integer and long variables correctly.
E.g. in date-time.txx the values x.year=2014 and x.month=12 resulted in a stream "2.014-12".

The only solution I found was to add the classic "C" locale to get no thousands separator.
You'll find the added line below.

[date-time.txx]
_________________________________
...
      // gyear_month
      //
      namespace bits
      {
        template <typename C, typename B>
        void
        insert (std::basic_ostream<C>& os, const tree::gyear_month<C, B>& x)
        {
          if (x.month () < 13)
          {
            os.imbue (std::locale::classic ());  // without that you'll get thousands separator
            os.fill (C ('0'));
            os.width (4);
            os << x.year () << C ('-');
            os.width (2);
            os << x.month ();

            if (x.zone_present ())
              zone_insert (os, x);
          }
        }
      }
...
_________________________________

Unfortunately I run into the same problem for all integer and long variables in *.hxx, *.txx in tree/serialization.
For double, decimal and float variables the classic "C" locale is part of the header (e.g. in tree/serialization/decimal.hxx) for integer and long variables not.

I'm not sure whether there's another solution for that.

With kind regards
Peter




More information about the xsd-users mailing list