File: msg

package info (click to toggle)
bobcat 3.01.00-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,612 kB
  • sloc: cpp: 12,107; makefile: 8,055; perl: 401; sh: 329
file content (124 lines) | stat: -rw-r--r-- 2,681 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
#ifndef INCLUDED_BOBCAT_MSG_
#define INCLUDED_BOBCAT_MSG_

#include <iterator>

#include <sstream>
#include <fstream>
#include <string>

#include <bobcat/errno>

namespace FBB
{

void info(std::ostream &out);
void spool(std::ostream &out);
void warning(std::ostream &out);
void err(std::ostream &out);
void fatal(std::ostream &out);

std::ostringstream &msg();
std::ostringstream &lineMsg();

class Msg
{
    friend void err(std::ostream &out);
    friend void spool(std::ostream &out);
    friend void info(std::ostream &out);
    friend void warning(std::ostream &out);
    friend void fatal(std::ostream &out);

    friend std::ostringstream &msg();
    friend std::ostringstream &msgstream();
    friend std::ostringstream &lineMsg();

    static size_t s_line;    
    static char const *s_warning;
    static size_t s_warnCount;
    static size_t s_count;
    static size_t s_maxCount;
    static std::ostringstream s_msg;
    static std::ostream s_out;
    static std::ostream s_info;
    static std::ofstream s_fout;
    static bool s_display;

    public:
        static bool display();
        static void open(std::ifstream &in, std::string const &name);
        static void open(std::ofstream &out, std::string const &name);
        static void open(std::ofstream &out, std::string const &name, 
                                            size_t protection);
        static bool setDisplay(bool mode);
        static void setOstream(std::string const &name);
        static void setLine(size_t linenr);
        static void setWarning(char const *pre = "[Warning] ");
        static void setMaxCount(size_t maxCount);
        static size_t count();
        static bool errors();
        static size_t warnings();
        static std::streambuf *setInfoBuf(std::streambuf *newBuffer,
                                          bool display = true);
        static std::streambuf *infoToWarning();
};


inline bool Msg::display()
{
    return s_display;
}

inline void Msg::setLine(size_t linenr)
{
    s_line = linenr;
}            

inline void Msg::setWarning(char const *pre)
{
    s_warning = pre;
}

inline void Msg::setMaxCount(size_t maxCount)
{
    s_maxCount = maxCount;
}
inline size_t Msg::count()
{
    return s_count;
}

inline bool Msg::errors()
{
    return s_count;
}

inline size_t Msg::warnings()
{
    return s_warnCount;
}

inline std::streambuf *Msg::infoToWarning()
{
    return setInfoBuf(s_out.rdbuf());
}

inline std::ostringstream &msgstream()
{
    return Msg::s_msg;
}

}   // namespace FBB

namespace std
{
    inline void operator<<(ostream &ostrstream, void (*manip)(ostream &str))
    {
        (*manip)(ostrstream);
    }
}    

#endif