# clutchlog: clutchlog::fmt Class Reference

clutchlog::fmt Class Reference
Formating tools

Color and style formatter for ANSI terminal escape sequences. More...

`#include <clutchlog.h>`

## Detailed Description

Color and style formatter for ANSI terminal escape sequences.

Note
  All styles may not be supported by a given terminal/operating system.

Definition at line 309 of file clutchlog.h.

## Public Member Functions

| fmt ()
| Empty constructor, only useful for a no-op formatter.
std::string | operator() (const std::string &msg) const
| Format the given string with the currently encoded format. More...
std::string | str () const
| Return the formatting code as a string.
All combination of constructors with different parameters orders.
| fmt (fg f, bg b=bg::none, typo s=typo::none)
| fmt (fg f, typo s, bg b=bg::none)
| fmt (bg b, fg f=fg::none, typo s=typo::none)
| fmt (bg b, typo s, fg f=fg::none)
| fmt (typo s, fg f=fg::none, bg b=bg::none)
| fmt (typo s, bg b, fg f=fg::none)

## Public Attributes

enum clutchlog::fmt::fg | fore
| Foreground color.
enum clutchlog::fmt::bg | back
| Background color.
enum clutchlog::fmt::typo | style
| Typographic style.

## Protected Member Functions

std::ostream & | print_on (std::ostream &os) const
| Print the currently encoded format escape code on the given output stream.

## Public Types

enum | fg { black = 30, red = 31, green = 32, yellow = 33, blue = 34, magenta = 35, cyan = 36, white = 37, none }
| Foreground color codes.
enum | bg { black = 40, red = 41, green = 42, yellow = 43, blue = 44, magenta = 45, cyan = 46, white = 47, none }
| Background color codes.
enum | typo { reset = 0, bold = 1, underline = 4, inverse = 7, none }
| Typographic style codes.

## Friends

std::ostream & | operator<< (std::ostream &os, const fmt &fmt)
| Output stream overload. More...

## Member Function Documentation

## operator()()

std::string clutchlog::fmt::operator() | ( | const std::string & | msg | ) | const

inline

Format the given string with the currently encoded format.

Allow to use a formatter as a function:

clutchlog::fmt error(clutchlog::fmt::fg::red, clutchlog::fmt::typo::bold);
std::cout << error("ERROR") << std::endl;

Note
  A formatter called this way WILL output a reset escape code at the end.

Definition at line 406 of file clutchlog.h.

References print_on().

## Friends And Related Function Documentation

## operator<<

std::ostream& operator<< | ( | std::ostream & | os,
|  | const fmt & | fmt
| ) |  |

friend

Output stream overload.

Allow to use a formatter as a tag within a stream:

clutchlog::fmt end(clutchlog::fmt::typo::reset);
clutchlog::fmt error(clutchlog::fmt::fg::red, clutchlog::fmt::typo::bold);
std::cout << error << "ERROR" << end << std::endl;

Note
  An formatter called this way will NOT output a reset escape code.

Definition at line 391 of file clutchlog.h.

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

- clutchlog.h

clutchlog::fmt
Color and style formatter for ANSI terminal escape sequences.
Definition: clutchlog.h:309