libzypp: ztui::ColorString Class Reference

libzypp 17.36.6

Public Member Functions | Private Attributes | Related Symbols | List of all members
ztui::ColorString Class Reference

Colored string if do_colors. More...

`#include <zypp-tui/utils/ansi.h>`

Inheritance diagram for ztui::ColorString:

## Public Member Functions
| ColorString ()
| ColorString (Color color_r)
| Ctor from color.
| ColorString (const std::string &str_r)
| Ctor from string.
| ColorString (std::string &&str_r)
| ColorString (const std::string &str_r, Color color_r)
| Ctor from string and color.
| ColorString (std::string &&str_r, Color color_r)
| ColorString (Color color_r, const std::string &str_r)
| Ctor from color and string.
| ColorString (Color color_r, std::string &&str_r)
ColorString & | operator= (const std::string &str_r)
| Assign new string.
ColorString & | operator= (std::string &&str_r)
ColorString & | operator= (Color color_r)
| Assign Color.
ColorString & | operator<< (const ColorString &rhs)
| Append a \Ref ColorString.
ColorString & | operator<< (const std::string &str_r)
| Append a string.
ColorString & | operator<= (Color color_r)
| Update Color.
ColorString | operator() (Color color_r) const
| Return a copy with different color.
Color | color () const
| Return strings Color.
bool | empty () const
| Whether the underlying string is empty.
std::string::size_type | size () const
| Size of the underlying string.
std::string | str () const
| Return the colored string if do_colors.
std::string | str (Color color_r) const
| Return the string rendered in a differernt color if do_colors.
std::string | asString () const
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const std::string & | plainstr () const
| Return the underlying plain string.
std::string & | plainstr ()
| Return the underlying plain string.
const std::string & | operator* () const
| Access the underlying plain string via `operator*`.
std::string & | operator* ()
| Access the underlying plain string via `operator*`.

## Private Attributes
std::string | _str
Color | _color

## Related Symbols
(Note that these are not member symbols.)
std::ostream & | operator<< (std::ostream &str, const ColorString &obj)
| Print colored on ostream.

## Detailed Description

Colored string if do_colors.

Stores a plain std::string (which may have color codes embedded) along with a Color. Retrieving the string will render all uncolored (Color::nololor) parts of the string in the Color.

In contrary to a ColorStream you can change the basic color of the string without losing embedded highlights.

Note
  Printing a ColorString renderd in Color::noclolor on a ColorStream will render the string in the ColorStreams color.

Definition at line 496 of file ansi.h.

## Constructor & Destructor Documentation

## ◆ ColorString() [1/8]

ztui::ansi::ColorString::ColorString | ( |  | ) |
| inline

Definition at line 499 of file ansi.h.

## ◆ ColorString() [2/8]

ztui::ansi::ColorString::ColorString | ( | Color | color_r | ) |
| inlineexplicit

Ctor from color.

Definition at line 504 of file ansi.h.

## ◆ ColorString() [3/8]

ztui::ansi::ColorString::ColorString | ( | const std::string & | str_r | ) |
| inlineexplicit

Ctor from string.

Definition at line 509 of file ansi.h.

## ◆ ColorString() [4/8]

ztui::ansi::ColorString::ColorString | ( | std::string && | str_r | ) |
| inlineexplicit

Definition at line 514 of file ansi.h.

## ◆ ColorString() [5/8]

ztui::ansi::ColorString::ColorString | ( | const std::string & | str_r,
|  | Color | color_r )
| inline

Ctor from string and color.

Definition at line 520 of file ansi.h.

## ◆ ColorString() [6/8]

ztui::ansi::ColorString::ColorString | ( | std::string && | str_r,
|  | Color | color_r )
| inline

Definition at line 525 of file ansi.h.

## ◆ ColorString() [7/8]

ztui::ansi::ColorString::ColorString | ( | Color | color_r,
|  | const std::string & | str_r )
| inline

Ctor from color and string.

Definition at line 531 of file ansi.h.

## ◆ ColorString() [8/8]

