libcsdbg  1.28
C++ exception (and generic) stack trace debug library
style.hpp
Go to the documentation of this file.
1 #ifndef _CSDBG_STYLE
2 #define _CSDBG_STYLE 1
3 
10 #include "./string.hpp"
11 
12 namespace csdbg {
13 
20 class style: virtual public object
21 {
22 protected:
23 
24  /* Protected variables */
25 
34 public:
35 
36  /* Constructors, copy constructors and destructor */
37 
38  style(const i8*, color_t = WHITE, color_t = CLEAR, attrset_t = 0);
39 
40  style(const style&);
41 
42  virtual ~style();
43 
44  virtual style* clone() const;
45 
46 
47  /* Accessor methods */
48 
49  virtual const i8* name() const;
50 
51  virtual color_t fgcolor() const;
52 
53  virtual color_t bgcolor() const;
54 
55  virtual attrset_t attributes() const;
56 
57  virtual style& set_name(const i8*);
58 
59  virtual style& set_fgcolor(color_t);
60 
61  virtual style& set_bgcolor(color_t);
62 
63  virtual style& set_attributes(attrset_t);
64 
65 
66  /* Operator overloading methods */
67 
68  virtual style& operator=(const style&);
69 
70 
71  /* Generic methods */
72 
73  virtual bool is_attr_enabled(attrset_t) const;
74 
75  virtual style& set_attr_enabled(attrset_t, bool);
76 
77  virtual style& to_string(string&) const;
78 
79  virtual style& apply(string&) const;
80 
81 
82  /* Public static variables */
83 
87  static const enum {
88 
89  BOLD = 0x01, DIM = 0x02, UNDERLINED = 0x04,
90 
91  BLINKING = 0x08, INVERTED = 0x10, HIDDEN = 0x20
92 
94 
98  static const enum {
99 
100  CLEAR = 0x00, GRAY = 0x08, RED = 0x09,
101 
102  GREEN = 0x0A, YELLOW = 0x0B, BLUE = 0x0C,
103 
104  MAGENTA = 0x0D, CYAN = 0x0E, WHITE = 0x0F,
105 
106  BLACK = 0x10
107 
108  } vt100_palette;
109 };
110 
111 }
112 
113 #endif
114 
virtual style & set_attr_enabled(attrset_t, bool)
Enable/disable a set of text formatting attributes.
Definition: style.cpp:237
This abstract class serves as the root of the class hierarchy tree.
Definition: object.hpp:17
virtual style * clone() const
Object virtual copy constructor.
Definition: style.cpp:74
virtual style & set_fgcolor(color_t)
Set the foreground color.
Definition: style.cpp:158
virtual style & to_string(string &) const
Set a string with all the style escape sequences.
Definition: style.cpp:260
char i8
8-bit signed integer
Definition: config.hpp:72
virtual style & apply(string &) const
Apply the style to some text.
Definition: style.cpp:304
A set of formatting attributes for VT100 (and compatible) terminals.
Definition: style.hpp:20
virtual const i8 * name() const
Get the style name.
Definition: style.cpp:85
u8 color_t
VT100 terminal color.
Definition: config.hpp:162
virtual style & set_name(const i8 *)
Set the style name.
Definition: style.cpp:134
virtual style & operator=(const style &)
Assignment operator.
Definition: style.cpp:202
static enum csdbg::style::@1 vt100_palette
Basic palette of VT100 terminals.
virtual attrset_t attributes() const
Get the text formatting attributes.
Definition: style.cpp:118
virtual color_t fgcolor() const
Get the foreground color.
Definition: style.cpp:96
virtual color_t bgcolor() const
Get the background color.
Definition: style.cpp:107
attrset_t m_attributes
Text formatting attribute bitmask.
Definition: style.hpp:32
Class csdbg::string definition.
color_t m_bgcolor
Background color.
Definition: style.hpp:30
static enum csdbg::style::@0 vt100_attributes
Text formatting attributes of VT100 terminals.
virtual style & set_bgcolor(color_t)
Set the background color.
Definition: style.cpp:172
u16 attrset_t
VT100 attribute bitmask.
Definition: config.hpp:170
virtual bool is_attr_enabled(attrset_t) const
Check if a set of text formatting attributes is enabled.
Definition: style.cpp:222
style(const i8 *, color_t=WHITE, color_t=CLEAR, attrset_t=0)
Object constructor.
Definition: style.cpp:25
color_t m_fgcolor
Foreground (text) color.
Definition: style.hpp:28
virtual style & set_attributes(attrset_t)
Set the text formatting attributes.
Definition: style.cpp:186
i8 * m_name
Style name.
Definition: style.hpp:26
virtual ~style()
Object destructor.
Definition: style.cpp:60