@@ -57,10 +57,6 @@ namespace Csv {
5757 * - Line ending format inside strings is preserved.
5858 * - getOriginalStringView() methods may return escaped double-quotes; string_views are read-only and we
5959 * cannot touch the original CSV data; use getCleanString() methods if you need unescaped data.
60- *
61- * Ambiguity notice:
62- * Empty cell (Invalid QVariant) and empty string (empty std::string) are serialized the same by Excel.
63- * We read them as Invalid QVariants, but QVariant::toByteArray() will give empty std::strings as expected.
6460 */
6561class Parser {
6662 public:
@@ -93,7 +89,7 @@ class Parser {
9389 // / \return std::array<std::array<Cell, rows>, columns>
9490 // / \throws ParseError
9591 template <std::size_t columns, std::size_t rows, typename Cell = CellStringReference>
96- constexpr auto parseTo2DArray (std::string_view data);
92+ constexpr auto parseTo2DArray (std::string_view data) const ;
9793
9894
9995 private:
@@ -428,29 +424,32 @@ template<typename Vector2D>
428424constexpr void Parser::parseTo (std::string_view data, Vector2D& values) const
429425{
430426 Vector2D parsed_values;
431- parse (data, [&](std::size_t row, std::size_t column, std::string_view cell_data, CellTypeHint hint) {
432- if (parsed_values.size () < (column + 1 )) {
433- parsed_values.resize (column + 1 );
434- }
435- if (parsed_values[column].size () < (row + 1 )) {
436- parsed_values[column].resize (row + 1 );
427+ parse (data,
428+ [&parsed_values](std::size_t row, std::size_t column, std::string_view cell_data, CellTypeHint hint)
429+ {
430+ if (parsed_values.size () < (column + 1 )) {
431+ parsed_values.resize (column + 1 );
432+ }
433+ if (parsed_values[column].size () < (row + 1 )) {
434+ parsed_values[column].resize (row + 1 );
435+ }
436+ parsed_values[column][row] = typename Vector2D::value_type::value_type (cell_data, hint);
437437 }
438- parsed_values[column][row] = typename Vector2D::value_type::value_type (cell_data, hint);
439- });
438+ );
440439 std::swap (values, parsed_values);
441440}
442441
443442
444443
445444template <std::size_t columns, std::size_t rows, typename Cell>
446- constexpr auto Parser::parseTo2DArray (std::string_view data)
445+ constexpr auto Parser::parseTo2DArray (std::string_view data) const
447446{
448447 std::array<std::array<Cell, rows>, columns> matrix;
449448
450449 parse (data,
451450 [&matrix](std::size_t row, std::size_t column,
452451 std::string_view cell_data, Csv::CellTypeHint hint)
453- constexpr mutable
452+ constexpr
454453 {
455454 matrix[column][row] = Cell (cell_data, hint);
456455 }
0 commit comments