1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/format/exceptions.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,103 @@
1.4 +// ----------------------------------------------------------------------------
1.5 +// boost/format/exceptions.hpp
1.6 +// ----------------------------------------------------------------------------
1.7 +
1.8 +// Copyright Samuel Krempp 2003.
1.9 +//
1.10 +// Distributed under the Boost Software License, Version 1.0.
1.11 +// (See accompanying file LICENSE_1_0.txt or copy at
1.12 +// http://www.boost.org/LICENSE_1_0.txt)
1.13 +//
1.14 +//
1.15 +// See http://www.boost.org/libs/format/ for library home page
1.16 +
1.17 +// ----------------------------------------------------------------------------
1.18 +
1.19 +#ifndef BOOST_FORMAT_EXCEPTIONS_HPP
1.20 +#define BOOST_FORMAT_EXCEPTIONS_HPP
1.21 +
1.22 +
1.23 +#include <stdexcept>
1.24 +
1.25 +
1.26 +namespace boost {
1.27 +
1.28 + namespace io {
1.29 +
1.30 +// **** exceptions -----------------------------------------------
1.31 +
1.32 + class format_error : public std::exception
1.33 + {
1.34 + public:
1.35 + format_error() {}
1.36 + virtual const char *what() const throw() {
1.37 + return "boost::format_error: "
1.38 + "format generic failure";
1.39 + }
1.40 + };
1.41 +
1.42 + class bad_format_string : public format_error
1.43 + {
1.44 + std::size_t pos_, next_;
1.45 + public:
1.46 + bad_format_string(std::size_t pos, std::size_t size)
1.47 + : pos_(pos), next_(size) {}
1.48 + std::size_t get_pos() const { return pos_; }
1.49 + std::size_t get_next() const { return next_; }
1.50 + virtual const char *what() const throw() {
1.51 + return "boost::bad_format_string: format-string is ill-formed";
1.52 + }
1.53 + };
1.54 +
1.55 + class too_few_args : public format_error
1.56 + {
1.57 + std::size_t cur_, expected_;
1.58 + public:
1.59 + too_few_args(std::size_t cur, std::size_t expected)
1.60 + : cur_(cur), expected_(expected) {}
1.61 + std::size_t get_cur() const { return cur_; }
1.62 + std::size_t get_expected() const { return expected_; }
1.63 + virtual const char *what() const throw() {
1.64 + return "boost::too_few_args: "
1.65 + "format-string referred to more arguments than were passed";
1.66 + }
1.67 + };
1.68 +
1.69 + class too_many_args : public format_error
1.70 + {
1.71 + std::size_t cur_, expected_;
1.72 + public:
1.73 + too_many_args(std::size_t cur, std::size_t expected)
1.74 + : cur_(cur), expected_(expected) {}
1.75 + std::size_t get_cur() const { return cur_; }
1.76 + std::size_t get_expected() const { return expected_; }
1.77 + virtual const char *what() const throw() {
1.78 + return "boost::too_many_args: "
1.79 + "format-string referred to less arguments than were passed";
1.80 + }
1.81 + };
1.82 +
1.83 +
1.84 + class out_of_range : public format_error
1.85 + {
1.86 + int index_, beg_, end_; // range is [ beg, end [
1.87 + public:
1.88 + out_of_range(int index, int beg, int end)
1.89 + : index_(index), beg_(beg), end_(end) {}
1.90 + int get_index() const { return index_; }
1.91 + int get_beg() const { return beg_; }
1.92 + int get_end() const { return end_; }
1.93 + virtual const char *what() const throw() {
1.94 + return "boost::out_of_range: "
1.95 + "tried to refer to an argument (or item) number which"
1.96 + " is out of range, according to the format string";
1.97 + }
1.98 + };
1.99 +
1.100 +
1.101 + } // namespace io
1.102 +
1.103 +} // namespace boost
1.104 +
1.105 +
1.106 +#endif // BOOST_FORMAT_EXCEPTIONS_HPP