00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef H_LIBTHROWABLE_COLOR
00021 #define H_LIBTHROWABLE_COLOR
00022 #include <iostream>
00023 #include <string>
00024 #include "system.h"
00025
00026 namespace libthrowable {
00030 const unsigned
00031 c_white = 0,
00032 c_black = 1,
00033 c_yellow = 2,
00034 c_red = 3,
00035 c_magenta = 4,
00036 c_blue = 5,
00037 c_cyan = 6,
00038 c_green = 7,
00039 c_nochange = 8;
00042 const unsigned c_intensity = 128;
00043
00056 class LIBTHROWABLE_API ColoredString
00057 {
00058 public:
00059 ColoredString(const std::string& str, unsigned fgColor=c_nochange, unsigned bgColor=c_nochange) throw();
00060 friend LIBTHROWABLE_API std::ostream& operator<<(std::ostream& os, const ColoredString& str) throw();
00061
00062 unsigned getFgColor() const throw()
00063 { return _fgColor; }
00064 unsigned getBgColor() const throw()
00065 { return _bgColor; }
00066
00083 bool hasColor() const throw();
00084
00088 static void disable(bool arg=true) throw()
00089 { _disabled = arg; }
00090
00091 private:
00092 std::string _str;
00093 unsigned _fgColor, _bgColor;
00094
00095 static bool _disabled;
00096 };
00098 }
00099 #endif