Jpp 19.3.0-rc.3
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JColorFacetELcode Struct Reference

Facet class to specify text color for ELcode. More...

#include <JColorFacet.hh>

Inheritance diagram for JLANG::JColorFacetELcode:
JLANG::JColorFacet

Public Member Functions

 JColorFacetELcode (std::size_t refs=0)
 Constructor.
 
virtual const char * c_str (const JColor_t color) const override
 Print color.
 
virtual JColorFacetELcodeclone () const override
 Clone this facet.
 

Static Public Member Functions

static const char * getName ()
 Get name of facet.
 
static bool is_color (const int color)
 Check color.
 
static bool is_bold (const int color)
 Check bold.
 
static bool is_reset (const int color)
 Check reset.
 

Static Public Attributes

static std::locale::id id
 

Private Attributes

std::vector< int > history
 

Detailed Description

Facet class to specify text color for ELcode.

Definition at line 185 of file JColorFacet.hh.

Constructor & Destructor Documentation

◆ JColorFacetELcode()

JLANG::JColorFacetELcode::JColorFacetELcode ( std::size_t refs = 0)
inline

Constructor.

Parameters
refsreference count

Definition at line 204 of file JColorFacet.hh.

204 :
205 JColorFacet(refs)
206 {}
JColorFacet(std::size_t refs=0)
Constructor.

Member Function Documentation

◆ getName()

static const char * JLANG::JColorFacetELcode::getName ( )
inlinestatic

Get name of facet.

Returns
name

Definition at line 193 of file JColorFacet.hh.

194 {
195 return "ELcode";
196 }

◆ c_str()

virtual const char * JLANG::JColorFacetELcode::c_str ( const JColor_t color) const
inlineoverridevirtual

Print color.

Parameters
colorcode
Returns
text

Implements JLANG::JColorFacet.

Definition at line 215 of file JColorFacet.hh.

216 {
217 static std::string buffer;
218
219 history.push_back(color);
220
221 switch (color) {
222
223 case RED: return "[color=red]";
224 case GREEN: return "[color=green]";
225 case BLUE: return "[color=blue]";
226 case WHITE: return "[color=white]";
227 case CYAN: return "[color=cyan]";
228 case PURPLE: return "[color=purple]";
229 case YELLOW: return "[color=yellow]";
230 case BOLD: return "[bold]";
231
232 case RESET:
233
234 buffer.clear();
235
236 for (std::vector<int>::const_reverse_iterator i = history.rbegin(); i != history.rend(); ++i) {
237 if (is_color(*i))
238 buffer += "[/color]";
239 else if (is_bold (*i))
240 buffer += "[/bold]";
241 else
242 ;
243 }
244
245 history.clear();
246
247 return buffer.c_str();
248
249 default: return "";
250 }
251 }
@ RED
red
@ PURPLE
purple
@ CYAN
cyan
@ RESET
reset
@ YELLOW
yellow
@ WHITE
white
@ GREEN
green
@ BOLD
bold
@ BLUE
blue
std::vector< int > history
static bool is_color(const int color)
Check color.
static bool is_bold(const int color)
Check bold.

◆ clone()

virtual JColorFacetELcode * JLANG::JColorFacetELcode::clone ( ) const
inlineoverridevirtual

Clone this facet.

Returns
pointer to newly created facet

Implements JLANG::JColorFacet.

Definition at line 259 of file JColorFacet.hh.

260 {
261 return new JColorFacetELcode();
262 }
JColorFacetELcode(std::size_t refs=0)
Constructor.

◆ is_color()

static bool JLANG::JColorFacet::is_color ( const int color)
inlinestaticinherited

Check color.

Parameters
colorcode
Returns
true if color; else false

Definition at line 85 of file JColorFacet.hh.

86 {
87 return !is_bold(color) && !is_reset(color);
88 }
static bool is_reset(const int color)
Check reset.

◆ is_bold()

static bool JLANG::JColorFacet::is_bold ( const int color)
inlinestaticinherited

Check bold.

Parameters
colorcode
Returns
true if bold; else false

Definition at line 97 of file JColorFacet.hh.

98 {
99 return color == BOLD;
100 }

◆ is_reset()

static bool JLANG::JColorFacet::is_reset ( const int color)
inlinestaticinherited

Check reset.

Parameters
colorcode
Returns
true if reset; else false

Definition at line 109 of file JColorFacet.hh.

110 {
111 return color == RESET;
112 }

Member Data Documentation

◆ history

std::vector<int> JLANG::JColorFacetELcode::history
mutableprivate

Definition at line 265 of file JColorFacet.hh.

◆ id

std::locale::id JLANG::JColorFacet::id
staticinherited
Author
mdejong

Definition at line 49 of file JColorFacet.hh.


The documentation for this struct was generated from the following file: