2025-12-09 03:24:30 -06:00

39 lines
853 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;
// using Base::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;
return 0;
}