Jpp  17.3.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
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. More...
 
virtual const char * c_str (const JColor_t color) const override
 Print color. More...
 
virtual JColorFacetELcodeclone () const override
 Clone this facet. More...
 

Static Public Member Functions

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

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

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.
Definition: JColorFacet.hh:57

Member Function Documentation

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  }
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  }
static bool is_bold(const int color)
Check bold.
Definition: JColorFacet.hh:97
static bool is_color(const int color)
Check color.
Definition: JColorFacet.hh:85
std::vector< int > history
Definition: JColorFacet.hh:265
then awk string
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.
Definition: JColorFacet.hh:204
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_bold(const int color)
Check bold.
Definition: JColorFacet.hh:97
static bool is_reset(const int color)
Check reset.
Definition: JColorFacet.hh:109
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  }
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

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

Definition at line 265 of file JColorFacet.hh.

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: