Skip to content

Commit 049920f

Browse files
committed
modify str convert
1 parent 62fe13d commit 049920f

File tree

4 files changed

+9
-31
lines changed

4 files changed

+9
-31
lines changed

openapi-cpp-sdk.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@
170170
<ClInclude Include="include\tigerapi\utils.h" />
171171
<ClInclude Include="include\tigerapi\version.h" />
172172
<ClInclude Include="include\tigerapi\win32.h" />
173-
<ClInclude Include="src\common\base64.h" />
174173
<ClInclude Include="src\common\sign_util.h" />
175174
</ItemGroup>
176175
<ItemGroup>

openapi-cpp-sdk.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
<ClInclude Include="src\common\sign_util.h">
5555
<Filter>src\common</Filter>
5656
</ClInclude>
57-
<ClInclude Include="src\common\base64.h">
58-
<Filter>src\common</Filter>
59-
</ClInclude>
6057
<ClInclude Include="include\tigerapi\win32.h">
6158
<Filter>include\tigerapi</Filter>
6259
</ClInclude>

src/contract_util.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,8 @@ Contract future_contract(const utility::string_t symbol, const utility::string_t
3535

3636

3737
std::tuple<utility::string_t , utility::string_t , utility::string_t , utility::string_t> extract_option_info(const utility::string_t identifier) {
38-
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
39-
auto trans_identifier = utility::conversions::utf16_to_utf8(identifier);
40-
#else
41-
auto trans_identifier = identifier;
42-
#endif
38+
auto trans_identifier = str16to8(identifier);
39+
4340
if (!trans_identifier.empty()) {
4441
std::regex pattern(R"((\w+(?:\.\w+)?)\s*(\d{6})([CP])(\d+))");
4542
std::smatch matches;
@@ -52,15 +49,8 @@ std::tuple<utility::string_t , utility::string_t , utility::string_t , utility::
5249
expiry = expiry.substr(0, 4) + "-" + expiry.substr(4, 2) + "-" + expiry.substr(6);
5350
}
5451
right = (right == "C") ? "CALL" : "PUT";
55-
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
56-
57-
return std::make_tuple(utility::conversions::utf8_to_utf16(underlying_symbol),
58-
utility::conversions::utf8_to_utf16(expiry),
59-
utility::conversions::utf8_to_utf16(right),
52+
return std::make_tuple(str8to16(underlying_symbol), str8to16(expiry), str8to16(right),
6053
strike);
61-
#else
62-
return std::make_tuple(underlying_symbol, expiry, right, strike);
63-
#endif
6454
}
6555
}
6656
return std::make_tuple(U(""), U(""), U(""), U(""));

src/utils.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,16 @@ utility::string_t get_device_id() {
216216
rng.seed(std::random_device()());
217217
std::uniform_int_distribution<> dist(0, 255);
218218

219-
std::ostringstream macAddressString;
220-
macAddressString << std::hex << std::setfill('0');
219+
std::ostringstream mac_addr;
220+
mac_addr << std::hex << std::setfill('0');
221221
for (int i = 0; i < 6; i++) {
222222
int n = dist(rng);
223-
macAddressString << std::setw(2) << n;
223+
mac_addr << std::setw(2) << n;
224224
if (i < 5) {
225-
macAddressString << ':';
225+
mac_addr << ':';
226226
}
227227
}
228-
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
229-
return utility::conversions::utf8_to_utf16(macAddressString.str());
230-
#else
231-
return macAddressString.str();
232-
#endif
228+
return str8to16(mac_addr.str());
233229
}
234230

235231

@@ -296,9 +292,5 @@ utility::string_t double_to_string(double num, int precision)
296292
std::ostringstream stream;
297293
stream << std::fixed << std::setprecision(precision) << num;
298294
std::string result = stream.str();
299-
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
300-
return utility::conversions::utf8_to_utf16(result);
301-
#else
302-
return result;
303-
#endif
295+
return str8to16(result);
304296
}

0 commit comments

Comments
 (0)