1#ifndef __JLANG__JCOLORFACET__
2#define __JLANG__JCOLORFACET__
21namespace JPP {
using namespace JLANG; }
47 public std::locale::facet
49 static std::locale::id
id;
58 std::locale::facet(refs)
97 static inline bool is_bold(
const int color)
111 return color ==
RESET;
156 case RED:
return "\033[91m";
157 case GREEN:
return "\033[92m";
158 case BLUE:
return "\033[94m";
159 case WHITE:
return "\033[97m";
160 case CYAN:
return "\033[96m";
161 case PURPLE:
return "\033[95m";
162 case YELLOW:
return "\033[93m";
163 case BOLD:
return "\033[1m";
164 case RESET:
return "\033[0m";
217 static std::string buffer;
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]";
236 for (std::vector<int>::const_reverse_iterator i =
history.rbegin(); i !=
history.rend(); ++i) {
238 buffer +=
"[/color]";
247 return buffer.c_str();
279 public std::map<std::string, JSinglePointer<JColorFacet> >
306 const_iterator p = find(key);
308 if (p != this->end()) {
348 const locale&
loc = out.getloc();
350 if (has_facet<JColorFacetASCII>(
loc))
351 return out << use_facet<JColorFacetASCII> (
loc).c_str(color);
352 else if (has_facet<JColorFacetELcode>(
loc))
353 return out << use_facet<JColorFacetELcode>(
loc).c_str(color);
std::ostream & operator<<(std::ostream &out, const JLANG::JColor_t color)
Print color.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Exception for null pointer operation.
Auxiliary classes and methods for language specific functionality.
void for_each(JObject_t &object, JType< JTypeList< JHead_t, JTail_t > > typelist)
For each data type method.
static const JColorFacetMap_t color_facets
Color facets.
JTYPELIST< JColorFacetASCII, JColorFacetELcode >::typelist JColorFacetTypes_t
Typelist of color facets.
JColor_t
Enumeration of text colors.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Facet class to specify text color for ASCII.
virtual JColorFacetASCII * clone() const override
Clone this facet.
JColorFacetASCII(std::size_t refs=0)
Constructor.
virtual const char * c_str(const JColor_t color) const override
Print color.
static const char * getName()
Get name of facet.
Facet class to specify text color for ELcode.
virtual const char * c_str(const JColor_t color) const override
Print color.
virtual JColorFacetELcode * clone() const override
Clone this facet.
std::vector< int > history
static const char * getName()
Get name of facet.
JColorFacetELcode(std::size_t refs=0)
Constructor.
Auxiliary map for color facets.
std::map< std::string, JSinglePointer< JColorFacet > > map_type
map_type::mapped_type mapped_type
map_type::value_type value_type
void operator()(const JType< T > &type)
Insert data type.
const mapped_type & operator[](const key_type &key) const
Get value for given key.
JColorFacetMap_t()
Default constructor.
map_type::key_type key_type
Facet interface to specify text color.
static std::locale::id id
static bool is_reset(const int color)
Check reset.
static bool is_color(const int color)
Check color.
void operator=(const JColorFacet &)
static bool is_bold(const int color)
Check bold.
JColorFacet(std::size_t refs=0)
Constructor.
virtual const char * c_str(const JColor_t color) const =0
Print color.
virtual JColorFacet * clone() const =0
Clone this facet.
JColorFacet(const JColorFacet &)
Auxiliary class for a type holder.