1*f8a1b7d9SAlexander Kabaev // -*- C++ -*-
2*f8a1b7d9SAlexander Kabaev 
3*f8a1b7d9SAlexander Kabaev // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
4*f8a1b7d9SAlexander Kabaev //
5*f8a1b7d9SAlexander Kabaev // This file is part of the GNU ISO C++ Library.  This library is free
6*f8a1b7d9SAlexander Kabaev // software; you can redistribute it and/or modify it under the terms
7*f8a1b7d9SAlexander Kabaev // of the GNU General Public License as published by the Free Software
8*f8a1b7d9SAlexander Kabaev // Foundation; either version 2, or (at your option) any later
9*f8a1b7d9SAlexander Kabaev // version.
10*f8a1b7d9SAlexander Kabaev 
11*f8a1b7d9SAlexander Kabaev // This library is distributed in the hope that it will be useful, but
12*f8a1b7d9SAlexander Kabaev // WITHOUT ANY WARRANTY; without even the implied warranty of
13*f8a1b7d9SAlexander Kabaev // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*f8a1b7d9SAlexander Kabaev // General Public License for more details.
15*f8a1b7d9SAlexander Kabaev 
16*f8a1b7d9SAlexander Kabaev // You should have received a copy of the GNU General Public License
17*f8a1b7d9SAlexander Kabaev // along with this library; see the file COPYING.  If not, write to
18*f8a1b7d9SAlexander Kabaev // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19*f8a1b7d9SAlexander Kabaev // MA 02111-1307, USA.
20*f8a1b7d9SAlexander Kabaev 
21*f8a1b7d9SAlexander Kabaev // As a special exception, you may use this file as part of a free
22*f8a1b7d9SAlexander Kabaev // software library without restriction.  Specifically, if other files
23*f8a1b7d9SAlexander Kabaev // instantiate templates or use macros or inline functions from this
24*f8a1b7d9SAlexander Kabaev // file, or you compile this file and link it with other files to
25*f8a1b7d9SAlexander Kabaev // produce an executable, this file does not by itself cause the
26*f8a1b7d9SAlexander Kabaev // resulting executable to be covered by the GNU General Public
27*f8a1b7d9SAlexander Kabaev // License.  This exception does not however invalidate any other
28*f8a1b7d9SAlexander Kabaev // reasons why the executable file might be covered by the GNU General
29*f8a1b7d9SAlexander Kabaev // Public License.
30*f8a1b7d9SAlexander Kabaev 
31*f8a1b7d9SAlexander Kabaev // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
32*f8a1b7d9SAlexander Kabaev 
33*f8a1b7d9SAlexander Kabaev // Permission to use, copy, modify, sell, and distribute this software
34*f8a1b7d9SAlexander Kabaev // is hereby granted without fee, provided that the above copyright
35*f8a1b7d9SAlexander Kabaev // notice appears in all copies, and that both that copyright notice
36*f8a1b7d9SAlexander Kabaev // and this permission notice appear in supporting documentation. None
37*f8a1b7d9SAlexander Kabaev // of the above authors, nor IBM Haifa Research Laboratories, make any
38*f8a1b7d9SAlexander Kabaev // representation about the suitability of this software for any
39*f8a1b7d9SAlexander Kabaev // purpose. It is provided "as is" without express or implied
40*f8a1b7d9SAlexander Kabaev // warranty.
41*f8a1b7d9SAlexander Kabaev 
42*f8a1b7d9SAlexander Kabaev /**
43*f8a1b7d9SAlexander Kabaev  * @file exception.hpp
44*f8a1b7d9SAlexander Kabaev  * Contains exception classes.
45*f8a1b7d9SAlexander Kabaev  */
46*f8a1b7d9SAlexander Kabaev 
47*f8a1b7d9SAlexander Kabaev #ifndef PB_DS_EXCEPTION_HPP
48*f8a1b7d9SAlexander Kabaev #define PB_DS_EXCEPTION_HPP
49*f8a1b7d9SAlexander Kabaev 
50*f8a1b7d9SAlexander Kabaev #include <stdexcept>
51*f8a1b7d9SAlexander Kabaev 
52*f8a1b7d9SAlexander Kabaev namespace pb_ds
53*f8a1b7d9SAlexander Kabaev {
54*f8a1b7d9SAlexander Kabaev   // Base class for exceptions.
55*f8a1b7d9SAlexander Kabaev   struct container_error : public std::logic_error
56*f8a1b7d9SAlexander Kabaev   {
container_errorpb_ds::container_error57*f8a1b7d9SAlexander Kabaev     container_error()
58*f8a1b7d9SAlexander Kabaev     : std::logic_error(__N("pb_ds::container_error")) { }
59*f8a1b7d9SAlexander Kabaev   };
60*f8a1b7d9SAlexander Kabaev 
61*f8a1b7d9SAlexander Kabaev   // An entry cannot be inserted into a container object for logical
62*f8a1b7d9SAlexander Kabaev   // reasons (not, e.g., if memory is unabvailable, in which case
63*f8a1b7d9SAlexander Kabaev   // the allocator's exception will be thrown).
64*f8a1b7d9SAlexander Kabaev   struct insert_error : public container_error { };
65*f8a1b7d9SAlexander Kabaev 
66*f8a1b7d9SAlexander Kabaev   // A join cannot be performed logical reasons (i.e., the ranges of
67*f8a1b7d9SAlexander Kabaev   // the two container objects being joined overlaps.
68*f8a1b7d9SAlexander Kabaev   struct join_error : public container_error { };
69*f8a1b7d9SAlexander Kabaev 
70*f8a1b7d9SAlexander Kabaev   // A container cannot be resized.
71*f8a1b7d9SAlexander Kabaev   struct resize_error : public container_error { };
72*f8a1b7d9SAlexander Kabaev 
73*f8a1b7d9SAlexander Kabaev #if __EXCEPTIONS
74*f8a1b7d9SAlexander Kabaev   void
__throw_container_error(void)75*f8a1b7d9SAlexander Kabaev   __throw_container_error(void)
76*f8a1b7d9SAlexander Kabaev   { throw container_error(); }
77*f8a1b7d9SAlexander Kabaev 
78*f8a1b7d9SAlexander Kabaev   void
__throw_insert_error(void)79*f8a1b7d9SAlexander Kabaev   __throw_insert_error(void)
80*f8a1b7d9SAlexander Kabaev   { throw insert_error(); }
81*f8a1b7d9SAlexander Kabaev 
82*f8a1b7d9SAlexander Kabaev   void
__throw_join_error(void)83*f8a1b7d9SAlexander Kabaev   __throw_join_error(void)
84*f8a1b7d9SAlexander Kabaev   { throw join_error(); }
85*f8a1b7d9SAlexander Kabaev 
86*f8a1b7d9SAlexander Kabaev   void
__throw_resize_error(void)87*f8a1b7d9SAlexander Kabaev   __throw_resize_error(void)
88*f8a1b7d9SAlexander Kabaev   { throw resize_error(); }
89*f8a1b7d9SAlexander Kabaev #else
90*f8a1b7d9SAlexander Kabaev   void
__throw_container_error(void)91*f8a1b7d9SAlexander Kabaev   __throw_container_error(void)
92*f8a1b7d9SAlexander Kabaev   { std::abort(); }
93*f8a1b7d9SAlexander Kabaev 
94*f8a1b7d9SAlexander Kabaev   void
__throw_insert_error(void)95*f8a1b7d9SAlexander Kabaev   __throw_insert_error(void)
96*f8a1b7d9SAlexander Kabaev   { std::abort(); }
97*f8a1b7d9SAlexander Kabaev 
98*f8a1b7d9SAlexander Kabaev   void
__throw_join_error(void)99*f8a1b7d9SAlexander Kabaev   __throw_join_error(void)
100*f8a1b7d9SAlexander Kabaev   { std::abort(); }
101*f8a1b7d9SAlexander Kabaev 
102*f8a1b7d9SAlexander Kabaev   void
__throw_resize_error(void)103*f8a1b7d9SAlexander Kabaev   __throw_resize_error(void)
104*f8a1b7d9SAlexander Kabaev   { std::abort(); }
105*f8a1b7d9SAlexander Kabaev #endif
106*f8a1b7d9SAlexander Kabaev } // namespace pb_ds
107*f8a1b7d9SAlexander Kabaev 
108*f8a1b7d9SAlexander Kabaev #endif
109