Porytiles
Loading...
Searching...
No Matches
porytiles2::PlainTextFormatter Class Referencefinal

TextFormatter implementation that strips all styling from text. More...

#include <plain_text_formatter.hpp>

Inheritance diagram for porytiles2::PlainTextFormatter:
[legend]
Collaboration diagram for porytiles2::PlainTextFormatter:
[legend]

Public Member Functions

std::string style (const std::string &text, Style style) const override
 Returns text unchanged, ignoring all styling.
 
- Public Member Functions inherited from porytiles2::TextFormatter
virtual ~TextFormatter ()=default
 
virtual std::string format (const std::string &format_str, const std::vector< FormatParam > &params) const
 Formats a string with styled parameters using fmtlib syntax.
 
template<typename FirstParam , typename... RestParams>
requires ( !std::is_same_v<std::decay_t<FirstParam>, std::vector<FormatParam>> && std::is_constructible_v<FormatParam, FirstParam> && (std::is_constructible_v<FormatParam, RestParams> && ...))
std::string format (const std::string &format_str, FirstParam &&first, RestParams &&...rest) const
 Formats a string with styled parameters using variadic template syntax.
 

Detailed Description

TextFormatter implementation that strips all styling from text.

PlainTextFormatter is a concrete implementation of TextFormatter that returns text without any styling applied, regardless of the Style flags provided. This formatter is intended for use when output is directed to non-TTY destinations such as files or pipes, where ANSI escape codes would appear as visible garbage characters.

The style() method ignores all Style flags and returns the input text unchanged, effectively stripping any requested styling. This ensures clean, readable output in contexts where terminal styling is not appropriate.

Usage context:

  • File output (logs, reports)
  • Pipe output to other programs
  • Non-TTY terminal contexts
  • Any scenario where styled output would be undesirable

Definition at line 24 of file plain_text_formatter.hpp.

Member Function Documentation

◆ style()

std::string porytiles2::PlainTextFormatter::style ( const std::string &  text,
Style  style 
) const
overridevirtual

Returns text unchanged, ignoring all styling.

Implements the style() interface by simply returning the input text without applying any formatting, regardless of the Style flags provided. This ensures output remains clean and readable in non-TTY contexts.

Parameters
textThe text to format
styleThe Style flags (ignored in this implementation)
Returns
The original text without any modifications

Implements porytiles2::TextFormatter.

Definition at line 7 of file plain_text_formatter.cpp.


The documentation for this class was generated from the following files: