| 62 | } |
| 63 | |
| 64 | void ConfigParser::parseLine(std::string line, std::string const& filename, int line_no) |
| 65 | { |
| 66 | // maybe check for all-whitespace m_lines, too? |
| 67 | if (line.empty() || line.find('#') != std::string::npos) |
| 68 | { |
| 69 | return; |
| 70 | } |
| 71 | |
| 72 | Line result; |
| 73 | result.line_no = line_no; |
| 74 | result.filename = filename; |
| 75 | auto lbrace = line.find('['); |
| 76 | |
| 77 | if (lbrace != std::string::npos) |
| 78 | { |
| 79 | auto rbrace = line.find(']'); |
| 80 | if (rbrace == std::string::npos || rbrace < lbrace) |
| 81 | { |
| 82 | error("unmatched ["); |
| 83 | } |
| 84 | result.data = line.substr(lbrace+1, rbrace-lbrace-1); |
| 85 | result.is_header = true; |
| 86 | m_lines.push_back(result); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | auto eq = line.find('='); |
| 91 | if (eq == std::string::npos) |
| 92 | { |
| 93 | error("unrecognised data"); |
| 94 | } |
| 95 | result.data = line.substr(0, eq); |
| 96 | result.extra_data = line.substr(eq+1); |
| 97 | m_lines.push_back(result); |
| 98 | } |
| 99 | |
| 100 | char const* ParseError::what() const noexcept |
| 101 | { |
nothing calls this directly
no outgoing calls
no test coverage detected