AnCH Framework
0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
formatter.hpp
1
/*
2
ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3
Copyright (C) 2012 Vincent Lachenal
4
5
This file is part of ANCH Framework.
6
7
ANCH Framework is free software: you can redistribute it and/or modify
8
it under the terms of the GNU Lesser General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
ANCH Framework is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU Lesser General Public License for more details.
16
17
You should have received a copy of the GNU Lesser General Public License
18
along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
#pragma once
21
22
#include <cstdint>
23
#include <array>
24
#include <optional>
25
#include <ostream>
26
27
namespace
anch::cli {
28
34
enum class
Color {
35
37
BLACK = 0,
38
40
RED = 1,
41
43
GREEN = 2,
44
46
YELLOW = 3,
47
49
BLUE = 4,
50
52
MAGENTA = 5,
53
55
CYAN = 6,
56
58
WHITE = 7,
59
61
DEFAULT = 9
62
63
};
64
72
struct
Formatter
{
73
75
static
bool
DISABLED
;
76
78
std::optional<Color>
_fg_color
;
79
81
std::optional<std::array<uint8_t,3>>
_rgb_fg_color
;
82
84
std::optional<Color>
_bg_color
;
85
87
std::optional<std::array<uint8_t,3>>
_rgb_bg_color
;
88
90
std::optional<bool>
_bold
=
false
;
91
93
std::optional<bool>
_underline
=
false
;
94
96
std::optional<bool>
_blink
=
false
;
97
99
bool
_reset
=
false
;
100
104
Formatter
();
105
109
virtual
~Formatter
();
110
116
static
Formatter
format
();
117
125
Formatter
&
bold
(
bool
state =
true
);
126
134
Formatter
&
underline
(
bool
state =
true
);
135
143
Formatter
&
blink
(
bool
state =
true
);
144
150
Formatter
&
reset
();
151
159
Formatter
&
fgColor
(
const
Color& color);
160
168
Formatter
&
fgColor
(
const
std::array<uint8_t,3>& color);
169
177
Formatter
&
bgColor
(
const
Color& color);
178
186
Formatter
&
bgColor
(
const
std::array<uint8_t,3>& color);
187
188
};
189
191
extern
anch::cli::Formatter
BOLD;
192
194
extern
anch::cli::Formatter
UNBOLD;
195
197
extern
anch::cli::Formatter
UNDERLINE;
198
200
extern
anch::cli::Formatter
UNUNDERLINE;
201
203
extern
anch::cli::Formatter
BLINK;
204
206
extern
anch::cli::Formatter
UNBLINK;
207
209
extern
anch::cli::Formatter
RESET;
210
211
}
// anch::cli
212
221
std::ostream&
222
operator<<(std::ostream& stream,
const
anch::cli::Formatter
& fmt);
anch::cli::Formatter
Console formatter.
Definition
formatter.hpp:72
anch::cli::Formatter::bgColor
Formatter & bgColor(const std::array< uint8_t, 3 > &color)
anch::cli::Formatter::underline
Formatter & underline(bool state=true)
anch::cli::Formatter::fgColor
Formatter & fgColor(const std::array< uint8_t, 3 > &color)
anch::cli::Formatter::reset
Formatter & reset()
anch::cli::Formatter::format
static Formatter format()
anch::cli::Formatter::_reset
bool _reset
Definition
formatter.hpp:99
anch::cli::Formatter::_fg_color
std::optional< Color > _fg_color
Definition
formatter.hpp:78
anch::cli::Formatter::_rgb_fg_color
std::optional< std::array< uint8_t, 3 > > _rgb_fg_color
Definition
formatter.hpp:81
anch::cli::Formatter::bold
Formatter & bold(bool state=true)
anch::cli::Formatter::DISABLED
static bool DISABLED
Definition
formatter.hpp:75
anch::cli::Formatter::~Formatter
virtual ~Formatter()
anch::cli::Formatter::_rgb_bg_color
std::optional< std::array< uint8_t, 3 > > _rgb_bg_color
Definition
formatter.hpp:87
anch::cli::Formatter::fgColor
Formatter & fgColor(const Color &color)
anch::cli::Formatter::_bold
std::optional< bool > _bold
Definition
formatter.hpp:90
anch::cli::Formatter::blink
Formatter & blink(bool state=true)
anch::cli::Formatter::Formatter
Formatter()
anch::cli::Formatter::_blink
std::optional< bool > _blink
Definition
formatter.hpp:96
anch::cli::Formatter::_underline
std::optional< bool > _underline
Definition
formatter.hpp:93
anch::cli::Formatter::bgColor
Formatter & bgColor(const Color &color)
anch::cli::Formatter::_bg_color
std::optional< Color > _bg_color
Definition
formatter.hpp:84
anch-cli
inc
cli
formatter.hpp
Generated by
1.14.0