Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49722 - in trunk/boost/date_time: . local_time posix_time
From: andrey.semashev_at_[hidden]
Date: 2008-11-13 14:04:16


Author: andysem
Date: 2008-11-13 14:04:15 EST (Thu, 13 Nov 2008)
New Revision: 49722
URL: http://svn.boost.org/trac/boost/changeset/49722

Log:
Fixed a number of warnings about shadowed variables. Fixed
date_generator_formatter constructor that accepts custom phrase
elements.

Text files modified:
   trunk/boost/date_time/date_generator_formatter.hpp | 42 +++++++++++++++++++-----------------
   trunk/boost/date_time/local_time/local_time_io.hpp | 31 +++++++++++++--------------
   trunk/boost/date_time/period_parser.hpp | 20 ++++++++--------
   trunk/boost/date_time/posix_time/posix_time_io.hpp | 45 ++++++++++++++++++---------------------
   4 files changed, 68 insertions(+), 70 deletions(-)

Modified: trunk/boost/date_time/date_generator_formatter.hpp
==============================================================================
--- trunk/boost/date_time/date_generator_formatter.hpp (original)
+++ trunk/boost/date_time/date_generator_formatter.hpp 2008-11-13 14:04:15 EST (Thu, 13 Nov 2008)
@@ -63,6 +63,7 @@
       //! Default format elements used
       date_generator_formatter()
       {
+ phrase_strings.reserve(number_of_phrase_elements);
         phrase_strings.push_back(string_type(first_string));
         phrase_strings.push_back(string_type(second_string));
         phrase_strings.push_back(string_type(third_string));
@@ -75,25 +76,26 @@
       }
 
       //! Constructor that allows for a custom set of phrase elements
- date_generator_formatter(const string_type& first,
- const string_type& second,
- const string_type& third,
- const string_type& fourth,
- const string_type& fifth,
- const string_type& last,
- const string_type& before,
- const string_type& after,
- const string_type& of)
- {
- phrase_strings.push_back(string_type(first_string));
- phrase_strings.push_back(string_type(second_string));
- phrase_strings.push_back(string_type(third_string));
- phrase_strings.push_back(string_type(fourth_string));
- phrase_strings.push_back(string_type(fifth_string));
- phrase_strings.push_back(string_type(last_string));
- phrase_strings.push_back(string_type(before_string));
- phrase_strings.push_back(string_type(after_string));
- phrase_strings.push_back(string_type(of_string));
+ date_generator_formatter(const string_type& first_str,
+ const string_type& second_str,
+ const string_type& third_str,
+ const string_type& fourth_str,
+ const string_type& fifth_str,
+ const string_type& last_str,
+ const string_type& before_str,
+ const string_type& after_str,
+ const string_type& of_str)
+ {
+ phrase_strings.reserve(number_of_phrase_elements);
+ phrase_strings.push_back(first_str);
+ phrase_strings.push_back(second_str);
+ phrase_strings.push_back(third_str);
+ phrase_strings.push_back(fourth_str);
+ phrase_strings.push_back(fifth_str);
+ phrase_strings.push_back(last_str);
+ phrase_strings.push_back(before_str);
+ phrase_strings.push_back(after_str);
+ phrase_strings.push_back(of_str);
       }
 
       //! Replace the set of phrase elements with those contained in new_strings
@@ -148,7 +150,7 @@
         facet.put(next, a_ios, a_fill, nkd.month());
         return next;
       }
