libthrowable::ColoredString Class Reference

Class for printing colored text to a terminal. More...

#include <libthrowable/color.h>

List of all members.

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.


std::ostream & operator<< (std::ostream &os, const ColoredString &str) throw ()

Detailed Description

Class for printing colored text to a terminal.

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;
will print a blue message saying Hello, blue world!.

Constructor & Destructor Documentation

libthrowable::ColoredString::ColoredString ( const std::string &  str,
unsigned  fgColor = c_nochange,
unsigned  bgColor = c_nochange 
) throw ()

Member Function Documentation

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);
will yield an invalid color. Also, a color like is not considered a color, because it does not change the output in any way.

static void libthrowable::ColoredString::disable ( bool  arg = true  )  throw () [inline, static]

Disables any colored output.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const ColoredString str 
) throw () [friend]

The documentation for this class was generated from the following file:
Generated on Wed Jan 9 18:07:17 2008 for libthrowable by  doxygen 1.5.4  Hosted on Logo