#include <CGAL/IO/Color_ostream.h>
std::basic_streambuf< CharT, std::char_traits< CharT > >, and std::char_traits< CharT >.
template<typename CharT, typename Traits = std::char_traits<CharT>>
class CGAL::IO::Basic_color_streambuf< CharT, Traits >
The class template Basic_color_streambuf wraps another basic_streambuf and automatically adds ANSI color codes to the output.
This is useful for colorizing terminal output with consistent color schemes.
- Template Parameters
-
| CharT | Character type (typically char or wchar_t) |
| Traits | Character traits type |
- See also
- Basic_color_stream_guard
-
make_color_guards
- Examples
- Stream_support/color_ostream.cpp.
|
|
using | char_type = CharT |
| | Character type.
|
| |
|
using | traits_type = Traits |
| | Character traits type.
|
| |
|
using | int_type = typename traits_type::int_type |
| | Integer type for character representation.
|
| |
|
using | pos_type = typename traits_type::pos_type |
| | Position type for stream positioning.
|
| |
|
using | off_type = typename traits_type::off_type |
| | Offset type for stream positioning.
|
| |
|
using | streambuf_type = std::basic_streambuf< char_type, traits_type > |
| | Type of the wrapped streambuf.
|
| |
|
using | string = std::basic_string< char_type > |
| | String type matching character type.
|
| |
|
| template<typename ... AnsiColors> |
| | Basic_color_streambuf (streambuf_type &wrapped_buf, AnsiColors... colors) |
| | constructs a color streambuf wrapper with one or more colors.
|
| |
|
const string & | color_code () const |
| | gets the current color code string.
|
| |
| void | set_color_code (string color_code) |
| | sets a new color code.
|
| |
|
bool | colors_enabled () const |
| | checks if colors are enabled for this streambuf.
|
| |
|
streambuf_type & | wrapped_streambuf () const |
| | gets the wrapped streambuf.
|
| |
|
|
static bool | detect_color_support (streambuf_type *buf) |
| | detects if the wrapped buffer supports color output.
|
| |
◆ Basic_color_streambuf()
template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename ... AnsiColors>
constructs a color streambuf wrapper with one or more colors.
Colors are automatically disabled if the wrapped buffer is not connected to a color-capable terminal (checked via isatty() and TERM variable), or if the NO_COLOR environment variable is set and non-empty.
- Template Parameters
-
| AnsiColors | Variadic list of Ansi_color values |
- Parameters
-
◆ set_color_code()
template<typename CharT , typename Traits = std::char_traits<CharT>>
sets a new color code.
- Parameters
-
| color_code | The new color code to apply |