37 lines
829 B
C++
37 lines
829 B
C++
#include <iostream>
|
|
|
|
#include "SmartStreams.hpp"
|
|
|
|
template <typename ST>
|
|
class TestStream : public nb::SmartOStream<ST, TestStream<ST>> {
|
|
using Base = nb::SmartOStream<ST, TestStream<ST>>;
|
|
public:
|
|
TestStream(ST& stream) : Base(stream) {}
|
|
|
|
static const nb::SmartFormatMap Formatters;
|
|
|
|
protected:
|
|
};
|
|
|
|
template<typename ST>
|
|
const nb::SmartFormatMap TestStream<ST>::Formatters = {
|
|
{0, [](std::string msg, std::string fmt){
|
|
return "[0] : " + msg;
|
|
}},
|
|
{1, [](std::string msg, std::string fmt){
|
|
return "\x1b[" + fmt + "m" + msg + "\x1b[0m";
|
|
}},
|
|
{2, [](std::string msg, std::string fmt){
|
|
return "\x1b[1m" + msg + "\x1b[0m";
|
|
}}
|
|
};
|
|
|
|
int main() {
|
|
|
|
auto tout = TestStream(std::cout);
|
|
tout << nb::SmartText{"Gloop!\n", {2, "32"}};
|
|
tout << 8989 << "\n";
|
|
|
|
return 0;
|
|
}
|