File: exception.yo

package info (click to toggle)
bobcat 6.11.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,292 kB
  • sloc: cpp: 21,370; fortran: 6,507; makefile: 2,787; sh: 724; perl: 401; ansic: 26
file content (279 lines) | stat: -rw-r--r-- 11,082 bytes parent folder | download | duplicates (3)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
includefile(include/header)

COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::Exception)(3bobcat)(_CurYrs_)(libbobcat-dev__CurVers_)
                    (insertable exception class)

manpagename(FBB::Exception)(std::exception objects acception stream insertions)

manpagesynopsis()
    bf(#include <bobcat/exception>)nl()
    Linking option: tt(-lbobcat)

manpagedescription()
       bf(FBB::Exception) objects derived from tt(std::exception), but accept
stream insertions. Their intended use consists of throwing an anonymous
object, into which the text of the tt(std::exception::what)
message has been inserted.

    tt(Exception) exceptions are thrown by several Bobcat classes. These
classes are tt(
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)


manpagesection(NAMESPACE)
    bf(FBB)nl()
    All constructors, members, operators and manipulators, mentioned in this
man-page, are defined in the namespace bf(FBB).

manpagesection(INHERITS FROM)
    bf(std::exception)

manpagesection(ENUMERATION)
    The enumeration tt(Protection) is used by the member tt(protection)
described below. The enumeration has two values:
    itemization(
    itt(ANY): an existing file may have any set of protection bits;
    itt(EQUAL): an existing file mut have exactly the set of protection bits
        as specified when calling tt(Exception::protection).
    )

manpagesection(CONSTRUCTORS)
    itemization(
    itb(Exception())
   The default constructor (assigns 0 to tt(FBB::g_errno), see the next
    constructor).

    itb(Exception(int errnoValue))
   This constructor stores the provided tt(errnoValue) value in a thread-local
    variable tt(int FBB::g_errno). Before Bobcat 4.04.00 tt(errnoValue) was
    only stored in the global tt(::errno) variable (it still is), but as this
    variable is also used by many other functions, tt(errno's) value may have
    changed by the time the exception is caught. The tt(thread_local int
    FBB::g_errno) variable does not have that drawback.

    When tt(g_errno) must be declared without including  tt(bobcat/exception)
    then do
        verb(
    namespace FBB
    {
        extern thread_local int g_errno;
    }
        )
    )

    Copy and move constructors (and assignment operators) are available.

manpagesection(MEMBER FUNCTIONS)
     All members of bf(std::exception) are
available, as bf(FBB::Exception) inherits from this class.
    itemization(
    itb(char const *what() const noexcept(true) override)
    Returns the text that was inserted into the bf(FBB::Exception) object.
    )

manpagesection(OVERLOADED OPERATORS)
    itemization(
    itb(Exception &&operator<<(Exception &&in, Type const &t))
    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
tt(ostringstream) object.
    )


manpagesection(STATIC MEMBERS)

    The following convenience functions can be used for controlled opening of
stream-type objects, like tt(std::ofstream) and tt(std::ifstream)
objects. These stream-type objects must support tt(open) and tt(close)
members, like those provided by tt(std::ifstream) and tt(std::ofstream).

If the stream  was already open it is first closed.

If opening fails an tt(FBB::Exception) exception is thrown containing a
short message stating that the named stream could not be opened.

    itemization(
    itb(static StreamType factory<StreamType>(std::string const &name))
       Returns an open tt(StreamType>) stream object which can be used to
        move-construct a tt(StreamType) object. E.g.,
            verb(
    auto out{ Exception::factory<ofstream>("/tmp/out") };
            )

    itb(static StreamType factory<StreamType>(int errnoValue,
                                              std::string const &name))
        Returns an open tt(StreamType>) stream object which can be used to
        move-construct a tt(StreamType) object. If constructing
        the stream object fails, then the thrown bf(FBB::Exception) assigns
        tt(errnoValue) to tt(FBB::g_errno).

    itb(static StreamType factory<StreamType>(std::string const &name,
                                              std::ios::openmode mode))
       Returns an open tt(StreamType>) stream object, created using
        the tt(openmode mode) flags,  which can be used to
        move-construct a tt(StreamType) object.

    itb(static StreamType factory<StreamType>(int errnoValue,
                                              std::string const &name,
                                              std::ios::openmode mode))
       Returns an open tt(StreamType>) stream object, created using
        the tt(openmode mode) flags,  which can be used to
        move-construct a tt(StreamType) object.  If constructing
        the stream object fails, then the thrown bf(FBB::Exception) assigns
        tt(errnoValue) to tt(FBB::g_errno).

    itb(static StreamType factory<StreamType>(std::string const &name,
                                              std::ios::openmode mode1,
                                              std::ios::openmode mode2))
       Returns an open tt(StreamType>) stream object. the stream is initially
        opened using tt(mode1). If that fails, tt(mode2) is used. If both ways
        to open the stream fail, then an tt(Exception) is thrown.  The
        returned stream can be used to move-construct a tt(StreamType) object.
        This member can be used to open an tt(std::fstream) which may or may
        not yet exist for both reading and writing. E.g.,
            verb(
    auto out{ Exception::factory<fstream>("/tmp/out",
                ios::in | ios::out,
                ios::in | ios::out | ios::trunc) };
            )
       If tt(/tmp/out) already exists, then tt(ios::in | ios::out) should
        succeed. If it doesn't, then it's created empty for reading and
        writing, using tt(ios::in | ios::out | ios::trunc).

    itb(static StreamType factory<StreamType>(int errnoValue,
                                              std::string const &name,
                                              std::ios::openmode mode1,
                                              std::ios::openmode mode2))
       Returns an open tt(StreamType>) stream object. the stream is initially
        opened using tt(mode1). If that fails, tt(mode2) is used. If both ways
        to open the stream fail, then an tt(Exception) is thrown, assigning
        tt(errnoValue) to tt(FBB::g_errno).

    itb(static void open(int errnoValue, StreamType &stream,
                        std::string const &name, std::ios::openmode mode))
       Opens the stream object, using its tt(open) member, passing tt(mode) to
        tt(open). If opening the stream fails, then the thrown
        bf(FBB::Exception) assigns tt(errnoValue) to tt(FBB::g_errno).

    itb(static void open(StreamType &stream, std::string const &name))
        Opens the stream object, using its default tt(open) member.

    itb(static void open(int errnoValue,
                         StreamType &stream, std::string const &name))
       Opens the stream object, using its default tt(open) member. If opening
        the stream fails, then the thrown bf(FBB::Exception) assigns
        tt(errnoValue) to tt(FBB::g_errno).

    itb(static void open(StreamType &stream, std::string const &name,
                                    std::ios::openmode mode))
       Opens the stream object, using its tt(open) member, passing tt(mode) to
        tt(open).

    itb(static void open(int errnoValue, StreamType &stream,
                        std::string const &name, std::ios::openmode mode))
       Opens the stream object, using its tt(open) member, passing tt(mode) to
        tt(open). If opening the stream fails, then the thrown
        bf(FBB::Exception) assigns tt(errnoValue) to tt(FBB::g_errno).

    itb(static void open(StreamType &stream, std::string const &name,
                                    std::ios::openmode mode1,
                                    std::ios::openmode mode2))
       Opens the stream object, using its tt(open) member, , initially passing
        tt(mode1) to tt(open). If that fails, tt(mode2) is used. If both ways
        to open the stream fail, then an tt(Exception) is thrown.

    itb(static void open(int errnoValue, StreamType &stream,
                        std::string const &name, std::ios::openmode mode1,
                                    std::ios::openmode mode2))
       Opens the stream object, using its tt(open) member, initially passing
        tt(mode1) to tt(open). If that fails, tt(mode2) is used. If both ways
        to open the stream fail, then an tt(Exception) is thrown, assigning
        tt(errnoValue) to tt(FBB::g_errno).

    itb(static size_t protection(std::string const &path, size_t protect,
                          Protection type = EQUAL))
       Returns the protection bits (cf. bf(open)(2)) of tt(path). The
        tt(protect) 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 tt(ANY) the file's actual permission bits are not
        compared with tt(protect); if specified as tt(EQUAL) the file's
        permission bits must be identical to tt(protect), or an exception is
        thrown. If tt(path) does not yet exist a file tt(path) with permission
        tt(protect) is created. This member returns tt(path)'s permission
        bits.

        If tt(path) is created by tt(protection), then opening a stream for
        tt(path) does not change tt(path)'s protection.
    )

manpagesection(MANIPULATOR)

    The following manipulator (which is em(not) part of the
bf(FBB::Exception), class, but em(is) defined in the bf(FBB) namespace) can be
inserted into the bf(FBB::Exception) object:
    itemization(
    itb(FBB::errnodescr)
        The descriptive text associated with the current tt(errno) value is
inserted into the bf(FBB::Exception) object (it can also be used to insert the
descriptive text in a tt(std::ostream) object). No text is inserted if
tt(errno) equals zero. This manipulator is thread-safe (but tt(errno) may be
modified when tt(errno) holds an invalid value).
    )

manpagesection(EXAMPLE)
        verb(
    if (exceptionalCondition)
        throw FBB::Exception{ 1 } << "Exceptional condition occurred";
        )

manpagefiles()
    em(bobcat/exception) - defines the class interface

manpageseealso()
    bf(bobcat)(7)

manpagebugs()
    None Reported.

includefile(include/trailer)