osmanip
Library with useful output stream tools like: color and style manipulators, progress bars and terminal graphics.
Public Member Functions | List of all members
osm::Decorator Class Reference

Class used to decorate an output stream. Each setting is set permanently on the chosen output stream until the destructor is met or one of the reset functions is called. More...

#include <decorator.hpp>

Public Member Functions

 Decorator ()
 Default constructor of Decorator class. More...
 
 ~Decorator ()
 Destructor of Decorator class. More...
 
void setColor (const std::string &color, std::ostream &os=osm::cout)
 Method used to set the color of a stream. More...
 
void setStyle (const std::string &style, std::ostream &os=osm::cout)
 Method used to set the style of a stream. More...
 
void resetColor (std::ostream &os=osm::cout)
 Method used to reset the color of a stream. More...
 
void resetStyle (std::ostream &os=osm::cout)
 Method used to reset the style or of a stream. More...
 
void removeStyle (std::string_view style, std::ostream &os=osm::cout)
 Method used to remove one of the set styles (useful in case they are more than one). More...
 
void resetFeatures (std::ostream &os=osm::cout)
 Method used to reset all the features of a stream. More...
 
std::string getColor (std::ostream &os=osm::cout)
 Method used to return the selected color of a stream. More...
 
std::string getStyle (std::ostream &os=osm::cout)
 Method used to return the selected style of a stream. More...
 
std::unordered_map< std::ostream *, std::string > getColorList ()
 Method used to return the map of streams with the respective color. More...
 
std::unordered_map< std::ostream *, std::string > getStyleList ()
 Method used to return the map of streams with the respective style. More...
 
std::ostream & getCurrentStream ()
 Method used to return the stream that is used to output stuff. More...
 
const Decoratoroperator() (std::ostream &os=osm::cout)
 Operator overload to assign the value into parentheses to the "current_stream" variable. More...
 

Detailed Description

Class used to decorate an output stream. Each setting is set permanently on the chosen output stream until the destructor is met or one of the reset functions is called.

Constructor & Destructor Documentation

◆ Decorator()

osm::Decorator::Decorator ( )

Default constructor of Decorator class.

◆ ~Decorator()

osm::Decorator::~Decorator ( )

Destructor of Decorator class.

Member Function Documentation

◆ getColor()

std::string osm::Decorator::getColor ( std::ostream &  os = osm::cout)

Method used to return the selected color of a stream.

Parameters
osThe stream which color is returned. Default is osm::cout.
Returns
std::string The current color of the stream.

◆ getColorList()

std::unordered_map< std::ostream *, std::string > osm::Decorator::getColorList ( )

Method used to return the map of streams with the respective color.

Returns
std::map <std::ostream*, std::string> The stream-color map.

◆ getCurrentStream()

std::ostream & osm::Decorator::getCurrentStream ( )

Method used to return the stream that is used to output stuff.

Returns
std::ostream& The used stream to output stuff.

◆ getStyle()

std::string osm::Decorator::getStyle ( std::ostream &  os = osm::cout)

Method used to return the selected style of a stream.

Parameters
osThe stream which style is returned. Default is osm::cout.
Returns
std::string The current style of the stream.

◆ getStyleList()

std::unordered_map< std::ostream *, std::string > osm::Decorator::getStyleList ( )

Method used to return the map of streams with the respective style.

Returns
std::map <std::ostream*, std::string> The stream-color map.

◆ operator()()

const Decorator & osm::Decorator::operator() ( std::ostream &  os = osm::cout)

Operator overload to assign the value into parentheses to the "current_stream" variable.

Parameters
osInput value, i.e. the stream put into parentheses.
Returns
const Decorator& The class pointer.

◆ removeStyle()

void osm::Decorator::removeStyle ( std::string_view  style,
std::ostream &  os = osm::cout 
)

Method used to remove one of the set styles (useful in case they are more than one).

Parameters
colorThe style to be reset for the stream.
osThe stream to be modified. Default is osm::cout.

◆ resetColor()

void osm::Decorator::resetColor ( std::ostream &  os = osm::cout)

Method used to reset the color of a stream.

Parameters
colorThe color to be reset for the stream.
osThe stream to be modified. Default is osm::cout.

◆ resetFeatures()

void osm::Decorator::resetFeatures ( std::ostream &  os = osm::cout)

Method used to reset all the features of a stream.

Parameters
osThe stream to be modified. Default is osm::cout.

◆ resetStyle()

void osm::Decorator::resetStyle ( std::ostream &  os = osm::cout)

Method used to reset the style or of a stream.

Parameters
colorThe style to be reset for the stream.
osThe stream to be modified. Default is osm::cout.

◆ setColor()

void osm::Decorator::setColor ( const std::string &  color,
std::ostream &  os = osm::cout 
)

Method used to set the color of a stream.

Parameters
colorThe color to be set for the stream.
osThe stream to be modified. Default is osm::cout.

◆ setStyle()

void osm::Decorator::setStyle ( const std::string &  style,
std::ostream &  os = osm::cout 
)

Method used to set the style of a stream.

Parameters
colorThe style to be set for the stream.
osThe stream to be modified. Default is osm::cout.

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