summaryrefslogtreecommitdiff
path: root/noncore/apps/tinykate/libkate/microkde/kdebug.h
Unidiff
Diffstat (limited to 'noncore/apps/tinykate/libkate/microkde/kdebug.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/microkde/kdebug.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/noncore/apps/tinykate/libkate/microkde/kdebug.h b/noncore/apps/tinykate/libkate/microkde/kdebug.h
new file mode 100644
index 0000000..9042644
--- a/dev/null
+++ b/noncore/apps/tinykate/libkate/microkde/kdebug.h
@@ -0,0 +1,112 @@
1#ifndef MINIKDE_KDEBUG_H
2#define MINIKDE_KDEBUG_H
3
4#include <stdio.h>
5
6#include <qstring.h>
7
8class kdbgstream;
9typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function
10
11class kdbgstream {
12 public:
13 kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) :
14 area(_area), level(_level), print(_print) { }
15 kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = true) :
16 output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) { }
17 ~kdbgstream()
18 {
19 if (!output.isEmpty()) {
20 fprintf(stderr,"ASSERT: debug output not ended with \\n\n");
21 *this << "\n";
22 }
23 }
24 kdbgstream &operator<<(bool i) {
25 if (!print) return *this;
26 output += QString::fromLatin1(i ? "true" : "false");
27 return *this;
28 }
29 kdbgstream &operator<<(short i) {
30 if (!print) return *this;
31 QString tmp; tmp.setNum(i); output += tmp;
32 return *this;
33 }
34 kdbgstream &operator<<(unsigned short i) {
35 if (!print) return *this;
36 QString tmp; tmp.setNum(i); output += tmp;
37 return *this;
38 }
39 kdbgstream &operator<<(char i) {
40 if (!print) return *this;
41 QString tmp; tmp.setNum(int(i)); output += tmp;
42 return *this;
43 }
44 kdbgstream &operator<<(unsigned char i) {
45 if (!print) return *this;
46 QString tmp; tmp.setNum(static_cast<unsigned int>(i)); output += tmp;
47 return *this;
48 }
49
50 kdbgstream &operator<<(int i) {
51 if (!print) return *this;
52 QString tmp; tmp.setNum(i); output += tmp;
53 return *this;
54 }
55 kdbgstream &operator<<(unsigned int i) {
56 if (!print) return *this;
57 QString tmp; tmp.setNum(i); output += tmp;
58 return *this;
59 }
60 kdbgstream &operator<<(long i) {
61 if (!print) return *this;
62 QString tmp; tmp.setNum(i); output += tmp;
63 return *this;
64 }
65 kdbgstream &operator<<(unsigned long i) {
66 if (!print) return *this;
67 QString tmp; tmp.setNum(i); output += tmp;
68 return *this;
69 }
70 kdbgstream &operator<<(const QString& string) {
71 if (!print) return *this;
72 output += string;
73 if (output.at(output.length() -1 ) == '\n')
74 flush();
75 return *this;
76 }
77 kdbgstream &operator<<(const char *string) {
78 if (!print) return *this;
79 output += QString::fromUtf8(string);
80 if (output.at(output.length() - 1) == '\n')
81 flush();
82 return *this;
83 }
84 kdbgstream &operator<<(const QCString& string) {
85 *this << string.data();
86 return *this;
87 }
88 kdbgstream& operator<<(KDBGFUNC f) {
89 if (!print) return *this;
90 return (*f)(*this);
91 }
92 kdbgstream& operator<<(double d) {
93 QString tmp; tmp.setNum(d); output += tmp;
94 return *this;
95 }
96 void flush() {
97 if (output.isEmpty() || !print)
98 return;
99 printf("%s",output.latin1());
100 output = QString::null;
101 }
102 private:
103 QString output;
104 unsigned int area, level;
105 bool print;
106};
107
108inline kdbgstream &endl( kdbgstream &s) { s << "\n"; return s; }
109
110inline kdbgstream kdDebug(int area = 0) { return kdbgstream(area, 0); }
111
112#endif