.TH "FBB::Exception" "3bobcat" "2005\-2020" "libbobcat\-dev_5\&.07\&.00" "Error handler" .PP .SH "NAME" FBB::Exception \- std::exception objects acception stream insertions .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" \fBFBB::Exception\fP objects derived from \fIstd::exception\fP, but accept stream insertions\&. Their intended use consists of throwing an anonymous object, into which the text of the \fIstd::exception::what\fP message has been inserted\&. .PP \fIException\fP exceptions are thrown by several Bobcat classes\&. These classes are \fI Arg, ArgConfig, BigInt, Cgi, Cidr, ClientSocket, CmdFinderBase, ConfigFile, DateTime, DecryptBuf, DigestBuf, EncryptBuf, Fork, GetHostent, Glob, HMacBuf, Hostname, LocalClientSocket, LocalServerSocket, LocalSocketBase, Log, MailHeaders, Mbuf, Milter, Mstream, OFoldBuf, OneKey, Pattern, Pipe, Process, Redirector, Selector, ServerSocket, Signal, SocketBase, Stat, TempStream, User, Xpointer\fP .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \fBstd::exception\fP .PP .SH "ENUMERATION" The enumeration \fIProtection\fP is used by the member \fIprotection\fP described below\&. The enumeration has two values: .IP o \fIANY\fP: an existing file may have any set of protection bits; .IP o \fIEQUAL\fP: an existing file mut have exactly the set of protection bits as specified when calling \fIException::protection\fP\&. .PP .SH "CONSTRUCTORS" .IP o \fBException()\fP: .br The default constructor (assigns 0 to \fIFBB::g_errno\fP, see the next constructor)\&. .IP .IP o \fBException(int errnoValue)\fP: .br This constructor stores the provided \fIerrnoValue\fP value in a thread\-local variable \fIint FBB::g_errno\fP\&. Before Bobcat 4\&.04\&.00 \fIerrnoValue\fP was only stored in the global \fI::errno\fP variable (it still is), but as this variable is also used by many other functions, \fIerrno\(cq\&s\fP value may have changed by the time the exception is caught\&. The \fIthread_local int FBB::g_errno\fP variable does not have that drawback\&. .IP When \fIg_errno\fP must be declared without including \fIbobcat/exception\fP then do .nf namespace FBB { extern thread_local int g_errno; } .fi .PP Copy and move constructors (and assignment operators) are available\&. .PP .SH "MEMBER FUNCTIONS" All members of \fBstd::exception\fP are available, as \fBFBB::Exception\fP inherits from this class\&. .IP o \fBchar const *what() const noexcept(true) override\fP: .br Returns the text that was inserted into the \fBFBB::Exception\fP object\&. .PP .SH "OVERLOADED OPERATORS" .IP o \fBException &&operator<<(Exception &&in, Type const &t)\fP: .br A function template implementing the overloaded insertion operator\&. It can be used to insert values of any type that can also be inserted into an \fIostringstream\fP object\&. .PP .SH "STATIC MEMBERS" .PP The following convenience functions can be used for controlled opening of stream\-type objects, like \fIstd::ofstream\fP and \fIstd::ifstream\fP objects\&. These stream\-type objects must support \fIopen\fP and \fIclose\fP members, like those provided by \fIstd::ifstream\fP and \fIstd::ofstream\fP\&. .PP If the stream was already open it is first closed\&. .PP If opening fails an \fIFBB::Exception\fP exception is thrown containing a short message stating that the named stream could not be opened\&. .PP .IP o \fBstatic StreamType factory(std::string const &name)\fP: .br Returns an open \fIStreamType>\fP stream object which can be used to move\-construct a \fIStreamType\fP object\&. E\&.g\&., .nf auto out{ Exception::factory(\(dq\&/tmp/out\(dq\&) }; .fi .IP .IP o \fBstatic StreamType factory(int errnoValue, std::string const &name)\fP: .br Returns an open \fIStreamType>\fP stream object which can be used to move\-construct a \fIStreamType\fP object\&. If constructing the stream object fails, then the thrown \fBFBB::Exception\fP assigns \fIerrnoValue\fP to \fIFBB::g_errno\fP\&. .IP .IP o \fBstatic StreamType factory(std::string const &name, std::ios::openmode mode)\fP: .br Returns an open \fIStreamType>\fP stream object, created using the \fIopenmode mode\fP flags, which can be used to move\-construct a \fIStreamType\fP object\&. .IP .IP o \fBstatic StreamType factory(int errnoValue, std::string const &name, std::ios::openmode mode)\fP: .br Returns an open \fIStreamType>\fP stream object, created using the \fIopenmode mode\fP flags, which can be used to move\-construct a \fIStreamType\fP object\&. If constructing the stream object fails, then the thrown \fBFBB::Exception\fP assigns \fIerrnoValue\fP to \fIFBB::g_errno\fP\&. .IP .IP o \fBstatic StreamType factory(std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2)\fP: .br Returns an open \fIStreamType>\fP stream object\&. the stream is initially opened using \fImode1\fP\&. If that fails, \fImode2\fP is used\&. If both ways to open the stream fail, then an \fIException\fP is thrown\&. The returned stream can be used to move\-construct a \fIStreamType\fP object\&. This member can be used to open an \fIstd::fstream\fP which may or may not yet exist for both reading and writing\&. E\&.g\&., .nf auto out{ Exception::factory(\(dq\&/tmp/out\(dq\&, ios::in | ios::out, ios::in | ios::out | ios::trunc) }; .fi If \fI/tmp/out\fP already exists, then \fIios::in | ios::out\fP should succeed\&. If it doesn\(cq\&t, then it\(cq\&s created empty for reading and writing, using \fIios::in | ios::out | ios::trunc\fP\&. .IP .IP o \fBstatic StreamType factory(int errnoValue, std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2)\fP: .br Returns an open \fIStreamType>\fP stream object\&. the stream is initially opened using \fImode1\fP\&. If that fails, \fImode2\fP is used\&. If both ways to open the stream fail, then an \fIException\fP is thrown, assigning \fIerrnoValue\fP to \fIFBB::g_errno\fP\&. .IP .IP o \fBstatic void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode)\fP: .br Opens the stream object, using its \fIopen\fP member, passing \fImode\fP to \fIopen\fP\&. If opening the stream fails, then the thrown \fBFBB::Exception\fP assigns \fIerrnoValue\fP to \fIFBB::g_errno\fP\&. .IP .IP o \fBstatic void open(StreamType &stream, std::string const &name)\fP: .br Opens the stream object, using its default \fIopen\fP member\&. .IP .IP o \fBstatic void open(int errnoValue, StreamType &stream, std::string const &name)\fP: .br Opens the stream object, using its default \fIopen\fP member\&. If opening the stream fails, then the thrown \fBFBB::Exception\fP assigns \fIerrnoValue\fP to \fIFBB::g_errno\fP\&. .IP .IP o \fBstatic void open(StreamType &stream, std::string const &name, std::ios::openmode mode)\fP: .br Opens the stream object, using its \fIopen\fP member, passing \fImode\fP to \fIopen\fP\&. .IP .IP o \fBstatic void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode)\fP: .br Opens the stream object, using its \fIopen\fP member, passing \fImode\fP to \fIopen\fP\&. If opening the stream fails, then the thrown \fBFBB::Exception\fP assigns \fIerrnoValue\fP to \fIFBB::g_errno\fP\&. .IP .IP o \fBstatic void open(StreamType &stream, std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2)\fP: .br Opens the stream object, using its \fIopen\fP member, , initially passing \fImode1\fP to \fIopen\fP\&. If that fails, \fImode2\fP is used\&. If both ways to open the stream fail, then an \fIException\fP is thrown\&. .IP .IP o \fBstatic void open(int errnoValue, StreamType &stream, std::string const &name, std::ios::openmode mode1, std::ios::openmode mode2)\fP: .br Opens the stream object, using its \fIopen\fP member, initially passing \fImode1\fP to \fIopen\fP\&. If that fails, \fImode2\fP is used\&. If both ways to open the stream fail, then an \fIException\fP is thrown, assigning \fIerrnoValue\fP to \fIFBB::g_errno\fP\&. .IP .IP o \fBstatic size_t protection(std::string const &path, size_t protect, Protection type = EQUAL)\fP: .br Returns the protection bits (cf\&. \fBopen\fP(2)) of \fIpath\fP\&. The \fIprotect\fP parameter is used to specify the requested protection bits\&. This value is usually specified as an octal value\&. If the specified value exceeds 0777 an exception is thrown\&. The third parameter is only used in combination with already existing files\&. If specified as \fIANY\fP the file\(cq\&s actual permission bits are not compared with \fIprotect\fP; if specified as \fIEQUAL\fP the file\(cq\&s permission bits must be identical to \fIprotect\fP, or an exception is thrown\&. If \fIpath\fP does not yet exist a file \fIpath\fP with permission \fIprotect\fP is created\&. This member returns \fIpath\fP\(cq\&s permission bits\&. .IP If \fIpath\fP is created by \fIprotection\fP, then opening a stream for \fIpath\fP does not change \fIpath\fP\(cq\&s protection\&. .PP .SH "MANIPULATOR" .PP The following manipulator (which is \fInot\fP part of the \fBFBB::Exception\fP, class, but \fIis\fP defined in the \fBFBB\fP namespace) can be inserted into the \fBFBB::Exception\fP object: .IP o \fBFBB::errnodescr\fP: .br The descriptive text associated with the current \fIerrno\fP value is inserted into the \fBFBB::Exception\fP object (it can also be used to insert the descriptive text in a \fIstd::ostream\fP object)\&. No text is inserted if \fIerrno\fP equals zero\&. This manipulator is thread\-safe (but \fIerrno\fP may be modified when \fIerrno\fP holds an invalid value)\&. .PP .SH "EXAMPLE" .nf if (exceptionalCondition) throw FBB::Exception{ 1 } << \(dq\&Exceptional condition occurred\(dq\&; .fi .PP .SH "FILES" \fIbobcat/exception\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7) .PP .SH "BUGS" None Reported\&. .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_5\&.07\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_5\&.07\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_5\&.07\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP