aboutsummaryrefslogtreecommitdiff
path: root/works/life/computer-network-experiment/Output.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-06-06 22:05:28 +0800
committercrupest <crupest@outlook.com>2021-06-06 22:05:28 +0800
commitf0309ee1e5cd268091f59f3aa377beca77d76c5c (patch)
tree14b86eaf2b9181d9a171ee8c9d11173beeebec52 /works/life/computer-network-experiment/Output.h
parentff92a987ad05e40a1315306b31bbc4a219d2ee1d (diff)
downloadcrupest-f0309ee1e5cd268091f59f3aa377beca77d76c5c.tar.gz
crupest-f0309ee1e5cd268091f59f3aa377beca77d76c5c.tar.bz2
crupest-f0309ee1e5cd268091f59f3aa377beca77d76c5c.zip
import(life): ...
Diffstat (limited to 'works/life/computer-network-experiment/Output.h')
-rw-r--r--works/life/computer-network-experiment/Output.h17
1 files changed, 8 insertions, 9 deletions
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 <iostream>
-
#include <fmt/format.h>
#include <folly/MPMCPipeline.h>
#include <folly/MPMCQueue.h>
+#include <iostream>
+
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 <typename... Args>
-void SendOutput(std::wstring_view format, Args &&...args) {
+void SendOutput(StringView format, Args &&...args) {
output_queue.blockingWrite(fmt::format(format, std::forward<Args>(args)...));
}
template <typename... Args>
-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>(args)...), type});
}