| 94 | }; |
| 95 | |
| 96 | class CSVRunner |
| 97 | { |
| 98 | public: |
| 99 | explicit CSVRunner(CSVReader && reader); |
| 100 | |
| 101 | class Iterator |
| 102 | { |
| 103 | public: |
| 104 | using iterator_category = std::input_iterator_tag; |
| 105 | using value_type = CSVReader::Row; |
| 106 | |
| 107 | explicit Iterator(CSVReader & reader, bool isEnd = false); |
| 108 | Iterator(Iterator const & other); |
| 109 | Iterator & operator++(); |
| 110 | Iterator operator++(int); |
| 111 | // Checks whether both this and other are equal. Two CSVReader iterators are equal if both of |
| 112 | // them are end-of-file iterators or not and both of them refer to the same CSVReader. |
| 113 | bool operator==(Iterator const & other) const; |
| 114 | bool operator!=(Iterator const & other) const; |
| 115 | CSVReader::Row & operator*(); |
| 116 | |
| 117 | private: |
| 118 | CSVReader & m_reader; |
| 119 | std::optional<CSVReader::Row> m_current; |
| 120 | }; |
| 121 | |
| 122 | // Warning: It reads first line. |
| 123 | Iterator begin(); |
| 124 | Iterator end(); |
| 125 | |
| 126 | private: |
| 127 | CSVReader m_reader; |
| 128 | }; |
| 129 | } // namespace coding |
no outgoing calls