-
+
       //! Put a first_day_of_the_week_in_month => "first weekday of month"
       template<class facet_type>
       OutItrT put_first_kday(OutItrT next, std::ios_base& a_ios,

Modified: trunk/boost/date_time/local_time/local_time_io.hpp
==============================================================================
--- trunk/boost/date_time/local_time/local_time_io.hpp (original)
+++ trunk/boost/date_time/local_time/local_time_io.hpp 2008-11-13 14:04:15 EST (Thu, 13 Nov 2008)
@@ -26,7 +26,7 @@
 
   typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,wchar_t> wlocal_time_input_facet;
   typedef boost::date_time::time_input_facet<local_date_time::utc_time_type,char> local_time_input_facet;
-
+
   //! operator<< for local_date_time - see local_time docs for formatting details
   template<class CharT, class TraitsT>
   inline
@@ -38,7 +38,7 @@
     typedef date_time::time_facet<time_type, CharT> custom_time_facet;
     typedef std::time_put<CharT> std_time_facet;
     std::ostreambuf_iterator<CharT> oitr(os);
-
+
     if(std::has_facet<custom_time_facet>(os.getloc())) {
       std::use_facet<custom_time_facet>(os.getloc()).put(oitr,
                                                          os,
@@ -63,7 +63,7 @@
   operator>>(std::basic_istream<CharT, Traits>& is, local_date_time& ldt)
   {
     boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
     if (strm_sentry) {
       try {
         typedef typename local_date_time::utc_time_type utc_time_type;
@@ -72,7 +72,7 @@
         // intermediate objects
         std::basic_string<CharT> tz_str;
         utc_time_type pt(not_a_date_time);
-
+
         std::istreambuf_iterator<CharT,Traits> sit(is), str_end;
         if(std::has_facet<time_input_facet>(is.getloc())) {
           std::use_facet<time_input_facet>(is.getloc()).get_local_time(sit, str_end, is, pt, tz_str);
@@ -95,20 +95,20 @@
           ldt = local_date_time(pt.date(), pt.time_of_day(), tz_ptr, local_date_time::EXCEPTION_ON_ERROR);
         }
       }
- catch(...) {
+ catch(...) {
         // mask tells us what exceptions are turned on
         std::ios_base::iostate exception_mask = is.exceptions();
         // if the user wants exceptions on failbit, we'll rethrow our
         // date_time exception & set the failbit
         if(std::ios_base::failbit & exception_mask) {
- try { is.setstate(std::ios_base::failbit); }
+ try { is.setstate(std::ios_base::failbit); }
           catch(std::ios_base::failure&) {} // ignore this one
           throw; // rethrow original exception
         }
         else {
           // if the user want's to fail quietly, we simply set the failbit
- is.setstate(std::ios_base::failbit);
- }
+ is.setstate(std::ios_base::failbit);
+ }
 
       }
     }
@@ -117,9 +117,9 @@
 
   //! output operator for local_time_period
   template <class CharT, class TraitsT>
- inline
+ inline
   std::basic_ostream<CharT, TraitsT>&
- operator<<(std::basic_ostream<CharT, TraitsT>& os,
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
              const boost::local_time::local_time_period& p) {
     boost::io::ios_flags_saver iflags(os);
     typedef boost::date_time::time_facet<local_date_time, CharT> custom_facet;
@@ -134,7 +134,6 @@
       //since we would always need to reconstruct for every time period
       //if the local did not already exist. Of course this will be overridden
       //if the user imbues as some later point.
- std::ostreambuf_iterator<CharT> oitr(os);
       custom_facet* f = new custom_facet();
       std::locale l = std::locale(os.getloc(), f);
       os.imbue(l);
@@ -150,7 +149,7 @@
   operator>>(std::basic_istream<CharT, Traits>& is, boost::local_time::local_time_period& tp)
   {
     boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
     if (strm_sentry) {
       try {
         typedef typename date_time::time_input_facet<local_date_time, CharT> time_input_facet;
@@ -166,16 +165,16 @@
           f->get(sit, str_end, is, tp);
         }
       }
- catch(...) {
+ catch(...) {
         std::ios_base::iostate exception_mask = is.exceptions();
         if(std::ios_base::failbit & exception_mask) {
- try { is.setstate(std::ios_base::failbit); }
+ try { is.setstate(std::ios_base::failbit); }
           catch(std::ios_base::failure&) {}
           throw; // rethrow original exception
         }
         else {
- is.setstate(std::ios_base::failbit);
- }
+ is.setstate(std::ios_base::failbit);
+ }
 
       }
     }

Modified: trunk/boost/date_time/period_parser.hpp
==============================================================================
--- trunk/boost/date_time/period_parser.hpp (original)
+++ trunk/boost/date_time/period_parser.hpp 2008-11-13 14:04:15 EST (Thu, 13 Nov 2008)
@@ -33,7 +33,7 @@
    * where the date format is controlled by the date facet
    */
   template<class date_type, typename CharT>
- class period_parser {
+ class period_parser {
   public:
     typedef std::basic_string<CharT> string_type;
     typedef CharT char_type;
@@ -42,7 +42,7 @@
     typedef string_parse_tree<CharT> parse_tree_type;
     typedef typename parse_tree_type::parse_match_result_type match_results;
     typedef std::vector<std::basic_string<CharT> > collection_type;
-
+
     static const char_type default_period_separator[2];
     static const char_type default_period_start_delimeter[2];
     static const char_type default_period_open_range_end_delimeter[2];
@@ -51,12 +51,12 @@
     enum period_range_option { AS_OPEN_RANGE, AS_CLOSED_RANGE };
 
     //! Constructor that sets up period parser options
- period_parser(period_range_option range_option = AS_CLOSED_RANGE,
- const char_type* const period_separator = default_period_separator,
+ period_parser(period_range_option range_opt = AS_CLOSED_RANGE,
+ const char_type* const period_separator = default_period_separator,
                   const char_type* const period_start_delimeter = default_period_start_delimeter,
                   const char_type* const period_open_range_end_delimeter = default_period_open_range_end_delimeter,
                   const char_type* const period_closed_range_end_delimeter = default_period_closed_range_end_delimeter)
- : m_range_option(range_option)
+ : m_range_option(range_opt)
     {
       delimiters.push_back(string_type(period_separator));
       delimiters.push_back(string_type(period_start_delimeter));
@@ -126,7 +126,7 @@
     {
       // skip leading whitespace
       while(std::isspace(*sitr) && sitr != stream_end) { ++sitr; }
-
+
       typedef typename period_type::point_type point_type;
       point_type p1(not_a_date_time), p2(not_a_date_time);
 
@@ -145,14 +145,14 @@
       else {
         consume_delim(sitr, stream_end, delimiters[OPEN_END]); // end delim
       }
-
+
       return period_type(p1, p2);
     }
-
+
   private:
     collection_type delimiters;
- period_range_option m_range_option;
-
+ period_range_option m_range_option;
+
     enum delim_ids { SEPARATOR, START, OPEN_END, CLOSED_END };
 
     //! throws ios_base::failure if delimiter and parsed data do not match

Modified: trunk/boost/date_time/posix_time/posix_time_io.hpp
==============================================================================
--- trunk/boost/date_time/posix_time/posix_time_io.hpp (original)
+++ trunk/boost/date_time/posix_time/posix_time_io.hpp 2008-11-13 14:04:15 EST (Thu, 13 Nov 2008)
@@ -41,9 +41,9 @@
   typedef boost::date_time::time_input_facet<ptime, char> time_input_facet;
 
   template <class CharT, class TraitsT>
- inline
+ inline
   std::basic_ostream<CharT, TraitsT>&
- operator<<(std::basic_ostream<CharT, TraitsT>& os,
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
              const ptime& p) {
     boost::io::ios_flags_saver iflags(os);
     typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
@@ -57,7 +57,6 @@
       //since we would always need to reconstruct for every time period
       //if the locale did not already exist. Of course this will be overridden
       //if the user imbues as some later point.
- std::ostreambuf_iterator<CharT> oitr(os);
       custom_ptime_facet* f = new custom_ptime_facet();
       std::locale l = std::locale(os.getloc(), f);
       os.imbue(l);
@@ -73,7 +72,7 @@
   operator>>(std::basic_istream<CharT, Traits>& is, ptime& pt)
   {
     boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
     if (strm_sentry) {
       try {
         typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
@@ -88,30 +87,30 @@
           f->get(sit, str_end, is, pt);
         }
       }
- catch(...) {
+ catch(...) {
         // mask tells us what exceptions are turned on
         std::ios_base::iostate exception_mask = is.exceptions();
         // if the user wants exceptions on failbit, we'll rethrow our
         // date_time exception & set the failbit
         if(std::ios_base::failbit & exception_mask) {
- try { is.setstate(std::ios_base::failbit); }
+ try { is.setstate(std::ios_base::failbit); }
           catch(std::ios_base::failure&) {} // ignore this one
           throw; // rethrow original exception
         }
         else {
           // if the user want's to fail quietly, we simply set the failbit
- is.setstate(std::ios_base::failbit);
- }
+ is.setstate(std::ios_base::failbit);
+ }
       }
     }
     return is;
   }
-
+
 
   template <class CharT, class TraitsT>
   inline
   std::basic_ostream<CharT, TraitsT>&
- operator<<(std::basic_ostream<CharT, TraitsT>& os,
+ operator<<(std::basic_ostream<CharT, TraitsT>& os,
              const boost::posix_time::time_period& p) {
     boost::io::ios_flags_saver iflags(os);
     typedef boost::date_time::time_facet<ptime, CharT> custom_ptime_facet;
@@ -126,7 +125,6 @@
       //since we would always need to reconstruct for every time period
       //if the local did not already exist. Of course this will be overridden
       //if the user imbues as some later point.
- std::ostreambuf_iterator<CharT> oitr(os);
       custom_ptime_facet* f = new custom_ptime_facet();
       std::locale l = std::locale(os.getloc(), f);
       os.imbue(l);
@@ -142,7 +140,7 @@
   operator>>(std::basic_istream<CharT, Traits>& is, time_period& tp)
   {
     boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
     if (strm_sentry) {
       try {
         typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
@@ -157,21 +155,21 @@
           f->get(sit, str_end, is, tp);
         }
       }
- catch(...) {
+ catch(...) {
         std::ios_base::iostate exception_mask = is.exceptions();
         if(std::ios_base::failbit & exception_mask) {
- try { is.setstate(std::ios_base::failbit); }
+ try { is.setstate(std::ios_base::failbit); }
           catch(std::ios_base::failure&) {}
           throw; // rethrow original exception
         }
         else {
- is.setstate(std::ios_base::failbit);
- }
+ is.setstate(std::ios_base::failbit);
+ }
       }
     }
     return is;
   }
-
+
 
   //! ostream operator for posix_time::time_duration
   // todo fix to use facet -- place holder for now...
@@ -192,7 +190,6 @@
       //since we would always need to reconstruct for every time period
       //if the locale did not already exist. Of course this will be overridden
       //if the user imbues as some later point.
- std::ostreambuf_iterator<CharT> oitr(os);
       custom_ptime_facet* f = new custom_ptime_facet();
       std::locale l = std::locale(os.getloc(), f);
       os.imbue(l);
@@ -208,7 +205,7 @@
   operator>>(std::basic_istream<CharT, Traits>& is, time_duration& td)
   {
     boost::io::ios_flags_saver iflags(is);
- typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
+ typename std::basic_istream<CharT, Traits>::sentry strm_sentry(is, false);
     if (strm_sentry) {
       try {
         typedef typename date_time::time_input_facet<ptime, CharT> time_input_facet;
@@ -223,20 +220,20 @@
           f->get(sit, str_end, is, td);
         }
       }
- catch(...) {
+ catch(...) {
         std::ios_base::iostate exception_mask = is.exceptions();
         if(std::ios_base::failbit & exception_mask) {
- try { is.setstate(std::ios_base::failbit); }
+ try { is.setstate(std::ios_base::failbit); }
           catch(std::ios_base::failure&) {}
           throw; // rethrow original exception
         }
         else {
- is.setstate(std::ios_base::failbit);
- }
+ is.setstate(std::ios_base::failbit);
+ }
       }
     }
     return is;
   }
-
+
 } } // namespaces
 #endif // DATE_TIME_POSIX_TIME_IO_HPP__


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