/usr/include/bobcat/exception is in libbobcat-dev 3.23.01-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | #ifndef INCLUDED_BOBCAT_EXCEPTION_
#define INCLUDED_BOBCAT_EXCEPTION_
#include <string>
#include <sstream>
#include <exception>
#include <iosfwd>
namespace FBB
{
class Exception: public std::exception
{
template <typename Type>
friend Exception &&operator<<(Exception &&tmp, Type const &value);
std::string d_what;
public:
enum
{
STRERROR_BUFSIZE = 100
};
enum Protection
{
ANY,
EQUAL
};
Exception() = default;
explicit Exception(int errnoValue); // exception1.cc
~Exception() noexcept(true) override;
static size_t protection(std::string const &name, size_t protect,
Protection type = EQUAL);
template <typename StreamType>
static void open(StreamType &stream, // open1.f
std::string const &name);
template <typename StreamType>
static void open(int errnoValue, StreamType &stream, // open2.f
std::string const &name);
template <typename StreamType>
static void open(StreamType &stream, // open3.f
std::string const &name, std::ios::openmode mode);
template <typename StreamType>
static void open(int errnoValue, StreamType &stream, // open4.f
std::string const &name, std::ios::openmode mode);
private:
char const *what() const noexcept(true) override;
};
template <typename StreamType>
void Exception::open(StreamType &stream, std::string const &name)
{
if (stream.is_open())
stream.close();
stream.open(name);
if (!stream)
throw Exception() << "Can't open `" << name << '\'';
}
template <typename StreamType>
void Exception::open(int errnoValue, StreamType &stream,
std::string const &name)
{
if (stream.is_open())
stream.close();
stream.open(name);
if (!stream)
throw Exception(errnoValue) << "Can't open `" << name << '\'';
}
template <typename StreamType>
void Exception::open(StreamType &stream, std::string const &name,
std::ios::openmode mode)
{
if (stream.is_open())
stream.close();
stream.open(name, mode);
if (!stream)
throw Exception() << "Can't open `" << name << '\'';
}
template <typename StreamType>
void Exception::open(int errnoValue, StreamType &stream,
std::string const &name, std::ios::openmode mode)
{
if (stream.is_open())
stream.close();
stream.open(name, mode);
if (!stream)
throw Exception(errnoValue) << "Can't open `" << name << '\'';
}
// Free functions
std::ostream &errnodescr(std::ostream &out);
template <typename Type>
inline Exception &&operator<<(Exception &&tmp, Type const &value)
{
std::ostringstream out;
out << value;
tmp.d_what += out.str();
return std::move(tmp);
}
} // FBB
#endif
|