HIPO  4.3.0
High Performance Output data format for experimental physics
ascii::Text Class Reference

Styled text element for terminal output with ANSI color support. More...

#include <text.h>

Public Member Functions

 Text ()
 Default constructor. Creates an empty text with default style. More...
 
 Text (std::string text)
 Construct a Text with the given string and default style. More...
 
 Text (std::string text, Style style)
 Construct a Text with the given string and style. More...
 
Textstyle (Style style)
 Set the style for this text. More...
 
Texttext (std::string text)
 Set the text content. More...
 
std::string text ()
 Get the text content. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const Text &val)
 Output the styled text to an output stream. Outputs the style, followed by the text content, followed by a reset decoration. More...
 

Detailed Description

Styled text element for terminal output with ANSI color support.

A Text object combines a string with a Style (foreground color, background color, and decorations). When output to a stream, it applies the style before the text and resets the decoration afterwards.

Definition at line 19 of file text.h.

Constructor & Destructor Documentation

◆ Text() [1/3]

ascii::Text::Text ( )
inline

Default constructor. Creates an empty text with default style.

Definition at line 22 of file text.h.

◆ Text() [2/3]

ascii::Text::Text ( std::string  text)
inline

Construct a Text with the given string and default style.

Parameters
textthe string content

Definition at line 28 of file text.h.

◆ Text() [3/3]

ascii::Text::Text ( std::string  text,
Style  style 
)
inline

Construct a Text with the given string and style.

Parameters
textthe string content
stylethe Style to apply to the text

Definition at line 35 of file text.h.

Member Function Documentation

◆ style()

Text& ascii::Text::style ( Style  style)
inline

Set the style for this text.

Parameters
stylethe Style to apply
Returns
a reference to this Text for method chaining

Definition at line 42 of file text.h.

◆ text() [1/2]

std::string ascii::Text::text ( )
inline

Get the text content.

Returns
the string content

Definition at line 61 of file text.h.

◆ text() [2/2]

Text& ascii::Text::text ( std::string  text)
inline

Set the text content.

Parameters
textthe string content
Returns
a reference to this Text for method chaining

Definition at line 52 of file text.h.

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Text val 
)
friend

Output the styled text to an output stream. Outputs the style, followed by the text content, followed by a reset decoration.

Parameters
osthe output stream
valthe Text to output
Returns
the output stream

Definition at line 68 of file text.h.


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