Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:53

0001 // ----------------------------------------------------------------------------
0002 // boost/format/exceptions.hpp 
0003 // ----------------------------------------------------------------------------
0004 
0005 //  Copyright Samuel Krempp 2003.
0006 //
0007 // Distributed under the Boost Software License, Version 1.0.
0008 //    (See accompanying file LICENSE_1_0.txt or copy at
0009 //          http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 //
0012 //  See http://www.boost.org/libs/format/ for library home page
0013 
0014 // ----------------------------------------------------------------------------
0015 
0016 #ifndef BOOST_FORMAT_EXCEPTIONS_HPP
0017 #define BOOST_FORMAT_EXCEPTIONS_HPP
0018 
0019 
0020 #include <boost/config.hpp>
0021 #include <stdexcept>
0022 
0023 
0024 namespace boost {
0025 
0026     namespace io {
0027 
0028 // **** exceptions -----------------------------------------------
0029 
0030         class format_error : public std::exception
0031         {
0032         public:
0033             format_error()  {}
0034             virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
0035                 return "boost::format_error: "
0036                     "format generic failure";
0037             }
0038         };
0039 
0040         class bad_format_string : public format_error
0041         {
0042             std::size_t pos_, next_;
0043         public:
0044             bad_format_string(std::size_t pos, std::size_t size) 
0045                 : pos_(pos), next_(size) {}
0046             std::size_t get_pos() const { return pos_; }
0047             std::size_t get_next() const { return next_; }
0048             virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
0049                 return "boost::bad_format_string: format-string is ill-formed";
0050             }
0051         };
0052 
0053         class too_few_args : public format_error
0054         {
0055             std::size_t cur_, expected_;
0056         public:
0057             too_few_args(std::size_t cur, std::size_t expected) 
0058                 : cur_(cur), expected_(expected) {}
0059             std::size_t get_cur() const { return cur_; }
0060             std::size_t get_expected() const { return expected_; }
0061             virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
0062                 return "boost::too_few_args: "
0063                     "format-string referred to more arguments than were passed";
0064             }
0065         };
0066 
0067         class too_many_args : public format_error
0068         {
0069             std::size_t cur_, expected_;
0070         public:
0071             too_many_args(std::size_t cur, std::size_t expected) 
0072                 : cur_(cur), expected_(expected) {}
0073             std::size_t get_cur() const { return cur_; }
0074             std::size_t get_expected() const { return expected_; }
0075             virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
0076                 return "boost::too_many_args: "
0077                     "format-string referred to fewer arguments than were passed";
0078             }
0079         };
0080 
0081 
0082         class  out_of_range : public format_error
0083         {
0084             int index_, beg_, end_;    // range is [ beg, end [
0085         public:
0086             out_of_range(int index, int beg, int end) 
0087                 : index_(index), beg_(beg), end_(end) {}
0088             int get_index() const { return index_; }
0089             int get_beg() const { return beg_; }
0090             int get_end() const { return end_; }
0091             virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
0092                 return "boost::out_of_range: "
0093                     "tried to refer to an argument (or item) number which"
0094                     " is out of range, according to the format string";
0095             }
0096         };
0097 
0098 
0099     } // namespace io
0100 
0101 } // namespace boost
0102 
0103 
0104 #endif // BOOST_FORMAT_EXCEPTIONS_HPP