Blame lib/exception.hpp

rpm-build d2b433
/*
rpm-build d2b433
 * libopenraw - exception.h
rpm-build d2b433
 *
rpm-build d2b433
 * Copyright (C) 2006-2014 Hubert Figuiere
rpm-build d2b433
 *
rpm-build d2b433
 * This library is free software: you can redistribute it and/or
rpm-build d2b433
 * modify it under the terms of the GNU Lesser General Public License
rpm-build d2b433
 * as published by the Free Software Foundation, either version 3 of
rpm-build d2b433
 * the License, or (at your option) any later version.
rpm-build d2b433
 *
rpm-build d2b433
 * This library is distributed in the hope that it will be useful,
rpm-build d2b433
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rpm-build d2b433
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
rpm-build d2b433
 * Lesser General Public License for more details.
rpm-build d2b433
 *
rpm-build d2b433
 * You should have received a copy of the GNU Lesser General Public
rpm-build d2b433
 * License along with this library.  If not, see
rpm-build d2b433
 * <http://www.gnu.org/licenses/>.
rpm-build d2b433
 */
rpm-build d2b433
rpm-build d2b433
#ifndef OR_INTERNALS_EXCEPTION_H_
rpm-build d2b433
#define OR_INTERNALS_EXCEPTION_H_
rpm-build d2b433
rpm-build d2b433
#include <exception>
rpm-build d2b433
#include <string>
rpm-build d2b433
#include <typeinfo>
rpm-build d2b433
rpm-build d2b433
namespace OpenRaw {
rpm-build d2b433
namespace Internals {
rpm-build d2b433
rpm-build d2b433
/** generic OpenRaw exception */
rpm-build d2b433
class Exception
rpm-build d2b433
  : public std::exception
rpm-build d2b433
{
rpm-build d2b433
protected:
rpm-build d2b433
  std::string m_what;
rpm-build d2b433
public:
rpm-build d2b433
  Exception()
rpm-build d2b433
    : std::exception(),
rpm-build d2b433
      m_what()
rpm-build d2b433
    {}
rpm-build d2b433
  Exception(const std::string &w)
rpm-build d2b433
    : std::exception(),
rpm-build d2b433
      m_what(w)
rpm-build d2b433
    {}
rpm-build d2b433
  virtual ~Exception()
rpm-build d2b433
    {}
rpm-build d2b433
  const char *what() const noexcept(true) override
rpm-build d2b433
    {
rpm-build d2b433
      if(m_what.empty()) {
rpm-build d2b433
        return typeid(this).name();
rpm-build d2b433
      }
rpm-build d2b433
      return m_what.c_str();
rpm-build d2b433
    }
rpm-build d2b433
};
rpm-build d2b433
rpm-build d2b433
/** IO exception */
rpm-build d2b433
class IOException
rpm-build d2b433
  : public Exception
rpm-build d2b433
{
rpm-build d2b433
public:
rpm-build d2b433
  IOException(const std::string &w)
rpm-build d2b433
    : Exception(w)
rpm-build d2b433
    {}
rpm-build d2b433
};
rpm-build d2b433
rpm-build d2b433
rpm-build d2b433
/** data is of bad type */
rpm-build d2b433
class BadTypeException
rpm-build d2b433
  : public Exception
rpm-build d2b433
{
rpm-build d2b433
rpm-build d2b433
};
rpm-build d2b433
rpm-build d2b433
/** data is of too big */
rpm-build d2b433
class TooBigException
rpm-build d2b433
  : public Exception
rpm-build d2b433
{
rpm-build d2b433
};
rpm-build d2b433
rpm-build d2b433
class OutOfRangeException
rpm-build d2b433
  : public Exception
rpm-build d2b433
{
rpm-build d2b433
};
rpm-build d2b433
rpm-build d2b433
class DecodingException
rpm-build d2b433
  : public Exception
rpm-build d2b433
{
rpm-build d2b433
public:
rpm-build d2b433
  DecodingException(const std::string &w)
rpm-build d2b433
    : Exception(w)
rpm-build d2b433
    {}
rpm-build d2b433
};
rpm-build d2b433
rpm-build d2b433
}
rpm-build d2b433
}
rpm-build d2b433
rpm-build d2b433
#endif
rpm-build d2b433
/*
rpm-build d2b433
  Local Variables:
rpm-build d2b433
  mode:c++
rpm-build d2b433
  c-file-style:"stroustrup"
rpm-build d2b433
  c-file-offsets:((innamespace . 0))
rpm-build d2b433
  tab-width:2
rpm-build d2b433
  c-basic-offset:2
rpm-build d2b433
  indent-tabs-mode:nil
rpm-build d2b433
  fill-column:80
rpm-build d2b433
  End:
rpm-build d2b433
*/