aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-dataloader/csv/Parser.cpp
diff options
context:
space:
mode:
author George L. Albany <Megacake1234@gmail.com>2023-09-14 10:32:23 +0200
committer GitHub <noreply@github.com>2023-09-14 10:32:23 +0200
commit2564d91f23a0b2a332d0d72023caa4091a56d1f1 (patch)
tree1c6dd3021397aa6b75b684ff7647b9ffbd2a4025 /src/openvic-dataloader/csv/Parser.cpp
parent3017487fa30b7f6593bd14e9c9d952ab948a6b80 (diff)
parentfed40d5dd5203bae678be7aea6fd91c73b43e298 (diff)
Merge pull request #14 from OpenVicProject/fix/quoting
Diffstat (limited to 'src/openvic-dataloader/csv/Parser.cpp')
-rw-r--r--src/openvic-dataloader/csv/Parser.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/openvic-dataloader/csv/Parser.cpp b/src/openvic-dataloader/csv/Parser.cpp
index 86ad02e..14ef553 100644
--- a/src/openvic-dataloader/csv/Parser.cpp
+++ b/src/openvic-dataloader/csv/Parser.cpp
@@ -165,16 +165,23 @@ constexpr Parser<Encoding>& Parser<Encoding>::load_from_file(const detail::Has_c
}
template<EncodingType Encoding>
-bool Parser<Encoding>::parse_csv() {
+bool Parser<Encoding>::parse_csv(bool handle_strings) {
if (!_buffer_handler->is_valid()) {
return false;
}
std::optional<std::vector<ParseError>> errors;
+ auto report_error = ovdl::detail::ReporError.path(_file_path).to(detail::OStreamOutputIterator { _error_stream });
if constexpr (Encoding == EncodingType::Windows1252) {
- errors = _buffer_handler->template parse<csv::grammar::windows1252::SemiColonFile>(ovdl::detail::ReporError.path(_file_path).to(detail::OStreamOutputIterator { _error_stream }));
+ if (handle_strings)
+ errors = _buffer_handler->template parse<csv::grammar::windows1252::strings::SemiColonFile>(report_error);
+ else
+ errors = _buffer_handler->template parse<csv::grammar::windows1252::SemiColonFile>(report_error);
} else {
- errors = _buffer_handler->template parse<csv::grammar::utf8::SemiColonFile>(ovdl::detail::ReporError.path(_file_path).to(detail::OStreamOutputIterator { _error_stream }));
+ if (handle_strings)
+ errors = _buffer_handler->template parse<csv::grammar::utf8::strings::SemiColonFile>(report_error);
+ else
+ errors = _buffer_handler->template parse<csv::grammar::utf8::SemiColonFile>(report_error);
}
if (errors) {
_errors.reserve(errors->size());