Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:34

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2015. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_INTERPROCESS_EXCEPTIONS_HPP
0012 #define BOOST_INTERPROCESS_EXCEPTIONS_HPP
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 #  pragma once
0020 #endif
0021 
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 #include <boost/interprocess/errors.hpp>
0025 #include <stdexcept>
0026 
0027 //!\file
0028 //!Describes exceptions thrown by interprocess classes
0029 
0030 namespace boost {
0031 
0032 namespace interprocess {
0033 
0034 //!This class is the base class of all exceptions
0035 //!thrown by boost::interprocess
0036 class BOOST_SYMBOL_VISIBLE interprocess_exception : public std::exception
0037 {
0038    public:
0039    interprocess_exception(const char *err) BOOST_NOEXCEPT
0040       :  m_err(other_error)
0041    {
0042       BOOST_TRY   {  m_str = err; }
0043       BOOST_CATCH(...) {} BOOST_CATCH_END
0044    }
0045 
0046    interprocess_exception(const error_info &err_info, const char *str = 0)
0047       :  m_err(err_info)
0048    {
0049       BOOST_TRY{
0050          if(m_err.get_native_error() != 0){
0051             fill_system_message(m_err.get_native_error(), m_str);
0052          }
0053          else if(str){
0054             m_str = str;
0055          }
0056          else{
0057             m_str = "boost::interprocess_exception::library_error";
0058          }
0059       }
0060       BOOST_CATCH(...){} BOOST_CATCH_END
0061    }
0062 
0063    ~interprocess_exception() BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE {}
0064 
0065    const char * what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
0066    {  return m_str.c_str();  }
0067 
0068    native_error_t get_native_error() const BOOST_NOEXCEPT { return m_err.get_native_error(); }
0069 
0070    // Note: a value of other_error implies a library (rather than system) error
0071    error_code_t   get_error_code()  const BOOST_NOEXCEPT { return m_err.get_error_code(); }
0072 
0073    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
0074    private:
0075    error_info        m_err;
0076    std::string       m_str;
0077    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
0078 };
0079 
0080 //!This is the exception thrown by shared interprocess_mutex family when a deadlock situation
0081 //!is detected or when using a interprocess_condition the interprocess_mutex is not locked
0082 class BOOST_SYMBOL_VISIBLE lock_exception : public interprocess_exception
0083 {
0084    public:
0085    lock_exception(error_code_t err = lock_error) BOOST_NOEXCEPT
0086       :  interprocess_exception(err)
0087    {}
0088 
0089    const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
0090    {  return "boost::interprocess::lock_exception";  }
0091 };
0092 
0093 
0094 //!This exception is thrown when a memory request can't be
0095 //!fulfilled.
0096 class BOOST_SYMBOL_VISIBLE bad_alloc : public interprocess_exception
0097 {
0098  public:
0099    bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc") {}
0100 
0101    const char* what() const BOOST_NOEXCEPT_OR_NOTHROW BOOST_OVERRIDE
0102    {  return "boost::interprocess::bad_alloc";  }
0103 };
0104 
0105 }  // namespace interprocess {
0106 
0107 }  // namespace boost
0108 
0109 #include <boost/interprocess/detail/config_end.hpp>
0110 
0111 #endif // BOOST_INTERPROCESS_EXCEPTIONS_HPP