ztui::ansi::ColorString::ColorString | ( | Color | color_r,
|  | std::string && | str_r )
| inline

Definition at line 536 of file ansi.h.

## Member Function Documentation

## ◆ operator=() [1/3]

ColorString & ztui::ansi::ColorString::operator= | ( | const std::string & | str_r | ) |
| inline

Assign new string.

Definition at line 543 of file ansi.h.

## ◆ operator=() [2/3]

ColorString & ztui::ansi::ColorString::operator= | ( | std::string && | str_r | ) |
| inline

Definition at line 546 of file ansi.h.

## ◆ operator=() [3/3]

ColorString & ztui::ansi::ColorString::operator= | ( | Color | color_r | ) |
| inline

Assign Color.

Definition at line 572 of file ansi.h.

## ◆ operator<<() [1/2]

ColorString & ztui::ansi::ColorString::operator<< | ( | const ColorString & | rhs | ) |
| inline

Append a \Ref ColorString.

Definition at line 563 of file ansi.h.

## ◆ operator<<() [2/2]

ColorString & ztui::ansi::ColorString::operator<< | ( | const std::string & | str_r | ) |
| inline

Append a string.

Definition at line 567 of file ansi.h.

## ◆ operator<=()

ColorString & ztui::ansi::ColorString::operator<= | ( | Color | color_r | ) |
| inline

Update Color.

Definition at line 576 of file ansi.h.

## ◆ operator()()

ColorString ztui::ansi::ColorString::operator() | ( | Color | color_r | ) | const
| inline

Return a copy with different color.

Definition at line 580 of file ansi.h.

## ◆ color()

Color ztui::ansi::ColorString::color | ( |  | ) | const
| inline

Return strings Color.

Definition at line 585 of file ansi.h.

## ◆ empty()

bool ztui::ansi::ColorString::empty | ( |  | ) | const
| inline

Whether the underlying string is empty.

Definition at line 590 of file ansi.h.

## ◆ size()

std::string::size_type ztui::ansi::ColorString::size | ( |  | ) | const
| inline

Size of the underlying string.

Definition at line 594 of file ansi.h.

## ◆ str() [1/2]

std::string ztui::ansi::ColorString::str | ( |  | ) | const
| inline

Return the colored string if do_colors.

Definition at line 598 of file ansi.h.

## ◆ str() [2/2]

std::string ztui::ansi::ColorString::str | ( | Color | color_r | ) | const
| inline

Return the string rendered in a differernt color if do_colors.

Definition at line 605 of file ansi.h.

## ◆ asString()

std::string ztui::ansi::ColorString::asString | ( |  | ) | const
| inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 601 of file ansi.h.

## ◆ plainstr() [1/2]

const std::string & ztui::ansi::ColorString::plainstr | ( |  | ) | const
| inline

Return the underlying plain string.

Definition at line 622 of file ansi.h.

## ◆ plainstr() [2/2]

std::string & ztui::ansi::ColorString::plainstr | ( |  | ) |
| inline

Return the underlying plain string.

Definition at line 626 of file ansi.h.

## ◆ operator*() [1/2]

const std::string & ztui::ansi::ColorString::operator* | ( |  | ) | const
| inline

Access the underlying plain string via `operator*`.

Definition at line 630 of file ansi.h.

## ◆ operator*() [2/2]

std::string & ztui::ansi::ColorString::operator* | ( |  | ) |
| inline

Access the underlying plain string via `operator*`.

Definition at line 634 of file ansi.h.

## Friends And Related Symbol Documentation

## ◆ operator<<()

std::ostream & operator<< | ( | std::ostream & | str,
|  | const ColorString & | obj )
| related

Print colored on ostream.

Definition at line 643 of file ansi.h.

## Member Data Documentation

## ◆ _str

std::string ztui::ansi::ColorString::_str
| private

Definition at line 638 of file ansi.h.

## ◆ _color

Color ztui::ansi::ColorString::_color
| private

Definition at line 639 of file ansi.h.

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

- zypp-tui/utils/ansi.h