Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75332 - in trunk/boost/chrono: . io io_v1
From: vicente.botet_at_[hidden]
Date: 2011-11-05 19:19:10


Author: viboes
Date: 2011-11-05 19:19:09 EDT (Sat, 05 Nov 2011)
New Revision: 75332
URL: http://svn.boost.org/trac/boost/changeset/75332

Log:
Chrono: cleanup io v2 version removing v1 parts.
Text files modified:
   trunk/boost/chrono/config.hpp | 2
   trunk/boost/chrono/io/duration_io.hpp | 770 ---------------------------------------
   trunk/boost/chrono/io/duration_units.hpp | 132 ------
   trunk/boost/chrono/io/time_point_io.hpp | 187 ---------
   trunk/boost/chrono/io/translate.hpp | 1
   trunk/boost/chrono/io_v1/chrono_io.hpp | 6
   6 files changed, 9 insertions(+), 1089 deletions(-)

Modified: trunk/boost/chrono/config.hpp
==============================================================================
--- trunk/boost/chrono/config.hpp (original)
+++ trunk/boost/chrono/config.hpp 2011-11-05 19:19:09 EDT (Sat, 05 Nov 2011)
@@ -96,8 +96,6 @@
 #define BOOST_CHRONO_USES_DURATION_PUT
 #define BOOST_CHRONO_USES_DURATION_GET
 //#define BOOST_CHRONO_USES_DURATION_UNITS_GLOBAL
-//#define BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
-//#define BOOST_CHRONO_IS_LOCALIZABLE_TRANSLATE
 
 // unicode support ------------------------------//
 

