#include <libthrowable/color.h>
Public Member Functions | |
ColoredString (const std::string &str, unsigned fgColor=c_nochange, unsigned bgColor=c_nochange) throw () | |
unsigned | getFgColor () const throw () |
unsigned | getBgColor () const throw () |
bool | hasColor () const throw () |
Checks whether the color is valid. | |
Static Public Member Functions | |
static void | disable (bool arg=true) throw () |
Disables any colored output. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const ColoredString &str) throw () |
This class can be used to print text with a specific foreground and background color. Usage is simple and straightforward: Something like
cout << ColoredString("Hello, blue world!", c_blue) << endl;
Hello, blue world!
. libthrowable::ColoredString::ColoredString | ( | const std::string & | str, | |
unsigned | fgColor = c_nochange , |
|||
unsigned | bgColor = c_nochange | |||
) | throw () |
unsigned libthrowable::ColoredString::getFgColor | ( | ) | const throw () [inline] |
unsigned libthrowable::ColoredString::getBgColor | ( | ) | const throw () [inline] |
bool libthrowable::ColoredString::hasColor | ( | ) | const throw () |
Checks whether the color is valid.
Invalid colors are colors that don't exist, for example something like
ColoredString str("foo", 666, 666);
ColoredString color("foo", c_nochange, c_nochange)
static void libthrowable::ColoredString::disable | ( | bool | arg = true |
) | throw () [inline, static] |
Disables any colored output.
std::ostream& operator<< | ( | std::ostream & | os, | |
const ColoredString & | str | |||
) | throw () [friend] |