aboutsummaryrefslogtreecommitdiff
path: root/works/life/computer-network-experiment/Common.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/Common.h
parentff92a987ad05e40a1315306b31bbc4a219d2ee1d (diff)
downloadcrupest-f0309ee1e5cd268091f59f3aa377beca77d76c5c.tar.gz
crupest-f0309ee1e5cd268091f59f3aa377beca77d76c5c.tar.bz2
crupest-f0309ee1e5cd268091f59f3aa377beca77d76c5c.zip
import(life): ...
Diffstat (limited to 'works/life/computer-network-experiment/Common.h')
-rw-r--r--works/life/computer-network-experiment/Common.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/works/life/computer-network-experiment/Common.h b/works/life/computer-network-experiment/Common.h
new file mode 100644
index 0000000..1f4fa23
--- /dev/null
+++ b/works/life/computer-network-experiment/Common.h
@@ -0,0 +1,37 @@
+#pragma once
+#include "StringUtil.hpp"
+
+#include <iostream>
+#include <string>
+#include <string_view>
+
+#ifdef WIN32
+using Char = wchar_t;
+using String = std::wstring;
+using StringView = std::wstring_view;
+inline auto &input_stream = std::wcin;
+inline auto &output_stream = std::wcout;
+inline auto &error_stream = std::wcerr;
+#define CRUT(string_literal) L##string_literal
+
+inline String ConvertCharString(std::string_view s) {
+ return cru::ToUtf16WString(s);
+}
+#else
+using Char = char;
+using String = std::string;
+using StringView = std::string_view;
+inline auto &input_stream = std::cin;
+inline auto &output_stream = std::cout;
+inline auto &error_stream = std::cerr;
+#define CRUT(string_literal) string_literal
+
+inline String ConvertCharString(std::string_view s) { return s; }
+#endif
+
+[[noreturn]] void PrintErrorMessageAndExit(StringView message,
+ bool print_last_error = true);
+
+#ifdef WIN32
+void InitWSA();
+#endif