Modified: trunk/boost/chrono/io/duration_io.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_io.hpp (original)
+++ trunk/boost/chrono/io/duration_io.hpp 2011-11-05 19:19:09 EDT (Sat, 05 Nov 2011)
@@ -28,269 +28,6 @@
   namespace chrono
   {
 
- template <class CharT>
- class duration_punct: public std::locale::facet
- {
- public:
- typedef std::basic_string<CharT> string_type;
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- enum
- {
- use_long=duration_style::prefix, use_short=duration_style::symbol
- };
-#endif
-
- private:
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- duration_style::type style_;
-#endif
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- string_type long_seconds_;
- string_type long_minutes_;
- string_type long_hours_;
- string_type short_seconds_;
- string_type short_minutes_;
- string_type short_hours_;
-
- template<class Period>
- string_type short_name(Period) const
- {
- return ::boost::ratio_string<Period, CharT>::short_name() + short_seconds_;
- }
-
- string_type short_name(ratio<1> ) const
- {
- return short_seconds_;
- }
- string_type short_name(ratio<60> ) const
- {
- return short_minutes_;
- }
- string_type short_name(ratio<3600> ) const
- {
- return short_hours_;
- }
-
- template<class Period>
- string_type long_name(Period) const
- {
- return ::boost::ratio_string<Period, CharT>::long_name() + long_seconds_;
- }
-
- string_type long_name(ratio<1> ) const
- {
- return long_seconds_;
- }
- string_type long_name(ratio<60> ) const
- {
- return long_minutes_;
- }
- string_type long_name(ratio<3600> ) const
- {
- return long_hours_;
- }
-
- void init_C();
-#endif
-
- public:
- static std::locale::id id;
-
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- explicit duration_punct(
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- int use = duration_style::prefix,
-#endif
- size_t refs = 0) :
- std::locale::facet(refs)
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- , style_(duration_style::type(use))
-#endif
- {
- init_C();
- }
-
- duration_punct(
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- int use,
-#endif
- const string_type& long_seconds, const string_type& long_minutes, const string_type& long_hours, const string_type& short_seconds, const string_type& short_minutes, const string_type& short_hours, size_t refs =
- 0);
-
- duration_punct(
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- int use,
-#endif
- const duration_punct& d, size_t refs = 0);
-
-#else
- explicit duration_punct(
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- duration_style::type style= duration_style::prefix,
-#endif
- size_t refs = 0) :
- std::locale::facet(refs)
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- , style_(style)
-#endif
- {
- }
- duration_punct(
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- duration_style::type style,
-#endif
- const duration_punct&, size_t refs = 0) :
- std::locale::facet(refs)
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- , style_(style)
-#endif
- {
- }
-#endif
-
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- bool is_symbol() const BOOST_NOEXCEPT
- {
- return (style_==duration_style::symbol);
- }
- bool is_prefix() const BOOST_NOEXCEPT
- {
- return (style_==duration_style::prefix);
- }
- duration_style::type get_duration_style() const BOOST_NOEXCEPT
- {
- return style_;
- }
-#endif
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
-
- template<class Period>
- string_type short_name() const
- {
- return short_name(typename Period::type());
- }
-
- template<class Period>
- string_type long_name() const
- {
- return long_name(typename Period::type());
- }
-
- template<class Period>
- string_type name() const
- {
- if (is_symbol())
- return short_name<Period> ();
- else
- return long_name<Period> ();
- }
- template<class Rep, class Period>
- string_type name(duration<Rep, Period> const&) const
- {
- if (is_symbol())
- return short_name<Period> ();
- else
- return long_name<Period> ();
- }
-
- bool is_short_name() const
- {
- return is_symbol();
- }
- bool is_long_name() const
- {
- return is_prefix();
- }
-#endif
- };
-
- template <class CharT>
- std::locale::id duration_punct<CharT>::id;
-
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
-
- template<class CharT>
- void duration_punct<CharT>::init_C()
- {
- short_seconds_ = CharT('s');
- short_minutes_ = CharT('m');
- short_hours_ = CharT('h');
- const CharT s[] =
- { 's', 'e', 'c', 'o', 'n', 'd', 's'};
- const CharT m[] =
- { 'm', 'i', 'n', 'u', 't', 'e', 's'};
- const CharT h[] =
- { 'h', 'o', 'u', 'r', 's'};
- long_seconds_.assign(s, s + sizeof(s) / sizeof(s[0]));
- long_minutes_.assign(m, m + sizeof(m) / sizeof(m[0]));
- long_hours_.assign(h, h + sizeof(h) / sizeof(h[0]));
- }
-
- template<class CharT>
- duration_punct<CharT>::duration_punct(
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- int use,
-#endif
- const string_type& long_seconds, const string_type& long_minutes, const string_type& long_hours, const string_type& short_seconds, const string_type& short_minutes, const string_type& short_hours, size_t refs) :
- std::locale::facet(refs),
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- style_(duration_style::type(use)),
-#endif
- long_seconds_(long_seconds), long_minutes_(long_minutes),
- long_hours_(long_hours), short_seconds_(short_seconds),
- short_minutes_(short_minutes), short_hours_(short_hours)
- {
- }
-
- template<class CharT>
- duration_punct<CharT>::duration_punct(
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- int use,
-#endif
- const duration_punct& d, size_t refs) :
- std::locale::facet(refs),
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- style_(duration_style::type(use)),
-#endif
- long_seconds_(d.long_seconds_), long_minutes_(d.long_minutes_),
- long_hours_(d.long_hours_), short_seconds_(d.short_seconds_),
- short_minutes_(d.short_minutes_), short_hours_(d.short_hours_)
- {
- }
- template<class CharT, class Traits>
- std::basic_ostream<CharT, Traits>&
- duration_short(std::basic_ostream<CharT, Traits>& os)
- {
- typedef duration_punct<CharT> Facet;
- std::locale loc = os.getloc();
- if (std::has_facet<Facet>(loc))
- {
- const Facet& f = std::use_facet<Facet>(loc);
- if (f.is_prefix())
- os.imbue(std::locale(loc, new Facet(duration_style::symbol, f)));
- }
- else
- os.imbue(std::locale(loc, new Facet(duration_style::symbol)));
- return os;
- }
-
- template<class CharT, class Traits>
- std::basic_ostream<CharT, Traits>&
- duration_long(std::basic_ostream<CharT, Traits>& os)
- {
- typedef duration_punct<CharT> Facet;
- std::locale loc = os.getloc();
- if (std::has_facet<Facet>(loc))
- {
- const Facet& f = std::use_facet<Facet>(loc);
- if (f.is_symbol())
- os.imbue(std::locale(loc, new Facet(duration_style::prefix, f)));
- }
- return os;
- }
-#endif
-
-#if 1
     /**
      * duration parameterized manipulator.
      */
@@ -314,103 +51,9 @@
       void operator()(out_stream &ios) const
       //void operator()(std::ios_base &ios) const
       {
-#if defined BOOST_CHRONO_IO_USE_XALLOC
         set_duration_style(ios, style_);
-#else
- typedef duration_punct<typename out_stream::char_type > Facet;
- std::locale loc = ios.getloc();
- if (std::has_facet<Facet>(loc))
- {
- const Facet& f = std::use_facet<Facet>(loc);
- if (f.get_duration_style()!=style_)
- ios.imbue(std::locale(loc, new Facet(style_, f)));
- }
- else
- ios.imbue(std::locale(loc, new Facet(style_)));
-#endif
       }
     };
