AoC code coverage
Current view: top level - aoclib - LinewiseInput.h (source / functions) Coverage Total Hit
Test: master Lines: 75.0 % 8 6
Test Date: 2025-07-28 10:53:57 Functions: 66.7 % 6 4

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <libassert/assert.hpp>
       4              : 
       5              : #include <algorithm>
       6              : #include <generator>
       7              : #include <span>
       8              : #include <string_view>
       9              : #include <vector>
      10              : 
      11              : template <typename T> class Grid2d;
      12              : 
      13              : class LinewiseInput {
      14              : public:
      15              :   LinewiseInput(std::string_view const text);
      16              : 
      17          319 :   [[nodiscard]] auto begin() const { return std::cbegin(_lines); }
      18          695 :   [[nodiscard]] auto end() const { return std::cend(_lines); }
      19            0 :   [[nodiscard]] auto rbegin() const { return std::crbegin(_lines); }
      20            0 :   [[nodiscard]] auto rend() const { return std::crend(_lines); }
      21              : 
      22           10 :   [[nodiscard]] size_t size() const { return _lines.size(); }
      23              : 
      24            6 :   [[nodiscard]] std::string_view const &operator[](size_t const i) const {
      25              :     DEBUG_ASSERT(i < _lines.size());
      26            6 :     return _lines[i];
      27            6 :   }
      28              : 
      29              :   [[nodiscard]] std::vector<std::span<std::string_view const>> splitOnEmptyLines() const;
      30              : 
      31              :   [[nodiscard]] bool allLinesOfSameSize() const;
      32              : 
      33              :   [[nodiscard]] Grid2d<char> makeCharGrid2d() const;
      34              :   [[nodiscard]] Grid2d<char> makeCharGrid2dWithGhostLayers(int const numGhostLayers,
      35              :                                                            char const fillElement) const;
      36              : 
      37              : private:
      38              :   std::vector<std::string_view> _lines;
      39              : };
      40              : 
      41              : std::generator<std::string_view> getLineWise(std::string_view const text);
      42              : 
      43              : Grid2d<char> makeCharGrid2d(std::span<std::string_view const> const lines);
        

Generated by: LCOV version 2.0-1