mirror of
https://github.com/red0124/ssp.git
synced 2025-01-23 04:55:20 +01:00
Merge branch 'improvement/throw_on_error' of https://github.com/red0124/ssp into improvement/throw_on_error
This commit is contained in:
commit
7d0a5598a8
@ -169,6 +169,8 @@ public:
|
||||
bool valid() const {
|
||||
if constexpr (string_error) {
|
||||
return error_.empty();
|
||||
} else if constexpr (throw_on_error) {
|
||||
return true;
|
||||
} else {
|
||||
return !error_;
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ public:
|
||||
if constexpr (ignore_header) {
|
||||
ignore_next();
|
||||
} else {
|
||||
header_ = reader_.get_next_row();
|
||||
// TODO read header after use_fields is called
|
||||
header_ = reader_.get_header();
|
||||
}
|
||||
} else {
|
||||
set_error_file_not_open();
|
||||
@ -62,6 +63,8 @@ public:
|
||||
bool valid() const {
|
||||
if constexpr (string_error) {
|
||||
return error_.empty();
|
||||
} else if constexpr (throw_on_error) {
|
||||
return true;
|
||||
} else {
|
||||
return !error_;
|
||||
}
|
||||
@ -770,14 +773,15 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> get_next_row() {
|
||||
std::vector<std::string> next_row;
|
||||
next_line_converter_.split(next_line_buffer_, delim_);
|
||||
auto& next_row_raw = next_line_converter_.splitter_.split_data_;
|
||||
for (const auto& [begin, end] : next_row_raw) {
|
||||
next_row.emplace_back(begin, end);
|
||||
std::vector<std::string> get_header() {
|
||||
std::vector<std::string> header;
|
||||
std::string header_buffer = next_line_buffer_;
|
||||
converter_.split(header_buffer.data(), delim_);
|
||||
auto& header_row_raw = converter_.splitter_.split_data_;
|
||||
for (const auto& [begin, end] : header_row_raw) {
|
||||
header.emplace_back(begin, end);
|
||||
}
|
||||
return next_row;
|
||||
return header;
|
||||
}
|
||||
|
||||
////////////////
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
bool valid() const {
|
||||
if constexpr (string_error) {
|
||||
return error_.empty();
|
||||
} else if constexpr (throw_on_error) {
|
||||
return true;
|
||||
} else {
|
||||
return !error_;
|
||||
}
|
||||
|
@ -689,6 +689,7 @@ std::string no_quote(const std::string& s) {
|
||||
}
|
||||
|
||||
TEST_CASE("parser test csv on multiple lines with quotes") {
|
||||
// TODO test with "_""_""_",...
|
||||
unique_file_name f;
|
||||
std::vector<X> data = {{1, 2, "\"x\r\nx\nx\""},
|
||||
{3, 4, "\"y\ny\r\ny\""},
|
||||
|
Loading…
Reference in New Issue
Block a user