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