-#else
- /**
- * duration parameterized manipulator.
- */
- class duration_fmt
- {
- duration_style::type style_;
- public:
-
- /**
- * explicit manipulator constructor from a @c duration_style
- */
- explicit duration_fmt(duration_style::type style) BOOST_NOEXCEPT
- : style_(style)
- {}
-
-#ifndef BOOST_NO_EXPLICIT_CONVERSION_OPERATORS
- /**
- * explicit conversion to the @c duration_style scoped enum.
- */
- explicit
- operator duration_style::type() const BOOST_NOEXCEPT
- { return style_;}
-#endif
-
- /**
- * gets the @c duration_style scoped enum.
- */
- duration_style::type get_duration_style() const BOOST_NOEXCEPT
- { return style_;}
- };
-
- /**
- * Change the duration_punc facet associated to the output stream depending on the duration_format style parameter.
- */
- template <class CharT, class Traits>
- std::basic_ostream<CharT, Traits>&
- operator <<(std::basic_ostream<CharT, Traits>& os, duration_fmt d)
- {
-#if defined BOOST_CHRONO_IO_USE_XALLOC
- set_duration_style(os, d.get_duration_style());
-#else
- typedef duration_punct<CharT> Facet;
- std::locale loc = os.getloc();
- if (std::has_facet<Facet>(loc))
- {
- const Facet& f = std::use_facet<Facet>(loc);
- if (f.get_duration_style()!=d.get_duration_style())
- os.imbue(std::locale(loc, new Facet(d.get_duration_style(), f)));
- }
- else
- os.imbue(std::locale(loc, new Facet(d.get_duration_style())));
-#endif
- return os;
- }
- /**
- * Change the duration_punc facet associated to the input stream depending on the duration_format style parameter.
- */
- template <class CharT, class Traits>
- std::basic_istream<CharT, Traits>&
- operator >>(std::basic_istream<CharT, Traits>& is, duration_fmt d)
- {
-#if defined BOOST_CHRONO_IO_USE_XALLOC
- set_duration_style(is, d.get_duration_style());
-#else
- typedef duration_punct<CharT> Facet;
- std::locale loc = is.getloc();
- if (std::has_facet<Facet>(loc))
- {
- const Facet& f = std::use_facet<Facet>(loc);
- if (f.get_duration_style()!=d.get_duration_style())
- is.imbue(std::locale(loc, new Facet(d.get_duration_style(), f)));
- }
- else
- is.imbue(std::locale(loc, new Facet(d.get_duration_style())));
-#endif
- return is;
- }
-
-#endif
-
 
     /**
      * duration_style i/o saver.
@@ -434,18 +77,7 @@
       explicit duration_style_io_saver(state_type &s) :
         s_save_(s)
       {
-#if defined BOOST_CHRONO_IO_USE_XALLOC
         a_save_ = get_duration_style(s_save_);
-
-#else
- typedef duration_punct<CharT> Facet;
- std::locale loc = s_save_.getloc();
- if (!std::has_facet<Facet>(loc))
- s_save_.imbue(std::locale(loc, new Facet()));
-
- const Facet& f = std::use_facet<Facet>(s_save_.getloc());
- a_save_ = f.get_duration_style();
-#endif
       }
 
       /**
@@ -473,12 +105,9 @@
        */
       void restore()
       {
-#if defined BOOST_CHRONO_IO_USE_XALLOC
         set_duration_style(s_save_, a_save_);
-#else
- s_save_ << duration_fmt(a_save_);
-#endif
       }
+
     private:
       state_type& s_save_;
       aspect_type a_save_;
