Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80542 - trunk/boost/chrono/io
From: vicente.botet_at_[hidden]
Date: 2012-09-16 12:45:04


Author: viboes
Date: 2012-09-16 12:45:04 EDT (Sun, 16 Sep 2012)
New Revision: 80542
URL: http://svn.boost.org/trac/boost/changeset/80542

Log:
Chrono: Make use of BOOST_TRY family macros
Text files modified:
   trunk/boost/chrono/io/duration_io.hpp | 42 ++++++++++++----------------
   trunk/boost/chrono/io/time_point_io.hpp | 58 +++++++++++++++------------------------
   2 files changed, 41 insertions(+), 59 deletions(-)

Modified: trunk/boost/chrono/io/duration_io.hpp
==============================================================================
--- trunk/boost/chrono/io/duration_io.hpp (original)
+++ trunk/boost/chrono/io/duration_io.hpp 2012-09-16 12:45:04 EDT (Sun, 16 Sep 2012)
@@ -10,13 +10,14 @@
 #ifndef BOOST_CHRONO_IO_DURATION_IO_HPP
 #define BOOST_CHRONO_IO_DURATION_IO_HPP
 
-#include <boost/chrono/chrono.hpp>
+#include <boost/chrono/duration.hpp>
 #include <boost/ratio/ratio_io.hpp>
 #include <boost/chrono/io/duration_style.hpp>
 #include <boost/chrono/io/ios_base_state.hpp>
 #include <boost/chrono/io/duration_put.hpp>
 #include <boost/chrono/io/duration_get.hpp>
 #include <boost/chrono/io/utility/manip_base.hpp>
+#include <boost/detail/no_exceptions_support.hpp>
 #include <locale>
 #include <iostream>
 
@@ -119,15 +120,11 @@
     operator<<(std::basic_ostream<CharT, Traits>& os, const duration<Rep, Period>& d)
     {
       typedef std::basic_string<CharT, Traits> string_type;
-#ifndef BOOST_NO_EXCEPTIONS
       bool failed = false;
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
       {
         std::ios_base::iostate err = std::ios_base::goodbit;
-#ifndef BOOST_NO_EXCEPTIONS
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
         {
           typename std::basic_ostream<CharT, Traits>::sentry opfx(os);
           if (opfx)
@@ -146,31 +143,30 @@
             os.width(0);
           }
         }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH(...)
         {
           bool flag = false;
- try // BOOST_NO_EXCEPTIONS protected
+ BOOST_TRY
           {
             os.setstate(std::ios_base::failbit);
           }
- catch (std::ios_base::failure ) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (std::ios_base::failure )
           {
             flag = true;
           }
+ BOOST_CATCH_END
           if (flag) throw;
         }
-#endif
+ BOOST_CATCH_END
         if (err) os.setstate(err);
         return os;
       }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH(...)
       {
         failed = true;
       }
+ BOOST_CATCH_END
       if (failed) os.setstate(std::ios_base::failbit | std::ios_base::badbit);
-#endif
       return os;
     }
 
@@ -186,9 +182,7 @@
     {
       std::ios_base::iostate err = std::ios_base::goodbit;
 
-#ifndef BOOST_NO_EXCEPTIONS
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
       {
         typename std::basic_istream<CharT, Traits>::sentry ipfx(is);
         if (ipfx)
@@ -204,21 +198,21 @@
           }
         }
       }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (...)
       {
         bool flag = false;
- try // BOOST_NO_EXCEPTIONS protected
+ BOOST_TRY
         {
           is.setstate(std::ios_base::failbit);
         }
- catch (std::ios_base::failure ) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (std::ios_base::failure )
         {
           flag = true;
         }
- if (flag) throw; // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH_END
+ if (flag) { BOOST_RETHROW }
       }
-#endif
+ BOOST_CATCH_END
       if (err) is.setstate(err);
       return is;
     }

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 2012-09-16 12:45:04 EDT (Sun, 16 Sep 2012)
@@ -15,10 +15,11 @@
 #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 <boost/chrono/time_point.hpp>
 #include <boost/chrono/clock_string.hpp>
 #include <boost/chrono/round.hpp>
 #include <boost/chrono/detail/scan_keyword.hpp>
+#include <boost/detail/no_exceptions_support.hpp>
 #include <cstring>
 #include <locale>
 #include <string.h>
@@ -222,15 +223,11 @@
     {
 
       typedef std::basic_string<CharT, Traits> string_type;
-#ifndef BOOST_NO_EXCEPTIONS
       bool failed = false;
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
       {
         std::ios_base::iostate err = std::ios_base::goodbit;
-#ifndef BOOST_NO_EXCEPTIONS
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
         {
           typename std::basic_ostream<CharT, Traits>::sentry opfx(os);
           if (opfx)
@@ -252,31 +249,30 @@
             os.width(0);
           }
         }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (...)
         {
           bool flag = false;
- try // BOOST_NO_EXCEPTIONS protected
+ BOOST_TRY
           {
             os.setstate(std::ios_base::failbit);
           }
- catch (std::ios_base::failure ) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (std::ios_base::failure )
           {
             flag = true;
           }
+ BOOST_CATCH_END
           if (flag) throw;
         }
-#endif
+ BOOST_CATCH_END
         if (err) os.setstate(err);
         return os;
       }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (...)
       {
         failed = true;
       }
+ BOOST_CATCH_END
       if (failed) os.setstate(std::ios_base::failbit | std::ios_base::badbit);
-#endif
       return os;
     }
 
@@ -287,9 +283,7 @@
       //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       std::ios_base::iostate err = std::ios_base::goodbit;
 
-#ifndef BOOST_NO_EXCEPTIONS
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
       {
         //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         typename std::basic_istream<CharT, Traits>::sentry ipfx(is);
@@ -309,26 +303,26 @@
           }
         }
       }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (...)
       {
         //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         bool flag = false;
- try
+ BOOST_TRY
         {
           //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           is.setstate(std::ios_base::failbit);
         }
- catch (std::ios_base::failure ) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (std::ios_base::failure )
         {
           //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           flag = true;
         }
+ BOOST_CATCH_END
         //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         if (flag) throw;
         //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       }
-#endif
+ BOOST_CATCH_END
       if (err) is.setstate(err);
       //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
       return is;
@@ -407,9 +401,7 @@
       {
         //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
         bool failed = false;
-#ifndef BOOST_NO_EXCEPTIONS
- try // BOOST_NO_EXCEPTIONS protected
-#endif
+ BOOST_TRY
         {
           //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           const CharT* pb = 0; //nullptr;
@@ -514,13 +506,12 @@
             }
           }
         }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (...)
         {
           //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
           failed = true;
         }
-#endif
+ BOOST_CATCH_END
         if (failed)
         {
           //std::cerr << __FILE__ << "[" << __LINE__ << "]"<< std::endl;
@@ -597,9 +588,7 @@
       if (ok)
       {
         std::ios_base::iostate err = std::ios_base::goodbit;
-#ifndef BOOST_NO_EXCEPTIONS
- try
-#endif
+ BOOST_TRY
         {
           const CharT* pb = 0; //nullptr;
           const CharT* pe = pb;
@@ -689,12 +678,11 @@
             tp = system_clock::from_time_t(t) - minu;
           }
         }
-#ifndef BOOST_NO_EXCEPTIONS
- catch (...) // BOOST_NO_EXCEPTIONS protected
+ BOOST_CATCH (...)
         {
           err |= std::ios_base::badbit | std::ios_base::failbit;
         }
-#endif
+ BOOST_CATCH_END
         exit: is.setstate(err);
       }
       return is;


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