| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "na64util/csv-io.hh" | ||
| 2 | |||
| 3 | #include <cassert> | ||
| 4 | |||
| 5 | namespace na64dp { | ||
| 6 | |||
| 7 | namespace error { | ||
| 8 | |||
| 9 | ✗ | CSVParsingError::CSVParsingError( const char * what_ | |
| 10 | , size_t nLine | ||
| 11 | ✗ | , size_t nToken ) throw() : std::runtime_error( what_ ) | |
| 12 | ✗ | , _nLine(nLine) | |
| 13 | ✗ | , _nToken(nToken) {} | |
| 14 | |||
| 15 | } // namespace ::na64dp::error | ||
| 16 | |||
| 17 | namespace csv { | ||
| 18 | |||
| 19 | ✗ | Reader::Reader( std::istream & is | |
| 20 | , size_t lineCountStart | ||
| 21 | ✗ | , const std::string & tokRx ) : _lineCount(lineCountStart) | |
| 22 | ✗ | , _is(is) | |
| 23 | ✗ | , _wrx(tokRx) | |
| 24 | ✗ | , _lastMatchPos(std::string::npos) {} | |
| 25 | |||
| 26 | std::string | ||
| 27 | ✗ | Reader::_get_next_line() { | |
| 28 | ✗ | std::string line; | |
| 29 | ✗ | while( std::getline(_is, line) ) { | |
| 30 | ✗ | ++_lineCount; | |
| 31 | ✗ | size_t startpos = line.find_first_not_of(" \t"); | |
| 32 | // omit blank lines | ||
| 33 | ✗ | if( startpos == std::string::npos ) continue; | |
| 34 | // omit lines starting with `#` | ||
| 35 | ✗ | if( '#' == line[startpos] ) continue; | |
| 36 | ✗ | return line; | |
| 37 | } | ||
| 38 | ✗ | assert(line.empty()); | |
| 39 | ✗ | return line; // return empty line (stream depleted) | |
| 40 | } | ||
| 41 | |||
| 42 | } // namespace ::na64dp::csv | ||
| 43 | } // namespace na64dp | ||
| 44 | |||
| 45 | |||
| 46 |