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