Got SmartOStreams kinda working!

This commit is contained in:
NaifBanana
2025-12-09 03:24:30 -06:00
parent 85875d8130
commit 95120f411e
9 changed files with 384 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.26.0)
project(gtest_Graphics VERSION 0.1.0 LANGUAGES C CXX)
add_executable(SmartStreamTest main.cpp)
target_link_libraries(SmartStreamTest NBCore)
+38
View File
@@ -0,0 +1,38 @@
#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;
}