]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/format/exceptions.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / format / exceptions.hpp
CommitLineData
7c673cae
FG
1// ----------------------------------------------------------------------------
2// boost/format/exceptions.hpp
3// ----------------------------------------------------------------------------
4
5// Copyright Samuel Krempp 2003.
6//
7// Distributed under the Boost Software License, Version 1.0.
8// (See accompanying file LICENSE_1_0.txt or copy at
9// http://www.boost.org/LICENSE_1_0.txt)
10//
11//
12// See http://www.boost.org/libs/format/ for library home page
13
14// ----------------------------------------------------------------------------
15
16#ifndef BOOST_FORMAT_EXCEPTIONS_HPP
17#define BOOST_FORMAT_EXCEPTIONS_HPP
18
19
1e59de90 20#include <boost/config.hpp>
7c673cae
FG
21#include <stdexcept>
22
23
24namespace boost {
25
26 namespace io {
27
28// **** exceptions -----------------------------------------------
29
30 class format_error : public std::exception
31 {
32 public:
33 format_error() {}
1e59de90 34 virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
7c673cae
FG
35 return "boost::format_error: "
36 "format generic failure";
37 }
38 };
39
40 class bad_format_string : public format_error
41 {
42 std::size_t pos_, next_;
43 public:
44 bad_format_string(std::size_t pos, std::size_t size)
45 : pos_(pos), next_(size) {}
46 std::size_t get_pos() const { return pos_; }
47 std::size_t get_next() const { return next_; }
1e59de90 48 virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
7c673cae
FG
49 return "boost::bad_format_string: format-string is ill-formed";
50 }
51 };
52
53 class too_few_args : public format_error
54 {
55 std::size_t cur_, expected_;
56 public:
57 too_few_args(std::size_t cur, std::size_t expected)
58 : cur_(cur), expected_(expected) {}
59 std::size_t get_cur() const { return cur_; }
60 std::size_t get_expected() const { return expected_; }
1e59de90 61 virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
7c673cae
FG
62 return "boost::too_few_args: "
63 "format-string referred to more arguments than were passed";
64 }
65 };
66
67 class too_many_args : public format_error
68 {
69 std::size_t cur_, expected_;
70 public:
71 too_many_args(std::size_t cur, std::size_t expected)
72 : cur_(cur), expected_(expected) {}
73 std::size_t get_cur() const { return cur_; }
74 std::size_t get_expected() const { return expected_; }
1e59de90 75 virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
7c673cae
FG
76 return "boost::too_many_args: "
77 "format-string referred to fewer arguments than were passed";
78 }
79 };
80
81
82 class out_of_range : public format_error
83 {
84 int index_, beg_, end_; // range is [ beg, end [
85 public:
86 out_of_range(int index, int beg, int end)
87 : index_(index), beg_(beg), end_(end) {}
88 int get_index() const { return index_; }
89 int get_beg() const { return beg_; }
90 int get_end() const { return end_; }
1e59de90 91 virtual const char *what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {
7c673cae
FG
92 return "boost::out_of_range: "
93 "tried to refer to an argument (or item) number which"
94 " is out of range, according to the format string";
95 }
96 };
97
98
99 } // namespace io
100
101} // namespace boost
102
103
104#endif // BOOST_FORMAT_EXCEPTIONS_HPP