JAPAn
Just Another Parity Analyzer
Loading...
Searching...
No Matches
QwColor Class Reference

A color changing class for the output stream. More...

#include <QwColor.h>

+ Collaboration diagram for QwColor:

Public Member Functions

 QwColor (const Qw::EQwColor f=Qw::kDefaultForeground, const Qw::EQwColor b=Qw::kDefaultBackground)
 Default constructor.
 
virtual ~QwColor ()
 

Static Protected Member Functions

static QwColorMap CreateColorMap ()
 

Static Protected Attributes

static QwColorMap kColorMap = QwColor::CreateColorMap()
 

Private Attributes

Qw::EQwColor foreground
 Foreground color.
 

Friends

std::ostream & operator<< (std::ostream &out, const QwColor &color)
 Output stream operator.
 

Detailed Description

A color changing class for the output stream.

This class changes the color in the output stream by inserting 'magic' escape sequences that are interpreted by smart terminals. On dumb terminals this will probably just print garbage. To use the color, a QwColor object should be streamed to the output stream:

QwMessage << "Hello, " << QwColor(Qw::kRed) << "Qweak!" << QwLog::endl;
#define QwMessage
Predefined log drain for regular messages.
Definition QwLog.h:49
@ kRed
Definition QwColor.h:77
QwColor(const Qw::EQwColor f=Qw::kDefaultForeground, const Qw::EQwColor b=Qw::kDefaultBackground)
Default constructor.
Definition QwColor.h:107
static std::ostream & endl(std::ostream &)
End of the line.
Definition QwLog.cc:297

Definition at line 102 of file QwColor.h.

Constructor & Destructor Documentation

◆ QwColor()

QwColor::QwColor ( const Qw::EQwColor f = Qw::kDefaultForeground,
const Qw::EQwColor b = Qw::kDefaultBackground )
inline

Default constructor.

Definition at line 107 of file QwColor.h.

108 : foreground(f) { };
Qw::EQwColor foreground
Foreground color.
Definition QwColor.h:151

References foreground, Qw::kDefaultBackground, and Qw::kDefaultForeground.

Referenced by operator<<.

+ Here is the caller graph for this function:

◆ ~QwColor()

virtual QwColor::~QwColor ( )
inlinevirtual

Definition at line 109 of file QwColor.h.

109{ };

Member Function Documentation

◆ CreateColorMap()

static QwColorMap QwColor::CreateColorMap ( )
inlinestaticprotected

Definition at line 116 of file QwColor.h.

116 {
117 QwColorMap map;
118 map[Qw::kBlack] = BLACK;
119 map[Qw::kRed] = RED;
120 map[Qw::kGreen] = GREEN;
121 map[Qw::kBrown] = BROWN;
122 map[Qw::kBlue] = BLUE;
123 map[Qw::kMagenta] = MAGENTA;
124 map[Qw::kCyan] = CYAN;
125 map[Qw::kWhite] = WHITE;
126 //
127 map[Qw::kBold] = BOLD;
128 //
129 map[Qw::kBoldRed] = BOLDRED;
132 map[Qw::kBoldBlue] = BOLDBLUE;
134 map[Qw::kBoldCyan] = BOLDCYAN;
136 //
137 map[Qw::kBackRed] = BACKRED;
139 map[Qw::kBackBlue] = BACKBLUE;
140 //
141 map[Qw::kDefaultForeground] = "\033[39m";
142 map[Qw::kDefaultBackground] = "\033[49m";
143 //
144 map[Qw::kNormal] = NORMAL;
145 return map;
146 };
#define BOLDBLUE
Definition QwColor.h:54
#define NORMAL
Definition QwColor.h:65
std::map< Qw::EQwColor, std::string > QwColorMap
Definition QwColor.h:87
#define BOLD
Definition QwColor.h:41
#define BOLDGREEN
Definition QwColor.h:52
#define BOLDBROWN
Definition QwColor.h:53
#define MAGENTA
Definition QwColor.h:37
#define BLUE
Definition QwColor.h:36
#define BACKRED
Definition QwColor.h:59
#define BLACK
Definition QwColor.h:32
#define WHITE
Definition QwColor.h:39
#define RED
Definition QwColor.h:33
#define BACKGREEN
Definition QwColor.h:60
#define BOLDWHITE
Definition QwColor.h:57
#define BROWN
Definition QwColor.h:35
#define BOLDRED
Definition QwColor.h:51
#define BOLDMAGENTA
Definition QwColor.h:55
#define GREEN
Definition QwColor.h:34
#define BACKBLUE
Definition QwColor.h:61
#define CYAN
Definition QwColor.h:38
#define BOLDCYAN
Definition QwColor.h:56
@ kDefaultBackground
Definition QwColor.h:80
@ kWhite
Definition QwColor.h:77
@ kBackBlue
Definition QwColor.h:80
@ kCyan
Definition QwColor.h:77
@ kBold
Definition QwColor.h:78
@ kBoldCyan
Definition QwColor.h:79
@ kBrown
Definition QwColor.h:77
@ kBoldWhite
Definition QwColor.h:79
@ kBoldRed
Definition QwColor.h:79
@ kBoldGreen
Definition QwColor.h:79
@ kBoldBrown
Definition QwColor.h:79
@ kBoldBlue
Definition QwColor.h:79
@ kBoldMagenta
Definition QwColor.h:79
@ kBlue
Definition QwColor.h:77
@ kGreen
Definition QwColor.h:77
@ kDefaultForeground
Definition QwColor.h:77
@ kBackRed
Definition QwColor.h:80
@ kBackGreen
Definition QwColor.h:80
@ kBlack
Definition QwColor.h:77
@ kMagenta
Definition QwColor.h:77
@ kNormal
Definition QwColor.h:81

References BACKBLUE, BACKGREEN, BACKRED, BLACK, BLUE, BOLD, BOLDBLUE, BOLDBROWN, BOLDCYAN, BOLDGREEN, BOLDMAGENTA, BOLDRED, BOLDWHITE, BROWN, CYAN, GREEN, Qw::kBackBlue, Qw::kBackGreen, Qw::kBackRed, Qw::kBlack, Qw::kBlue, Qw::kBold, Qw::kBoldBlue, Qw::kBoldBrown, Qw::kBoldCyan, Qw::kBoldGreen, Qw::kBoldMagenta, Qw::kBoldRed, Qw::kBoldWhite, Qw::kBrown, Qw::kCyan, Qw::kDefaultBackground, Qw::kDefaultForeground, Qw::kGreen, Qw::kMagenta, Qw::kNormal, Qw::kRed, Qw::kWhite, MAGENTA, NORMAL, RED, and WHITE.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const QwColor & color )
friend

Output stream operator.

Definition at line 156 of file QwColor.h.

157{
158 return out << color.kColorMap[color.foreground];
159}
static QwColorMap kColorMap
Definition QwColor.h:147

References foreground, kColorMap, and QwColor().

Field Documentation

◆ foreground

Qw::EQwColor QwColor::foreground
private

Foreground color.

Definition at line 151 of file QwColor.h.

Referenced by operator<<, and QwColor().

◆ kColorMap

QwColorMap QwColor::kColorMap = QwColor::CreateColorMap()
staticprotected

Definition at line 147 of file QwColor.h.

Referenced by operator<<.


The documentation for this class was generated from the following files: