std::string_view 的使用
This commit is contained in:
@@ -4,12 +4,13 @@
|
||||
#include "Local_Server/Data_Source.h"
|
||||
#include "Local_Server/Data_Source.h"
|
||||
#include "SSR/export.h"
|
||||
#include <string_view>
|
||||
using namespace Psc;
|
||||
int max_distance = 700;
|
||||
class MY_File_Data_Source : public File_Data_Source {
|
||||
public:
|
||||
BaseLogger* logger{};
|
||||
void pre_handle(const std::string& data) override {}
|
||||
void pre_handle(std::string_view data) override {}
|
||||
void handle_mode_s(std::string& packet) override {}
|
||||
};
|
||||
std::map<std::string, Aircraft_Info*> air_map;
|
||||
@@ -45,7 +46,7 @@ void handle(const fs::path& file_path, const fs::path& rel_path) {
|
||||
std::cout << "first:" << mem2hex(packet) << std::endl;
|
||||
return;
|
||||
}
|
||||
std::string error_len = key + " " + LOG_POS_SIMPLE + " mode_s_error_length";
|
||||
std::string_view error_len = key + " " + LOG_POS_SIMPLE + " mode_s_error_length";
|
||||
auto type = packet[1];
|
||||
if (type == Msg::AC) {
|
||||
if (packet.size() != Msg::AC_len) {
|
||||
@@ -97,9 +98,9 @@ void handle(const fs::path& file_path, const fs::path& rel_path) {
|
||||
// 拓展点
|
||||
auto mode_s_msg = std::make_unique<Mode_S_Msg>(nullptr, packet);
|
||||
std::string& msg_hex = mode_s_msg->msg_hex;
|
||||
std::string msg_bin = hex2bin(mode_s_msg->msg_hex);
|
||||
std::string_view msg_bin = hex2bin(mode_s_msg->msg_hex);
|
||||
auto df = ::decode_df(msg_bin);
|
||||
std::string icao = ::decode_icao(msg_bin);
|
||||
std::string_view icao = ::decode_icao(msg_bin);
|
||||
JSON msg_json = JSON::object();
|
||||
MLAT_timestamp* mlat_timestamp = &mode_s_msg->mlat_timestamp;
|
||||
Log_Type lt({}, {
|
||||
@@ -208,7 +209,7 @@ void list_directory(const fs::path& dir_path, const fs::path& base_path) {
|
||||
}
|
||||
}
|
||||
}
|
||||
std::wstring _transformString2Wstring(const std::string& s) {
|
||||
std::wstring _transformString2Wstring(std::string_view s) {
|
||||
setlocale(LC_CTYPE, "en_US.UTF-8");
|
||||
const char* _Source = s.c_str();
|
||||
size_t len = strlen(_Source) + 1;
|
||||
@@ -219,7 +220,7 @@ std::wstring _transformString2Wstring(const std::string& s) {
|
||||
delete[] wStr;
|
||||
return result;
|
||||
}
|
||||
std::wstring gbk_to_wstring(const std::string& gbk) {
|
||||
std::wstring gbk_to_wstring(std::string_view gbk) {
|
||||
int len = MultiByteToWideChar(CP_ACP, 0, gbk.c_str(), -1, nullptr, 0);
|
||||
std::wstring wstr(len, L'\0');
|
||||
MultiByteToWideChar(CP_ACP, 0, gbk.c_str(), -1, &wstr[0], len);
|
||||
|
||||
Reference in New Issue
Block a user