|
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> && std::formattable<std::decay_t<T>, char>) | |
| 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> && std::formattable<std::decay_t<T>, char>) | |
| 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 417 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 427 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 438 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 std::format. This constructor is constrained to accept types that satisfy std::formattable<T, char>, excluding std::string to avoid ambiguity with the existing string constructor.
| T | The type of the value (must satisfy std::formattable<T, char>) |
| value | The value to convert to string |
Definition at line 455 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 std::format, with the specified styling attributes applied.
| T | The type of the value (must satisfy std::formattable<T, char>) |
| value | The value to convert to string |
| styles | The styling attributes to apply to the text |
Definition at line 474 of file text_formatter.hpp.
|
inline |
Definition at line 483 of file text_formatter.hpp.
|
inline |
Definition at line 478 of file text_formatter.hpp.