From f0309ee1e5cd268091f59f3aa377beca77d76c5c Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 6 Jun 2021 22:05:28 +0800 Subject: import(life): ... --- works/life/computer-network-experiment/Output.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'works/life/computer-network-experiment/Output.h') diff --git a/works/life/computer-network-experiment/Output.h b/works/life/computer-network-experiment/Output.h index 0e53363..157e5c8 100644 --- a/works/life/computer-network-experiment/Output.h +++ b/works/life/computer-network-experiment/Output.h @@ -1,24 +1,25 @@ #pragma once +#include "Common.h" #include "StringUtil.hpp" -#include - #include #include #include +#include + enum class OutputType { Normal, Error }; struct Output { Output() = default; - Output(std::wstring message, OutputType type = OutputType::Normal) + Output(String message, OutputType type = OutputType::Normal) : message(std::move(message)), type(type) {} CRU_DEFAULT_COPY(Output) CRU_DEFAULT_MOVE(Output) ~Output() = default; - std::wstring message; + String message; OutputType type; }; @@ -28,17 +29,15 @@ inline void SendOutput(Output output) { output_queue.blockingWrite(std::move(output)); } -inline void SendOutput(std::wstring output) { - SendOutput(std::move(output)); -} +inline void SendOutput(String output) { SendOutput(std::move(output)); } template -void SendOutput(std::wstring_view format, Args &&...args) { +void SendOutput(StringView format, Args &&...args) { output_queue.blockingWrite(fmt::format(format, std::forward(args)...)); } template -void SendOutput(OutputType type, std::wstring_view format, Args &&...args) { +void SendOutput(OutputType type, StringView format, Args &&...args) { output_queue.blockingWrite( Output{fmt::format(format, std::forward(args)...), type}); } -- cgit v1.2.3