| 1591 | } |
| 1592 | |
| 1593 | inline |
| 1594 | line_result decode_tabular_array(const std::vector<parsed_line>& lines, |
| 1595 | std::size_t start_idx, |
| 1596 | std::size_t base_depth, |
| 1597 | const std::vector<jsoncons::string_view>& fields, |
| 1598 | char delimiter, |
| 1599 | std::size_t expected_length, |
| 1600 | const toon_decode_options& options, |
| 1601 | json_visitor& visitor) |
| 1602 | { |
| 1603 | bool strict = options.strict(); |
| 1604 | |
| 1605 | visitor.begin_array(); |
| 1606 | |
| 1607 | std::size_t i = start_idx; |
| 1608 | std::size_t row_depth = base_depth + 1; |
| 1609 | std::size_t row_count =0; |
| 1610 | |
| 1611 | while (i < lines.size()) |
| 1612 | { |
| 1613 | const auto& line = lines[i]; |
| 1614 | if (line.is_blank()) |
| 1615 | { |
| 1616 | if (strict) |
| 1617 | { |
| 1618 | // In strict mode: blank lines at or above row depth are errors |
| 1619 | // Blank lines dedented below row depth mean array has ended |
| 1620 | |
| 1621 | if ((i-start_idx) < expected_length) |
| 1622 | { |
| 1623 | return line_result{jsoncons::unexpect, toon_errc::blank_lines_in_array, line.line_num, 0}; |
| 1624 | } |
| 1625 | else |
| 1626 | { |
| 1627 | break; |
| 1628 | } |
| 1629 | } |
| 1630 | else |
| 1631 | { |
| 1632 | ++i; |
| 1633 | continue; |
| 1634 | } |
| 1635 | } |
| 1636 | if (line.depth < row_depth) |
| 1637 | { |
| 1638 | break; |
| 1639 | } |
| 1640 | if (line.depth > row_depth) |
| 1641 | { |
| 1642 | break; |
| 1643 | } |
| 1644 | auto content = line.content; |
| 1645 | if (is_row_line(content, delimiter)) |
| 1646 | { |
| 1647 | auto r = parse_delimited_values(content, delimiter, fields, visitor); |
| 1648 | if (!r) |
| 1649 | { |
| 1650 | return line_result{jsoncons::unexpect, r.error(), line.line_num, 0}; |
no test coverage detected