@@ -497,23 +126,10 @@
       typename std::basic_ostream<CharT, Traits>::sentry ok(os);
       if (ok)
       {
- typedef duration_punct<CharT> Facet;
         typedef std::basic_string<CharT, Traits> string_type;
-
         bool failed = false;
         try
         {
-#if defined BOOST_CHRONO_IO_USE_XALLOC
-
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- std::locale loc = os.getloc();
-
- if (!std::has_facet<Facet>(loc))
- os.imbue(std::locale(loc, new Facet));
- const Facet& f = std::use_facet<Facet>(os.getloc());
- return os << d.count() << ' ' << f.template name<Rep,Period>(d);
-#else
-#if defined BOOST_CHRONO_USES_DURATION_PUT
           std::ios_base::iostate err = std::ios_base::goodbit;
           try
           {
@@ -546,63 +162,16 @@
           }
           if (err) os.setstate(err);
           return os;
-
-#elif defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
- return os
- << to_basic_string<CharT> (get_duration_style(os), d, os.getloc());
-#elif defined BOOST_CHRONO_IS_LOCALIZABLE_TRANSLATE
-
- duration_style::type style = get_duration_style(os);
- if (ratio_string_is_localizable<Period>())
- {
- std::cout << __FILE__ << ":"<< __LINE__ << ": " << std::endl;
-
- return os << basic_format<CharT>(
- translated_duration_unit<CharT, Rep, Period>(os.getloc(), style==duration_style::prefix, d),
- os.getloc()
- )
- % d.count();
- }
- else
- {
- std::cout << __FILE__ << ":"<< __LINE__ << ": " << std::endl;
- return os << to_basic_string<CharT>(get_duration_style(os), d, os.getloc());
- return os << basic_format<CharT>(
- translated_duration_unit<CharT, ratio<1> >(os.getloc(), style==duration_style::prefix),
- os.getloc()
- )
- % d.count()
- % ratio_string<Period, CharT>::symbol();
- }
-#else
- return os << d.count() << ' ' << duration_unit<CharT>(os.getloc(), get_duration_style(os)==duration_style::prefix, d);
-#endif
-#endif
-#else
- std::locale loc = os.getloc();
-
- if (!std::has_facet<Facet>(loc))
- os.imbue(std::locale(loc, new Facet));
- const Facet& f = std::use_facet<Facet>(os.getloc());
-
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- return os << d.count() << ' ' << f.template name<Rep,Period>(d);
-#else
- return os << d.count() << ' ' << duration_unit<CharT>(os.getloc(), f.is_prefix(), d);
-#endif
-#endif
         }
         catch (...)
         {
           failed = true;
         }
         if (failed) os.setstate(std::ios_base::failbit | std::ios_base::badbit);
-
       }
       return os;
     }
 
