OOStuBS - Technische Informatik II (TI-II)  2.4
o_stream.h
gehe zur Dokumentation dieser Datei
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2  * Technische Informatik II *
3  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
4  * *
5  * O _ S T R E A M *
6  * *
7 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8 
9 #ifndef __o_stream_include__
10 #define __o_stream_include__
11 
12 /* INCLUDES */
13 #include "common/strbuf.h"
14 
15 /* CLASSES */
16 
26 enum Colors{
29 };
30 
38 class FGColor{
39  public:
48  FGColor(Colors color) : color(color){}
49 };
50 
58 class BGColor{
59  public:
68  BGColor(Colors color) : color(color){}
69 };
70 
78 class Blink{
79  public:
83  bool blink;
88  Blink(bool blink) : blink(blink){}
89 };
90 
91 
102 class O_Stream : public Stringbuffer{
103  protected:
106  int fgColor;
109  int bgColor;
112  bool blink;
113 
147  virtual void setAttributes(int fgColor, int bgColor, bool blink) = 0;
148 
149  public:
150 
154  enum Base{
155  bin=2,
156  oct=8,
157  dec=10,
158  hex=16
159  };
160 
165 
169  O_Stream();
170 
174  virtual ~O_Stream();
175 
187  O_Stream& operator << (char value);
188 
190  O_Stream& operator << (unsigned char value);
191 
193  O_Stream& operator << (char* value);
194 
196  O_Stream& operator << (const char* value);
197 
199  O_Stream& operator << (unsigned short value);
200 
202  O_Stream& operator << (short value);
203 
205  O_Stream& operator << (unsigned int value);
206 
208  O_Stream& operator << (int value);
209 
211  O_Stream& operator << (unsigned long value);
212 
214  O_Stream& operator << (long value);
215 
217  O_Stream& operator << (void* value);
218 
227 
236 
245 
256 
257  /* declaration for manipulator functions */
258  friend O_Stream& endl(O_Stream&);
259  friend O_Stream& bin(O_Stream&);
260  friend O_Stream& oct(O_Stream&);
261  friend O_Stream& dec(O_Stream&);
262  friend O_Stream& hex(O_Stream&);
263 };
264 
265 
266 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
267  * M A N I P U L A T O R E N *
268 \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
269 
270 /*
271  * The following methods receive and return a referenz to the current O_Stream
272  * object. Class O_Stream defines an operator that can be used to call this so
273  * called manipulators. It is eveen possible to embedd the output of the method
274  * into the input of the stream.
275  * Main goal of the manipulators is to influence the display of the following
276  * output (eg. by choosing a basis for the display of digits).
277  */
278 
280 O_Stream& endl(O_Stream &out);
281 
283 O_Stream& bin(O_Stream &out);
284 
286 O_Stream& oct(O_Stream &out);
287 
289 O_Stream& dec(O_Stream &out);
290 
292 O_Stream& hex(O_Stream &out);
293 
294 #endif