16 #include <arsenalgear/stream.hpp>
17 #include <arsenalgear/utils.hpp>
23 #include <unordered_map>
37 template <
typename... Args>
38 inline void print( std::ostream& os = agr::null_stream,
const Args&... args )
40 if( &os == &agr::null_stream ) std::cout <<
"\n";
41 else if( &os == &std::cerr ) os <<
feat(
col,
"red" ) <<
feat(
sty,
"bold" );
42 else if( &os == &std::clog ) os <<
feat(
col,
"lt blue" ) <<
feat(
sty,
"bold" );
44 ( os << ... << args ) <<
"\n";
46 if( &os == &std::cerr || &os == &std::clog || &os == &std::cout ) os <<
feat(
rst,
"all" );
58 template <
typename... Args>
59 inline void print( Args&... args )
61 ( std::cout << ... << args ) <<
"\n" <<
feat(
rst,
"all" );
84 void setColor(
const std::string& color, std::ostream& os = std::cout );
85 void setStyle(
const std::string& style, std::ostream& os = std::cout );
90 void resetColor( std::ostream& os = std::cout );
91 void resetStyle( std::ostream& os = std::cout );
92 void removeStyle(
const std::string& style, std::ostream& os = std::cout );
98 std::string
getColor( std::ostream& os = std::cout );
99 std::string
getStyle( std::ostream& os = std::cout );
100 std::unordered_map <std::ostream*, std::string>
getColorList();
101 std::unordered_map <std::ostream*, std::string>
getStyleList();
114 std::unordered_map <std::ostream*, std::string> colors, styles;
115 std::ostream* current_stream;
129 template <
typename T>
138 std::vector<std::string> list_of_styles = agr::split_string( my_shell.
getStyle( my_shell.
getCurrentStream() ),
" " );
139 for (
auto elem: list_of_styles )
Class used to decorate an output stream. Each setting is set permanently on the chosen output stream ...
Definition: printer.hpp:72
std::unordered_map< std::ostream *, std::string > getStyleList()
Method used to return the map of streams with the respective style.
Definition: printer.cpp:187
void resetStyle(std::ostream &os=std::cout)
Method used to reset the style or of a stream.
Definition: printer.cpp:95
void setColor(const std::string &color, std::ostream &os=std::cout)
Method used to set the color of a stream.
Definition: printer.cpp:51
std::ostream & getCurrentStream()
Method used to return the stream that is used to output stuff.
Definition: printer.cpp:200
std::unordered_map< std::ostream *, std::string > getColorList()
Method used to return the map of streams with the respective color.
Definition: printer.cpp:174
void resetFeatures(std::ostream &os=std::cout)
Method used to reset all the features of a stream.
Definition: printer.cpp:129
std::string getStyle(std::ostream &os=std::cout)
Method used to return the selected style of a stream.
Definition: printer.cpp:161
OS_Decorator()
Default constructor of OS_Decorator class.
Definition: printer.cpp:28
std::string getColor(std::ostream &os=std::cout)
Method used to return the selected color of a stream.
Definition: printer.cpp:146
void resetColor(std::ostream &os=std::cout)
Method used to reset the color of a stream.
Definition: printer.cpp:81
const OS_Decorator & operator()(std::ostream &os=std::cout)
Operator overload to assign the value into parentheses to the "current_stream" variable.
Definition: printer.cpp:214
void removeStyle(const std::string &style, std::ostream &os=std::cout)
Method used to remove one of the set styles (useful in case they are more than one).
Definition: printer.cpp:109
void setStyle(const std::string &style, std::ostream &os=std::cout)
Method used to set the style of a stream.
Definition: printer.cpp:66
~OS_Decorator()
Destructor of OS_Decorator class.
Definition: printer.cpp:37
Definition: canvas.cpp:15
const std::unordered_map< std::string, std::string > rst
It is used to store the reset features commands.
Definition: colsty.cpp:114
const std::unordered_map< std::string, std::string > sty
It is used to store the styles.
Definition: colsty.cpp:90
std::ostream & operator<<(OS_Decorator my_shell, const T &elem)
Operator overload to output a modified ostream object which properties are set thanks to the OS_Decor...
Definition: printer.hpp:130
const std::unordered_map< std::string, std::string > col
It is used to store the colors. Note: "bg" is the prefix of the background color features and "bd" is...
Definition: colsty.cpp:31
void print(std::ostream &os=agr::null_stream, const Args &... args)
It can be used to print messages and strings to the output stream, specifying also the stream you wan...
Definition: printer.hpp:38
const std::string & feat(const std::unordered_map< std::string, std::string > &generic_map, const std::string &feat_string)
It takes an std::map object as the first argument and an std::string object (map key) as the second a...
Definition: common.cpp:28