-
     /**
      *
      * @param is the input stream
@@ -615,16 +184,6 @@
     {
       std::ios_base::iostate err = std::ios_base::goodbit;
 
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- typedef duration_punct<CharT> Facet;
- std::locale loc = is.getloc();
- if (!std::has_facet<Facet>(loc))
- is.imbue(std::locale(loc, new Facet));
- loc = is.getloc();
- const Facet& f = std::use_facet<Facet>(loc);
-#endif
-#if defined BOOST_CHRONO_USES_DURATION_GET
-
       try
       {
         typename std::basic_istream<CharT, Traits>::sentry ipfx(is);
@@ -637,8 +196,7 @@
           std::use_facet<duration_get<CharT> >(is.getloc())
           .get(is, std::istreambuf_iterator<CharT,Traits>() ,is, err, d);
         }
- } // try
-
+ }
       catch(...)
       {
         bool flag = false;
@@ -654,330 +212,6 @@
       }
       if ( err ) is.setstate(err);
       return is;
-
-#elif defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL2
-#elif defined BOOST_CHRONO_IS_LOCALIZABLE_TRANSLATE2
-#else
-
- typedef typename detail::duration_io_intermediate<Rep>::type intermediate_type;
- intermediate_type r;
- // read value into r
- is >> r;
- if (is.good())
- {
- // now determine unit
- typedef std::istreambuf_iterator<CharT, Traits> in_iterator;
- in_iterator i(is);
- in_iterator e;
- if (i != e && *i == ' ') // mandatory ' ' after value
-
- {
- ++i;
- if (i != e)
- {
- // unit is num / den (yet to be determined)
- unsigned long long num = 0;
- unsigned long long den = 0;
- if (*i == '[')
- {
- // parse [N/D]s or [N/D]seconds format
- ++i;
- CharT x;
- is >> num >> x >> den;
- if (!is.good() || (x != '/'))
- {
- is.setstate(is.failbit);
- return is;
- }
- i = in_iterator(is);
- if (*i != ']')
- {
- is.setstate(is.failbit);
- return is;
- }
- ++i;
- const std::basic_string<CharT> units[] =
- {
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- f.template long_name<ratio<1> >(),
- f.template short_name<ratio<1> >()
-#else
- duration_unit<CharT> (is.getloc(), true, seconds(2)),
- duration_unit<CharT> (is.getloc(), true, seconds(1)),
- duration_unit<CharT> (is.getloc(), false, seconds(1))
-#endif
- };
- std::ios_base::iostate err = std::ios_base::goodbit;
- const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e, units,
- units + sizeof (units) / sizeof (units[0]),
- //~ std::use_facet<std::ctype<CharT> >(loc),
- err);
- switch ( (k - units) / 3)
- {
- case 0:
- break;
- default:
- is.setstate(err);
- return is;
- }
- }
- else
- {
- // parse SI name, short or long
-
- const std::basic_string<CharT> units[] =
- {
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- f.template long_name<atto>(),
- f.template short_name<atto>(),
- f.template long_name<femto>(),
- f.template short_name<femto>(),
- f.template long_name<pico>(),
- f.template short_name<pico>(),
- f.template long_name<nano>(),
- f.template short_name<nano>(),
- f.template long_name<micro>(),
- f.template short_name<micro>(),
- f.template long_name<milli>(),
- f.template short_name<milli>(),
- f.template long_name<centi>(),
- f.template short_name<centi>(),
- f.template long_name<deci>(),
- f.template short_name<deci>(),
- f.template long_name<deca>(),
- f.template short_name<deca>(),
- f.template long_name<hecto>(),
- f.template short_name<hecto>(),
- f.template long_name<kilo>(),
- f.template short_name<kilo>(),
- f.template long_name<mega>(),
- f.template short_name<mega>(),
- f.template long_name<giga>(),
- f.template short_name<giga>(),
- f.template long_name<tera>(),
- f.template short_name<tera>(),
- f.template long_name<peta>(),
- f.template short_name<peta>(),
- f.template long_name<exa>(),
- f.template short_name<exa>(),
- f.template long_name<ratio<1> >(),
- f.template short_name<ratio<1> >(),
- f.template long_name<ratio<60> >(),
- f.template short_name<ratio<60> >(),
- f.template long_name<ratio<3600> >(),
- f.template short_name<ratio<3600> >()
-#else
- duration_unit<CharT> (is.getloc(), true, duration<Rep, atto> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, atto> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, atto> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, femto> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, femto> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, femto> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, pico> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, pico> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, pico> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, nano> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, nano> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, nano> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, micro> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, micro> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, micro> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, milli> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, milli> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, milli> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, centi> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, centi> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, centi> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, deci> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, deci> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, deci> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, deca> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, deca> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, deca> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, hecto> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, hecto> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, hecto> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, kilo> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, kilo> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, kilo> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, mega> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, mega> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, mega> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, giga> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, giga> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, giga> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, tera> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, tera> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, tera> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, peta> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, peta> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, peta> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, exa> (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, exa> (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, exa> (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<1> > (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<1> > (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, ratio<1> > (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<60> > (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<60> > (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, ratio<60> > (1)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<3600> > (2)),
- duration_unit<CharT> (is.getloc(), true, duration<Rep, ratio<3600> > (1)),
- duration_unit<CharT> (is.getloc(), false, duration<Rep, ratio<3600> > (1)),
-#endif
- };
- const std::basic_string<CharT>* k = chrono_detail::scan_keyword(i, e, units,
- units + sizeof (units) / sizeof (units[0]),
- //~ std::use_facet<std::ctype<CharT> >(loc),
- err);
-#if !defined BOOST_CHRONO_IO_V1_DONT_PROVIDE_DEPRECATED
- switch ((k - units) / 2)
-#else
- switch ( (k - units) / 3)
-#endif
- {
- case 0:
- num = 1ULL;
- den = 1000000000000000000ULL;
- break;
- case 1:
- num = 1ULL;
- den = 1000000000000000ULL;
- break;
- case 2:
- num = 1ULL;
- den = 1000000000000ULL;
- break;
- case 3:
- num = 1ULL;
- den = 1000000000ULL;
- break;
- case 4:
- num = 1ULL;
- den = 1000000ULL;
- break;
- case 5:
- num = 1ULL;
- den = 1000ULL;
- break;
- case 6:
- num = 1ULL;
- den = 100ULL;
- break;
- case 7:
- num = 1ULL;
- den = 10ULL;
- break;
- case 8:
- num = 10ULL;
- den = 1ULL;
- break;
- case 9:
- num = 100ULL;
- den = 1ULL;
- break;
- case 10:
- num = 1000ULL;
- den = 1ULL;
- break;
- case 11:
- num = 1000000ULL;
- den = 1ULL;
- break;
- case 12:
- num = 1000000000ULL;
- den = 1ULL;
- break;
- case 13:
- num = 1000000000000ULL;
- den = 1ULL;
- break;
- case 14:
- num = 1000000000000000ULL;
- den = 1ULL;
- break;
- case 15:
- num = 1000000000000000000ULL;
- den = 1ULL;
- break;
- case 16:
- num = 1;
- den = 1;
- break;
- case 17:
- num = 60;
- den = 1;
- break;
- case 18:
- num = 3600;
- den = 1;
- break;
- default:
- is.setstate(err);
- return is;
- }
- }
- // unit is num/den
- // r should be multiplied by (num/den) / Period
- // Reduce (num/den) / Period to lowest terms
- unsigned long long gcd_n1_n2 = math::gcd<unsigned long long>(num, Period::num);
- unsigned long long gcd_d1_d2 = math::gcd<unsigned long long>(den, Period::den);
- num /= gcd_n1_n2;
- den /= gcd_d1_d2;
- unsigned long long n2 = Period::num / gcd_n1_n2;
- unsigned long long d2 = Period::den / gcd_d1_d2;
- if (num > (std::numeric_limits<unsigned long long>::max)() / d2 || den > (std::numeric_limits<
- unsigned long long>::max)() / n2)
- {
- // (num/den) / Period overflows
- is.setstate(is.failbit);
- return is;
- }
- num *= d2;
- den *= n2;
- // num / den is now factor to multiply by r
- typedef typename common_type<intermediate_type, unsigned long long>::type common_type_t;
- if (!detail::reduce(r, den, err)) {
- is.setstate(is.failbit);
- return is;
- }
-
- if (r > ( (duration_values<common_type_t>::max)() / num))
- {
- // Conversion to Period overflowed
- is.setstate(is.failbit);
- return is;
- }
- common_type_t t = r * num;
- t /= den;
- if (t > 0)
- {
- Rep pt = t;
- if ( (duration_values<Rep>::max)() < pt)
- {
- // Conversion to Period overflowed
- is.setstate(is.failbit);
- return is;
- }
- }
- // Success! Store it.
- r = Rep(t);
- d = duration<Rep, Period> (r);
- if (i == e) is.setstate(is.eofbit);
- }
- else
- is.setstate(is.failbit | is.eofbit);
- }
- else
- {
- if (i == e) is.setstate(is.eofbit);
- is.setstate(is.failbit);
- }
- }
- else
- is.setstate(is.failbit);
-#endif
- return is;
     }
 
   } // chrono

Modified: trunk/boost/chrono/io/duration_units.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_units.hpp (original)
+++ trunk/boost/chrono/io/duration_units.hpp 2011-11-05 19:19:09 EDT (Sat, 05 Nov 2011)
@@ -875,138 +875,6 @@
 
 #endif
 
-#if defined BOOST_CHRONO_IS_LOCALIZABLE_VIRTUAL
-
- template <typename CharT, typename T>
- std::basic_string<CharT> to_basic_string(T const&v, std::locale const &loc)
- {
- std::basic_ostringstream<CharT> os;
- os.imbue(loc);
- os << v;
- return os.str();
- }
-
- template <typename CharT, typename Rep, typename Period>
- typename enable_if<is_localizable<Period>, std::basic_string<CharT> >::type
- to_basic_string(
- duration_style_type style,
- duration<Rep,Period> value,
- std::locale const &loc
- )
- {
- std::locale nloc;
- if (!std::has_facet<duration_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new duration_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
-
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, Period(), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, Period(), int_least64_t(value.count()));
- }
- }
-
- template <typename CharT, typename Rep, typename Period>
- typename disable_if<is_localizable<Period> , std::basic_string<CharT> >::type
- to_basic_string(
- duration_style_type style,
- duration<Rep,Period> value,
- std::locale const& loc
- )
- {
- std::locale nloc;
- if (!std::has_facet<duration_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new duration_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, detail::rt_ratio(Period()), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, detail::rt_ratio(Period()), int_least64_t(value.count()));
- }
- }
-
- template <typename CharT, typename Rep, typename Period>
- typename enable_if<is_localizable<Period>, std::basic_string<CharT> >::type
- to_basic_string(
- duration_style_type style,
- duration<process_times<Rep>,Period> value,
- std::locale const &loc
- )
- {
- std::locale nloc;
- if (!std::has_facet<duration_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new duration_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
-
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, nano(), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, nano(), int_least64_t(value.count()));
- }
- }
-
- template <typename CharT, typename Rep, typename Period>
- typename disable_if<is_localizable<Period> , std::basic_string<CharT> >::type
- to_basic_string(
- duration_style_type style,
- duration<process_times<Rep>,Period> value,
- std::locale const& loc
- )
- {
- std::locale nloc;
- if (!std::has_facet<duration_units<CharT> >(loc))
- {
- nloc =std::locale(loc, new duration_units_default<CharT>());
- }
- else
- {
- nloc=loc;
- }
- duration_units<CharT> const & f = std::use_facet<duration_units<CharT> >(nloc);
- if (f.swaps_value_unit_order())
- {
- return f.to_string(style, detail::rt_ratio(nano()), int_least64_t(value.count())) + " " + to_basic_string<CharT>(value.count(), nloc);
- }
- else
- {
- return to_basic_string<CharT>(value.count(), nloc) + " " + f.to_string(style, detail::rt_ratio(nano()), int_least64_t(value.count()));
- }
- }
-
- template <typename CharT, typename Rep, typename Period>
- std::basic_string<CharT>
- to_basic_string(duration_style_type style, duration<Rep,Period> value)
- {
- return to_basic_string<CharT>(style, value, std::locale());
- }
-#endif
 
   } // chrono
 

Modified: trunk/boost/chrono/io/time_point_io.hpp
==============================================================================
--- trunk/boost/chrono/io/time_point_io.hpp (original)
+++ trunk/boost/chrono/io/time_point_io.hpp 2011-11-05 19:19:09 EDT (Sat, 05 Nov 2011)
@@ -12,65 +12,22 @@
 #ifndef BOOST_CHRONO_IO_TIME_POINT_IO_HPP
 #define BOOST_CHRONO_IO_TIME_POINT_IO_HPP
 
+#include <boost/chrono/io/translate.hpp>
 #include <boost/chrono/io/duration_io.hpp>
+#include <boost/chrono/io/ios_base_state.hpp>
+#include <boost/chrono/io/utility/manip_base.hpp>
 #include <boost/chrono/chrono.hpp>
-#include <locale>
-#include <boost/chrono/detail/scan_keyword.hpp>
-#include <boost/chrono/round.hpp>
-#include <boost/chrono/io/translate.hpp>
 #include <boost/chrono/clock_string.hpp>
-#include <boost/chrono/io/ios_base_state.hpp>
+#include <boost/chrono/round.hpp>
+#include <boost/chrono/detail/scan_keyword.hpp>
 #include <cstring>
+#include <locale>
 #include <string.h>
-#include <boost/chrono/io/utility/manip_base.hpp>
 
 namespace boost
 {
   namespace chrono
   {
-
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
-
- template<class CharT>
- class time_punct: public std::locale::facet
- {
- public:
- typedef std::basic_string<CharT> string_type;
-
- private:
- string_type fmt_;
- chrono::timezone_type tz_;
-
- public:
- static std::locale::id id;
-
- explicit time_punct(size_t refs = 0) :
- std::locale::facet(refs), tz_(timezone::utc)
- {
- }
-
- time_punct(timezone_type tz, string_type fmt, size_t refs = 0)
- // todo use move semantic when available.
- :
- std::locale::facet(refs), fmt_(fmt), tz_(tz)
- {
- }
-
- const string_type& fmt() const BOOST_NOEXCEPT
- {
- return fmt_;
- }
- chrono::timezone_type get_timezone() const BOOST_NOEXCEPT
- {
- return tz_;
- }
- };
-
- template<class CharT>
- std::locale::id time_punct<CharT>::id;
-#endif
-
-#if 1
     namespace detail
     {
 
@@ -94,12 +51,8 @@
         void operator()(out_stream &ios) const
         //void operator()(std::ios_base &ios) const
         {
- #if ! defined BOOST_CHRONO_IO_USE_XALLOC
- ios.imbue(std::locale(ios.getloc(), new time_punct<CharT> (tz_, fmt_)));
- #else
           set_time_fmt<CharT>(ios, fmt_);
           set_timezone(ios, tz_);
- #endif
         }
       };
 
@@ -121,111 +74,13 @@
         void operator()(out_stream &ios) const
         //void operator()(std::ios_base &ios) const
         {
- #if ! defined BOOST_CHRONO_IO_USE_XALLOC
- //ios.imbue(std::locale(ios.getloc(), new time_punct<typename out_stream::char_type> (tz_, std::basic_string<typename out_stream::char_type>())));
- ios.imbue(std::locale(ios.getloc(), new time_punct<typename out_stream::char_type> (tz_, "")));
- #else
- //set_time_fmt<CharT>(ios, std::basic_string<typename out_stream::char_type>());
           set_time_fmt<typename out_stream::char_type>(ios, "");
           set_timezone(ios, tz_);
- #endif
         }
       };
 
   }
 
-#else
- namespace detail
- {
- template<class CharT>
- struct time_manip
- {
- std::basic_string<CharT> fmt_;
- timezone_type tz_;
-
- time_manip(timezone_type tz, std::basic_string<CharT> fmt)
- // todo move semantics
- :
- fmt_(fmt), tz_(tz)
- {
- }
- };
-
- // todo move semantics
- template<class CharT, class Traits>
- std::basic_ostream<CharT, Traits>&
- operator <<(std::basic_ostream<CharT, Traits>& os, time_manip<CharT> m)
- {
- // todo move semantics
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- os.imbue(std::locale(os.getloc(), new time_punct<CharT> (m.tz_, m.fmt_)));
-#else
- set_time_fmt<CharT>(os, m.fmt_);
- set_timezone(os, m.tz_);
-#endif
- return os;
- }
-
- template<class CharT, class Traits>
- std::basic_istream<CharT, Traits>&
- operator >>(std::basic_istream<CharT, Traits>& is, time_manip<CharT> m)
- {
- // todo move semantics
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- is.imbue(std::locale(is.getloc(), new time_punct<CharT> (m.tz_, m.fmt_)));
-#else
- set_time_fmt<CharT>(is, m.fmt_);
- set_timezone(is, m.tz_);
-#endif
- return is;
- }
-
- class time_man
- {
- timezone_type form_;
- public:
- explicit time_man(timezone_type f) :
- form_(f)
- {
- }
- // explicit
- operator timezone_type() const
- {
- return form_;
- }
- };
-
- template<class CharT, class Traits>
- std::basic_ostream<CharT, Traits>&
- operator <<(std::basic_ostream<CharT, Traits>& os, time_man m)
- {
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- os.imbue(std::locale(os.getloc(), new time_punct<CharT> (static_cast<timezone_type> (m), std::basic_string<
- CharT>())));
-#else
- set_time_fmt<CharT>(os, std::basic_string<CharT>());
- set_timezone(os, static_cast<timezone_type> (m));
-#endif
- return os;
- }
-
- template<class CharT, class Traits>
- std::basic_istream<CharT, Traits>&
- operator >>(std::basic_istream<CharT, Traits>& is, time_man m)
- {
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- is.imbue(std::locale(is.getloc(), new time_punct<CharT> (static_cast<timezone_type> (m), std::basic_string<
- CharT>())));
-#else
- set_time_fmt<CharT>(is, "");
- set_timezone(is, static_cast<timezone_type> (m));
-#endif
- return is;
- }
-
- }
-#endif
-
     template<class CharT>
     inline detail::time_manip<CharT> time_fmt(timezone_type tz, const CharT* fmt)
     {
@@ -472,20 +327,6 @@
         bool failed = false;
         try
         {
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- const CharT* pb = 0; //nullptr;
- const CharT* pe = pb;
- timezone_type tz = timezone::utc;
- typedef time_punct<CharT> F;
- std::locale loc = os.getloc();
- if (std::has_facet<F>(loc))
- {
- const F& f = std::use_facet<F>(loc);
- pb = f.fmt().data();
- pe = pb + f.fmt().size();
- tz = f.get_timezone();
- }
-#else
           const CharT* pb = 0; //nullptr;
           const CharT* pe = pb;
           std::basic_string<CharT> fmt =
@@ -495,7 +336,6 @@
 
           timezone_type tz = get_timezone(os);
           std::locale loc = os.getloc();
-#endif
           time_t t = system_clock::to_time_t(tp);
           tm tm;
           if (tz == timezone::local)
@@ -646,20 +486,6 @@
         std::ios_base::iostate err = std::ios_base::goodbit;
         try
         {
-#if ! defined BOOST_CHRONO_IO_USE_XALLOC
- const CharT* pb = 0;//nullptr;
- const CharT* pe = pb;
- typedef time_punct<CharT> F;
- std::locale loc = is.getloc();
- timezone_type tz = timezone::utc;
- if (std::has_facet<F>(loc))
- {
- const F& f = std::use_facet<F>(loc);
- pb = f.fmt().data();
- pe = pb + f.fmt().size();
- tz = f.timezone_type();
- }
-#else
           const CharT* pb = 0; //nullptr;
           const CharT* pe = pb;
           std::basic_string<CharT> fmt =
@@ -669,7 +495,6 @@
 
           timezone_type tz = get_timezone(is);
           std::locale loc = is.getloc();
-#endif
           const std::time_get<CharT>& tg =
               std::use_facet<std::time_get<CharT> >(loc);
           const std::ctype<CharT>& ct = std::use_facet<std::ctype<CharT> >(loc);

Modified: trunk/boost/chrono/io/translate.hpp
==============================================================================
--- trunk/boost/chrono/io/translate.hpp (original)
+++ trunk/boost/chrono/io/translate.hpp 2011-11-05 19:19:09 EDT (Sat, 05 Nov 2011)
@@ -11,6 +11,7 @@
 
 #include <boost/chrono/config.hpp>
 #include <string>
+#include <locale>
 
 namespace boost
 {

Modified: trunk/boost/chrono/io_v1/chrono_io.hpp
==============================================================================
--- trunk/boost/chrono/io_v1/chrono_io.hpp (original)
+++ trunk/boost/chrono/io_v1/chrono_io.hpp 2011-11-05 19:19:09 EDT (Sat, 05 Nov 2011)
@@ -95,12 +95,6 @@
         string_type singular() const
     {
       return string_type(long_name(typename Period::type()), 0, long_name(typename Period::type()).size()-1);
-// string_type res;
-// res.assign(
-// long_name<Period>().data(),
-// long_name<Period>().data() + long_name<Period>().size()-1
-// );
-// return res;
     }
 
     template <class Period>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk