color.h

Go to the documentation of this file.
00001 /* libthrowable - a C++ library to ease error handling and debugging
00002  *
00003  * Copyright (C) Joseph Lehner 2007 <deadbeef@gmx.at>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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

Generated on Wed Jan 9 18:07:17 2008 for libthrowable by  doxygen 1.5.4  Hosted on  SourceForge.net Logo