Index: date_time/gregorian/gregorian_io.hpp =================================================================== --- date_time/gregorian/gregorian_io.hpp (revision 93) +++ date_time/gregorian/gregorian_io.hpp (working copy) @@ -20,6 +20,7 @@ #include #include #include // to_tm will be needed in the facets +#include "boost/detail/no_exceptions_support.hpp" namespace boost { namespace gregorian { @@ -76,7 +77,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -90,15 +91,16 @@ f->get(sit, str_end, is, d); } } - catch(...) { + BOOST_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); } - catch(std::ios_base::failure&) {} // ignore this one - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} // ignore this one + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { // if the user want's to fail quietly, we simply set the failbit @@ -106,6 +108,7 @@ } } + BOOST_CATCH_END } return is; } @@ -137,7 +140,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -151,18 +154,20 @@ f->get(sit, str_end, is, dd); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -201,7 +206,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -215,18 +220,20 @@ f->get(sit, str_end, is, dp); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -260,7 +267,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -274,18 +281,20 @@ f->get(sit, str_end, is, m); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -317,7 +326,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -331,18 +340,20 @@ f->get(sit, str_end, is, wd); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_RETHROW; // rethrow original exception + BOOST_CATCH_END } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -358,7 +369,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -372,18 +383,20 @@ f->get(sit, str_end, is, gd); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -399,7 +412,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -413,18 +426,20 @@ f->get(sit, str_end, is, gy); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -457,7 +472,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -471,18 +486,20 @@ f->get(sit, str_end, is, pd); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_RETHROW; // rethrow original exception + BOOST_CATCH_END } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -514,7 +531,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -528,18 +545,20 @@ f->get(sit, str_end, is, nday); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_RETHROW; // rethrow original exception + BOOST_CATCH_END } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -572,7 +591,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -586,18 +605,20 @@ f->get(sit, str_end, is, fkd); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -630,7 +651,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -644,18 +665,20 @@ f->get(sit, str_end, is, lkd); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -689,7 +712,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -703,18 +726,20 @@ f->get(sit, str_end, is, fka); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -748,7 +773,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::date_input_facet date_input_facet; std::istreambuf_iterator sit(is), str_end; @@ -762,18 +787,20 @@ f->get(sit, str_end, is, fkb); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } Index: date_time/posix_time/posix_time_io.hpp =================================================================== --- date_time/posix_time/posix_time_io.hpp (revision 93) +++ date_time/posix_time/posix_time_io.hpp (working copy) @@ -74,7 +74,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::time_input_facet time_input_facet; std::istreambuf_iterator sit(is), str_end; if(std::has_facet(is.getloc())) { @@ -87,21 +87,23 @@ f->get(sit, str_end, is, pt); } } - catch(...) { + BOOST_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); } - catch(std::ios_base::failure&) {} // ignore this one - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} // ignore this one + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { // if the user want's to fail quietly, we simply set the failbit is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -142,7 +144,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::time_input_facet time_input_facet; std::istreambuf_iterator sit(is), str_end; if(std::has_facet(is.getloc())) { @@ -155,17 +157,19 @@ f->get(sit, str_end, is, tp); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } @@ -207,7 +211,7 @@ boost::io::ios_flags_saver iflags(is); typename std::basic_istream::sentry strm_sentry(is, false); if (strm_sentry) { - try { + BOOST_TRY { typedef typename date_time::time_input_facet time_input_facet; std::istreambuf_iterator sit(is), str_end; if(std::has_facet(is.getloc())) { @@ -220,17 +224,19 @@ f->get(sit, str_end, is, td); } } - catch(...) { + BOOST_CATCH(...) { std::ios_base::iostate exception_mask = is.exceptions(); if(std::ios_base::failbit & exception_mask) { - try { is.setstate(std::ios_base::failbit); } - catch(std::ios_base::failure&) {} - throw; // rethrow original exception + BOOST_TRY { is.setstate(std::ios_base::failbit); } + BOOST_CATCH(std::ios_base::failure&) {} + BOOST_CATCH_END + BOOST_RETHROW; // rethrow original exception } else { is.setstate(std::ios_base::failbit); } } + BOOST_CATCH_END } return is; } Index: date_time/time_facet.hpp =================================================================== --- date_time/time_facet.hpp (revision 93) +++ date_time/time_facet.hpp (working copy) @@ -1005,17 +1005,18 @@ char_type cs[3] = { '%', *itr }; string_type s(cs); match_results mr; - try { + BOOST_TRY { t_year = this->m_parser.parse_year(sitr, stream_end, s, mr); } - catch(std::out_of_range&) { // base class for bad_year exception + BOOST_CATCH(std::out_of_range&) { // base class for bad_year exception if(this->m_sv_parser.match(sitr, stream_end, mr)) { t = time_type(static_cast(mr.current_match)); return sitr; } else { - throw; // rethrow bad_year + BOOST_RETHROW; // rethrow bad_year } + BOOST_CATCH_END } break; } @@ -1026,18 +1027,19 @@ char_type cs[3] = { '%', *itr }; string_type s(cs); match_results mr; - try { + BOOST_TRY { t_month = this->m_parser.parse_month(sitr, stream_end, s, mr); } - catch(std::out_of_range&) { // base class for bad_month exception + BOOST_CATCH(std::out_of_range&) { // base class for bad_month exception if(this->m_sv_parser.match(sitr, stream_end, mr)) { t = time_type(static_cast(mr.current_match)); return sitr; } else { - throw; // rethrow bad_month + BOOST_RETHROW; // rethrow bad_month } } + BOOST_CATCH_END // did m_parser already advance sitr to next char? if(mr.has_remaining()) { use_current_char = true; @@ -1053,18 +1055,19 @@ string_type s(cs); match_results mr; typename date_type::day_of_week_type wd(0); - try { + BOOST_TRY { wd = this->m_parser.parse_weekday(sitr, stream_end, s, mr); } - catch(std::out_of_range&) { // base class for bad_weekday exception + BOOST_CATCH(std::out_of_range&) { // base class for bad_weekday exception if(this->m_sv_parser.match(sitr, stream_end, mr)) { t = time_type(static_cast(mr.current_match)); return sitr; } else { - throw; // rethrow bad_weekday + BOOST_RETHROW; // rethrow bad_weekday } } + BOOST_CATCH_END // did m_parser already advance sitr to next char? if(mr.has_remaining()) { use_current_char = true; @@ -1089,19 +1092,20 @@ } case 'd': { - try { + BOOST_TRY { t_day = this->m_parser.parse_day_of_month(sitr, stream_end); } - catch(std::out_of_range&) { // base class for exception bad_day_of_month + BOOST_CATCH(std::out_of_range&) { // base class for exception bad_day_of_month match_results mr; if(this->m_sv_parser.match(sitr, stream_end, mr)) { t = time_type(static_cast(mr.current_match)); return sitr; } else { - throw; // rethrow bad_day_of_month + BOOST_RETHROW; // rethrow bad_day_of_month } } + BOOST_CATCH_END break; } // time flags