|
Porytiles
|
A text parameter with associated styling for formatted output. More...
#include <text_formatter.hpp>
Public Member Functions | |
| FormatParam (std::string text) | |
| Constructs a FormatParam with unstyled text. | |
| FormatParam (std::string text, Style styles) | |
| Constructs a FormatParam with styled text. | |
| template<typename T > requires ( !std::is_same_v<std::decay_t<T>, std::string> && !std::is_same_v<std::decay_t<T>, FormatParam> && requires(std::ostringstream os, T val) { os << val; }) | |
| FormatParam (T &&value) | |
| Constructs a FormatParam by converting a value to string. | |
| template<typename T > requires ( !std::is_same_v<std::decay_t<T>, std::string> && !std::is_same_v<std::decay_t<T>, FormatParam> && requires(std::ostringstream os, T val) { os << val; }) | |
| FormatParam (T &&value, Style styles) | |
| Constructs a FormatParam by converting a value to styled string. | |
| const std::string & | text () const |
| Style | styles () const |
A text parameter with associated styling for formatted output.
FormatParam pairs a text string with Style flags to enable styled parameter substitution in formatted strings. When used with TextFormatter::format(), the text is styled according to the formatter implementation (ANSI codes for TTY, plain text for non-TTY) before being substituted into the format string.
Example usage:
This struct is typically constructed inline when creating error messages or formatted diagnostic output.
Definition at line 132 of file text_formatter.hpp.
|
inline |
Constructs a FormatParam with unstyled text.
Creates a FormatParam with the given text and no styling applied (Style::none).
| text | The text content to be formatted |
Definition at line 142 of file text_formatter.hpp.
|
inlineexplicit |
Constructs a FormatParam with styled text.
Creates a FormatParam with the given text and specified styling attributes.
| text | The text content to be formatted |
| styles | The styling attributes to apply to the text |
Definition at line 153 of file text_formatter.hpp.
|
inline |
Constructs a FormatParam by converting a value to string.
Creates a FormatParam by converting the given value to a string using stream insertion. This constructor is constrained to accept only types that support operator<<, excluding std::string to avoid ambiguity with the existing string constructor.
| T | The type of the value (must support stream insertion) |
| value | The value to convert to string |
Definition at line 170 of file text_formatter.hpp.
|
inlineexplicit |
Constructs a FormatParam by converting a value to styled string.
Creates a FormatParam by converting the given value to a string using stream insertion, with the specified styling attributes applied.
| T | The type of the value (must support stream insertion) |
| value | The value to convert to string |
| styles | The styling attributes to apply to the text |
Definition at line 189 of file text_formatter.hpp.
|
inline |
Definition at line 198 of file text_formatter.hpp.
|
inline |
Definition at line 193 of file text_formatter.hpp.