aboutsummaryrefslogtreecommitdiff
path: root/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
commit27f3043a55e97c13eb586cf71a3d50cf48f67aca (patch)
treeaaaf3863b1832e8ad65df5c00c70ad99160f3fe7 /computer-network-experiment/Output.h
parentc548f911b47d8bbaa951e9e5d18bf9f1f95afacb (diff)
downloadlife-27f3043a55e97c13eb586cf71a3d50cf48f67aca.tar.gz
life-27f3043a55e97c13eb586cf71a3d50cf48f67aca.tar.bz2
life-27f3043a55e97c13eb586cf71a3d50cf48f67aca.zip
...
Diffstat (limited to 'computer-network-experiment/Output.h')
-rw-r--r--computer-network-experiment/Output.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/computer-network-experiment/Output.h b/computer-network-experiment/Output.h
index 0e53363..157e5c8 100644
--- a/computer-network-experiment/Output.h
+++ b/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});
}