blob: 6886e38cb9d6d4c914154cea7e1f324e4d82e9c1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#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);
}
inline std::string ConvertCharStringBack(StringView s) {
return cru::ToUtf8(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 String(s); }
inline std::string ConvertCharStringBack(StringView s) { return {s}; }
#endif
int Main();
[[noreturn]] void PrintErrorMessageAndExit(StringView message,
bool print_last_error = true);
int CloseSocket(int socket);
void BeforeExit();
String ReadInputLine();
void SafeSend(int socket, std::string_view buffer);
std::string SafeReadUntil(int socket, char c, std::string &rest);
|