Platform-independent color output interface.
More...
#include <ConsoleOutput.hpp>
|
| enum | Color {
FG_WHITE
, FG_RED
, FG_GREEN
, FG_BLUE
,
FG_MAGENTA
, FG_YELLOW
, FG_ORANGE
, FG_PURPLE
} |
| enum | : uint32 { STYLE_NONE = 0
, STYLE_BOLD = 0x1
, STYLE_UNDERLINED = 0x2
} |
|
|
| ConsoleOutput () |
| | Default constructor; initializes the output stream to use std::cerr (the standard error stream).
|
| | ConsoleOutput (std::ostream &os) |
| | Construct a console output object with a custom output stream.
|
| ConsoleOutput::Color | color () const |
| | Get the last color that was set.
|
| bool | use_color () const |
| | Get the current use state of colored output logging.
|
| virtual void | set_color (ConsoleOutput::Color color) |
| virtual void | set_style (uint32 style) |
| virtual void | endl () |
| | Reset the colors that have been set.
|
|
| std::string | env (const std::string &path) const |
| | Get the value of an environment variable.
|
Platform-independent color output interface.
- See also
- nom::SDL2Logger
Definition at line 43 of file ConsoleOutput.hpp.
◆ anonymous enum
| Enumerator |
|---|
| STYLE_NONE | Resets the text colors.
|
Definition at line 1 of file ConsoleOutput.hpp.
◆ Color
◆ ConsoleOutput()
| nom::ConsoleOutput::ConsoleOutput |
( |
std::ostream & | os | ) |
|
Construct a console output object with a custom output stream.
- Parameters
-
| os | std::cerr, std::cout, std::ofstream, etc. |
◆ color()
Get the last color that was set.
◆ endl()
| virtual void nom::ConsoleOutput::endl |
( |
| ) |
|
|
virtual |
◆ env()
| std::string nom::ConsoleOutput::env |
( |
const std::string & | path | ) |
const |
|
private |
Get the value of an environment variable.
- Returns
- A null-terminated string (zero length) upon err, such as an non-existent environment variable.
◆ set_color()
◆ set_style()
| virtual void nom::ConsoleOutput::set_style |
( |
uint32 | style | ) |
|
|
virtual |
◆ use_color()
| bool nom::ConsoleOutput::use_color |
( |
| ) |
const |
Get the current use state of colored output logging.
- Returns
- Boolean TRUE when the platform's environment variable NOM_COLOR is set to 'true, 'always', 'yes' or "1", otherwise boolean FALSE is returned (the default).
- Todo
- The environment variable's value is case-sensitive.
- Todo
- Provide 'auto' option for NOM_COLOR; this could be tested on Unix platforms with the value of TERM equaling xterm-color or such; see also: gtest.cc.
◆ impl_
◆ lcolor_
◆ out_
| std::ostream& nom::ConsoleOutput::out_ |
|
protected |
The output stream to use; i.e.: std::cout or std::cerr.
Definition at line 108 of file ConsoleOutput.hpp.
The documentation for this class was generated from the following file: