std::string_view 的使用
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include <string_view>
|
||||
#include "Data_Source_Handler.h"
|
||||
namespace Psc {
|
||||
class SM_RingBuffer;
|
||||
@@ -263,7 +264,7 @@ public:
|
||||
}
|
||||
asio::awaitable<void> _close() override;
|
||||
asio::awaitable<void> _open() override;
|
||||
std::vector<std::string> readBinaryFileAsString(const std::string& filepath,
|
||||
std::vector<std::string> readBinaryFileAsString(std::string_view filepath,
|
||||
size_t part_size);
|
||||
void from_json(const Psc::JSON* that_json) override {
|
||||
Data_Source::from_json(that_json);
|
||||
@@ -370,7 +371,7 @@ protected:
|
||||
std::unique_ptr<Psc::SM_RingBuffer> sm;
|
||||
};
|
||||
inline std::shared_ptr<Data_Source>
|
||||
create_data_source_from_type(const std::string& t) {
|
||||
create_data_source_from_type(std::string_view t) {
|
||||
std::shared_ptr<Data_Source> ret{};
|
||||
if (t == "Serial_Data_Source")
|
||||
ret = std::make_shared<Serial_Data_Source>();
|
||||
@@ -384,7 +385,7 @@ create_data_source_from_type(const std::string& t) {
|
||||
ret = std::make_shared<Shared_Memory_Data_Source>();
|
||||
else {
|
||||
std::cout << "未知�?Data_Source type类型!" << std::endl;
|
||||
throw std::invalid_argument("unknown Data_Source type: " + t);
|
||||
throw std::invalid_argument("unknown Data_Source type: " + std::string(t));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user