File: msg.yo

package info (click to toggle)
bobcat 1.18.1-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 3,920 kB
  • ctags: 575
  • sloc: makefile: 12,973; cpp: 6,284; perl: 401; ansic: 68; sh: 52
file content (186 lines) | stat: -rw-r--r-- 7,832 bytes parent folder | download
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
includefile(header.inc)

COMMENT(manpage, section, releasedate, archive, short name)
manpage(FBB::Msg)(3bobcat)(_CurYrs_)(libbobcat1-dev__CurVers_-x.tar.gz)
                    (Message handler)

manpagename(FBB::Msg)(Generic message handler)

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

manpagedescription()

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)
    -

manpagesection(CONSTRUCTORS)
    The class bf(Msg) only has static members. There are no constructors.


manpagesection(MEMBER FUNCTIONS)
    The class bf(Msg) only has static members. The member functions listed
below are not frequently used. They exist primarily to control the output
streams and to fine-tune the inner workings of the class' data members.
Instead, the class-less members bf(msg()) and bf(lineMsg()) (see below) and
the manipulators (see below) are used to create messages.

    itemization(
    itb(static size_t count())
        Returns the number of error messages generated so far.
    itb(static bool display())
        Returns tt(true) if the currently accumulated message will be
inserted into the message stream. This is the default case.
    itb(static size_t errors())
        Returns the number of error messages generated so far. Synonym of
bf(count()). 
    itb(static std::streambuf *infoToWarning())
        Following this call all `info'-messages will be written to the same
stream as warning messages. The function returns the bf(streambuf) used so
far. 
    itb(static void open(std::ifstream &in, std::string const &name))
        Convenience function opening the object tt(ifstream in) refers to. If
opening the stream fails, a message is displayed and a fatal error message is
generated. 
    itb(static void open(std::ofstream &in, std::string const &name))
        Convenience function opening the object tt(ofstream in) refers to. If
opening the stream fails, a message is displayed and a fatal error message is
generated. 
    itb(static bool setDisplay(bool mode))
        Changes the setting of the `display' variable. At bf(true) (Note that
the default is bf(false)) accumulated messages will be inserted into the
message stream.
    itb(static std::streambuf *setInfoBuf(std::streambuf *newBuffer,
                                          bool display = true))
        Define a new bf(streambuf) into which info-messages will be
inserted. The passed bf(streambuf) must remain in existence after the call. If
bf(newBuffer) is 0, the currently used bf(streambuf) is not altered.
The function returns the bf(streambuf) used so far.
    itb(static void setLine(size_t linenr))
        Set the value of the line-counter used with the bf(lineMsg)
manipulator (see below).
    itb(static void setMaxCount(size_t maxCount))
        Define the maximum number of error messages (using the bf(err)
manipulator, see below), before a fatal em(maximum number of error messsages
reached) message is generated. The default value is the maximum size_t
value; not reached in any practical situation.
    itb(static void setOstream(std::string const &name))
        Define the name of the stream to which messages will be written.
    itb(static void setWarning(char const *pre = "[Warning] "))
        Define the text printed ahead of warning messages. The default value
is equal to this member function's default argument value.
    itb(static size_t warnings())
        Returns the number of warning messages generated so far.
    )

manpagesection(FREE FUNCTIONS)
    Note that the following two functions are not members of the class
bf(Msg), but em(are) defined in the namespace bf(FBB).
    itemization(
    itb(std::ostringstream &linMsg())
        Information inserted into this function is used to compose a
message. Messages must be completed, using an appropriate manipulator, before
another message can be constructed. The final message is prefixed by
the text `tt(Line <nr>: )', where tt(<nr>) is the value last set by the member
function bf(setLine()). Note the blank trailing the colon.
    itb(std::ostringstream &msg())
        Information inserted into this function is used to compose a
message. Messages must be completed, using an appropriate manipulator, before
another message can be constructed. 
    itb(std::ostringstream &msgstream())
        Contrary to the function bf(msg), which will first clear the current
contents of the message buffer, bf(msgstream) returns the current stream `as
is'. This allows the use of certain Template Library algorithms, like
tt(copy). E.g., assuming that tt(std::vector<std::string> d_words) has been
defined, and using directives were specificied for the tt(std) and tt(FBB)
namespaces, then
        verb(
    copy(d_words.begin(), d_words.end(), ostream_iterator<string>(msg, " "));
    msgstream() << info;
        )
    can be used to insert the contents of tt(d_words), separated by a blank
space, into the tt(Msg) stream.
    )

manpagesection(MANIPULATORS)
    The following manipulators (which are em(not) part of the bf(FBB::Msg),
class, but em(are) defined in the bf(FBB) namespace) can be inserted into the
bf(FBB::Msg) object. All messages are by default inserted into the standard
output stream (tt(cout)).
    itemization(
    itb(FBB::err)
        An error message is generated. Error messages are prefixed by the text
`tt([Error <count>] )', where tt(<count>) counts the number of error messages
generated so far. If the maximum error count is exceeded (see
bf(setMaxCount()) above) a fatal message is generated as well. A newline is
added to the message by the manipulator.
    itb(FBB::fatal) 
        A fatal message is generated. Fatal messages are prefixed by the text
`tt([Fatal] )'. Following a fatal message an bf(Errno(1)) exception is
thrown.  A newline is added to the message by the manipulator.
    itb(FBB::info) 
        This manipulator generates an informational message. Information
messages may be controlled by the bf(setDisplay()) member (see above), and
have no further characteristics.  A newline is added to the message by the
manipulator.
    itb(FBB::spool) 
        This manipulator generates a (partial) informational message. 
bf(spool) does not add a newline message, but merrely flushes the stream's
buffer.
    itb(FBB::warning) 
        This manipulator generates a warning message. Warning
messages may be controlled by the bf(setDisplay()) member (see above). By
default the text `tt([Warning] )' is prefixed to the message, but the prefixed
message is configurable.  A newline is added to the message by the
manipulator.
    )

manpagesection(OVERLOADED OPERATOR)
    The following insertion operator is em(not) defined in the namespace
bf(FBB). It is part of the distribution to allow the manipulators to be
inserted into a bf(ostrstream):
    itemization(
    itb(void operator<<(std::ostream &ostrstream, void (*)(std::ostream &)))
        The second argument normally is one of the manipulators defined above.
    )

manpagesection(EXAMPLE)
        verb(
    #include <bobcat/msg>

    using namespace FBB;

    int main(int argc)
    try
    {
        if (argc == 1)
            msg() << "Need some arguments" << fatal;
        else
        {
            Msg::setDisplay(true);
            msg() << "Thanks for providing " << argc << 
                                    " arguments " << info;
        }
    }            
    catch(...)
    {
        msg() << "Got an Errno object, but ignoring it" << err;
    }
        )

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

manpageseealso()
    bf(bobcat)(7), bf(errno)(3bobcat), bf(indent)(3bobcat)

manpagebugs()
    None Reported.

includefile(trailer.inc)