|
25 | 25 | #include <iostream> |
26 | 26 | #include <sstream> |
27 | 27 |
|
28 | | -#ifdef _WIN32 |
29 | | -#include <Windows.h> |
30 | | -#endif |
31 | | - |
32 | 28 | namespace libcdoc { |
33 | 29 |
|
34 | 30 | std::string toBase64(const uint8_t *data, size_t len); |
@@ -79,7 +75,7 @@ join(const std::vector<std::string> &parts, const std::string_view sep) |
79 | 75 | if (part != parts.front()) result += sep; |
80 | 76 | result += part; |
81 | 77 | } |
82 | | - return std::move(result); |
| 78 | + return result; |
83 | 79 | } |
84 | 80 |
|
85 | 81 | std::vector<std::string> JsonToStringArray(std::string_view json); |
@@ -123,83 +119,7 @@ std::string buildURL(const std::string& host, int port); |
123 | 119 | std::string urlEncode(std::string_view src); |
124 | 120 | std::string urlDecode(const std::string &src); |
125 | 121 |
|
126 | | -#ifdef _WIN32 |
127 | | - |
128 | | -static std::wstring toWide(UINT codePage, const std::string &in) |
129 | | -{ |
130 | | - std::wstring result; |
131 | | - if(in.empty()) |
132 | | - return result; |
133 | | - int len = MultiByteToWideChar(codePage, 0, in.data(), int(in.size()), nullptr, 0); |
134 | | - result.resize(size_t(len), 0); |
135 | | - len = MultiByteToWideChar(codePage, 0, in.data(), int(in.size()), &result[0], len); |
136 | | - return result; |
137 | | -} |
138 | | - |
139 | | -static std::wstring |
140 | | -toWide(const std::string& in) |
141 | | -{ |
142 | | - return toWide(CP_UTF8, in); |
143 | | -} |
144 | | - |
145 | | -static std::string toMultiByte(UINT codePage, const std::wstring &in) |
146 | | -{ |
147 | | - std::string result; |
148 | | - if(in.empty()) |
149 | | - return result; |
150 | | - int len = WideCharToMultiByte(codePage, 0, in.data(), int(in.size()), nullptr, 0, nullptr, nullptr); |
151 | | - result.resize(size_t(len), 0); |
152 | | - len = WideCharToMultiByte(codePage, 0, in.data(), int(in.size()), &result[0], len, nullptr, nullptr); |
153 | | - return result; |
154 | | -} |
155 | | - |
156 | | -static std::string |
157 | | -toUTF8(const std::wstring& in) |
158 | | -{ |
159 | | - return toMultiByte(CP_UTF8, in); |
160 | | -} |
161 | | - |
162 | | - |
163 | | -#endif |
164 | | - |
165 | | -static std::string toUTF8(const std::string &in) |
166 | | -{ |
167 | | -#ifdef _WIN32 |
168 | | - return toMultiByte(CP_UTF8, toWide(CP_ACP, in)); |
169 | | -#else |
170 | | - return in; |
171 | | -#endif |
172 | | -} |
173 | | - |
174 | | -static std::vector<unsigned char> readFile(const std::string &path) |
175 | | -{ |
176 | | - std::vector<unsigned char> data; |
177 | | -#ifdef _WIN32 |
178 | | - std::ifstream f(toWide(CP_UTF8, path).c_str(), std::ifstream::binary); |
179 | | -#else |
180 | | - std::ifstream f(path, std::ifstream::binary); |
181 | | -#endif |
182 | | - if (!f) |
183 | | - return data; |
184 | | - f.seekg(0, std::ifstream::end); |
185 | | - data.resize(size_t(f.tellg())); |
186 | | - f.clear(); |
187 | | - f.seekg(0); |
188 | | - f.read((char*)data.data(), std::streamsize(data.size())); |
189 | | - return data; |
190 | | -} |
191 | | - |
192 | | -static void writeFile(const std::string &path, const std::vector<unsigned char> &data) |
193 | | -{ |
194 | | -#ifdef _WIN32 |
195 | | - std::ofstream f(toWide(CP_UTF8, path).c_str(), std::ofstream::binary); |
196 | | -#else |
197 | | - std::ofstream f(path.c_str(), std::ofstream::binary); |
198 | | -#endif |
199 | | - f.write((const char*)data.data(), std::streamsize(data.size())); |
200 | | -} |
201 | | - |
202 | | -} // vectorwrapbuf |
| 122 | +} // namespace libcdoc |
203 | 123 |
|
204 | 124 | // A source implementation that always keeps last 16 bytes in tag |
205 | 125 |
|
|
0 commit comments