TermOx
Public Types | Public Member Functions | Static Public Attributes | List of all members
ox::Glyph_string Class Reference

Holds a collection of Glyphs with a similar interface to std::string. More...

#include <glyph_string.hpp>

Inheritance diagram for ox::Glyph_string:

Public Types

using size_type = int
 

Public Member Functions

 Glyph_string ()=default
 Default constructs an empty Glyph_string.
 
 Glyph_string (Glyph glyph, int count=1)
 Construct with count glyph's, adding given Traits to each.
 
template<typename... Attributes>
 Glyph_string (std::u32string_view symbols, Attributes... attrs)
 Construct with a Glyph for each char32_t in symbols and Brush b. More...
 
template<typename... Attributes>
 Glyph_string (char32_t const *symbols, Attributes... attrs)
 
template<typename... Attributes>
 Glyph_string (std::u32string const &symbols, Attributes... attrs)
 
template<typename... Attributes>
 Glyph_string (std::string_view symbols, Attributes... attrs)
 Construct with a Glyph for each character in symbols and Brush b. More...
 
template<typename... Attributes>
 Glyph_string (char const *symbols, Attributes... attrs)
 
template<typename... Attributes>
 Glyph_string (std::string const &symbols, Attributes... attrs)
 
template<typename InputIterator >
 Glyph_string (InputIterator first, InputIterator last)
 Construct with iterators from any container providing Input Iterators. More...
 
auto append (Glyph g) -> Glyph_string &
 Append a single Glyph to the end of *this.
 
auto append (Glyph_string const &gs) -> Glyph_string &
 Append another Glyph_string to the end of *this.
 
auto length () const -> int
 Return the number of Glyphs in *this Glyph_string. More...
 
auto size () const -> int
 Return the number of Glyphs in *this Glyph_string. More...
 
auto u32str () const -> std::u32string
 Convert to a std::u32string, each Glyph being a char32_t. More...
 
auto str () const -> std::string
 Convert to a std::string. More...
 
void add_traits (Traits traits)
 Add traits to every Glyph contained in *this.
 
void clear_traits ()
 Remove all currently set traits on each Glyph.
 
void add_color (Background_color bg)
 Add bg as the background color to every Glyph contained in *this.
 
void add_color (Foreground_color fg)
 Add fg as the foreground color to every Glyph contained in *this.
 
void remove_traits (Traits traits)
 Remove a series of Traits from every Glyph within the Glyph_string.
 
void remove_background ()
 Set the background color as the default for every Glyph in *this.
 
void remove_foreground ()
 Set the foreground color as the default for every Glyph in *this.
 

Static Public Attributes

static constexpr auto npos = -1
 Used to indicate 'Until the end of the string'.
 

Detailed Description

Holds a collection of Glyphs with a similar interface to std::string.

Constructor & Destructor Documentation

◆ Glyph_string() [1/3]

template<typename... Attributes>
ox::Glyph_string::Glyph_string ( std::u32string_view  symbols,
Attributes...  attrs 
)
inline

Construct with a Glyph for each char32_t in symbols and Brush b.

Attributes can be background/foreground Colors and Traits.

◆ Glyph_string() [2/3]

template<typename... Attributes>
ox::Glyph_string::Glyph_string ( std::string_view  symbols,
Attributes...  attrs 
)
inline

Construct with a Glyph for each character in symbols and Brush b.

This allows for mult-byte characters in symbols, using the currently set clocale for the conversion. This is set to utf8 by this library. Attributes can be background/foreground Colors and Traits.

◆ Glyph_string() [3/3]

template<typename InputIterator >
ox::Glyph_string::Glyph_string ( InputIterator  first,
InputIterator  last 
)
inline

Construct with iterators from any container providing Input Iterators.

The iterator type must be iterating over Glyphs.

Member Function Documentation

◆ length()

auto ox::Glyph_string::length ( ) const -> int

Return the number of Glyphs in *this Glyph_string.

Same as size() member function.

◆ size()

auto ox::Glyph_string::size ( ) const -> int

Return the number of Glyphs in *this Glyph_string.

Same as length() member function.

◆ str()

auto ox::Glyph_string::str ( ) const -> std::string

Convert to a std::string.

Each Glyph::symbols is converted to a (potentially) multi-byte char string. All Brush attributes are lost.

◆ u32str()

auto ox::Glyph_string::u32str ( ) const -> std::u32string

Convert to a std::u32string, each Glyph being a char32_t.

All Brush attributes are lost.


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