containers/exceptions.hpp

    1: #ifndef STLPLUS_EXCEPTIONS
    2: #define STLPLUS_EXCEPTIONS
    3: ////////////////////////////////////////////////////////////////////////////////
    4: 
    5: //   Author: Andy Rushton
    6: //   Copyright: (c) Andy Rushton, 2007
    7: //   License:   BSD License, see ../docs/license.html
    8: 
    9: //   The set of general exceptions thrown by STLplus components
   10: 
   11: ////////////////////////////////////////////////////////////////////////////////
   12: #include "containers_fixes.hpp"
   13: #include <stdexcept>
   14: #include <string>
   15: 
   16: namespace stlplus
   17: {
   18: 
   19:   ////////////////////////////////////////////////////////////////////////////////
   20:   // Thrown if a pointer or an iterator is dereferenced when it is null
   21: 
   22:   class null_dereference : public std::logic_error
   23:   {
   24:   public:
   25:     null_dereference(const std::string& description) throw();
   26:     ~null_dereference(void) throw();
   27:   };
   28: 
   29:   ////////////////////////////////////////////////////////////////////////////////
   30:   // Thrown if an iterator is dereferenced when it is pointing to the end element
   31: 
   32:   class end_dereference : public std::logic_error
   33:   {
   34:   public:
   35:     end_dereference(const std::string& description) throw();
   36:     ~end_dereference(void) throw();
   37:   };
   38: 
   39:   ////////////////////////////////////////////////////////////////////////////////
   40:   // Thrown if an iterator is used with the wrong container. In other words, an
   41:   // iterator is created as a pointer to a sub-object within a container. If
   42:   // that iterator is then used with a different container, this exception is
   43:   // thrown.
   44: 
   45:   class wrong_object : public std::logic_error
   46:   {
   47:   public:
   48:     wrong_object(const std::string& description) throw();
   49:     ~wrong_object(void) throw();
   50:   };
   51: 
   52:   ////////////////////////////////////////////////////////////////////////////////
   53:   // Thrown if an attempt is made to copy an object that is uncopyable
   54: 
   55:   class illegal_copy : public std::logic_error
   56:   {
   57:   public:
   58:     illegal_copy(const std::string& description) throw();
   59:     ~illegal_copy(void) throw();
   60:   };
   61: 
   62:   ////////////////////////////////////////////////////////////////////////////////
   63: 
   64: } // end namespace stlplus
   65: 
   66: #endif