2025-12-12 02:19:45 -06:00

42 lines
1002 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";
}},
{3, [](std::string msg, std::string fmt){
return "\x1b[31m" + msg + "\x1b[0m";
}}
};
using nb::SmartText;
int main() {
auto tout = TestStream(std::cout);
tout << SmartText<SmartText<const char*>>{SmartText<const char*>{"Gloop\n", {3, ""}}, {2, "32"}};
tout << 8989 << "\n";
return 0;
}