| 114 | |
| 115 | |
| 116 | void TextReader::parseQuotedHeader(const std::string& header) |
| 117 | { |
| 118 | // We know there's a double quote at position 0. |
| 119 | std::string::size_type pos = 1; |
| 120 | while (true) |
| 121 | { |
| 122 | size_t count = Dimension::extractName(header, pos); |
| 123 | m_dimNames.push_back(header.substr(pos, count)); |
| 124 | pos += count; |
| 125 | if (header[pos] != '"') |
| 126 | throwError("Invalid character '" + std::string(1, header[pos]) + |
| 127 | "' found while parsing quoted header line."); |
| 128 | pos++; // Skip ending quote. |
| 129 | |
| 130 | // Skip everything other than a double quote. |
| 131 | count = Utils::extract(header, pos, [](char c){ return c != '"'; }); |
| 132 | |
| 133 | // Find a separator. |
| 134 | if (!m_separatorArg->set()) |
| 135 | { |
| 136 | std::string sep = header.substr(pos, count); |
| 137 | Utils::trim(sep); |
| 138 | if (sep.size() > 1) |
| 139 | throwError("Found separator longer than a single character."); |
| 140 | if (sep.size() == 0) |
| 141 | sep = ' '; |
| 142 | m_separatorArg->setValue(sep); |
| 143 | } |
| 144 | pos += count; |
| 145 | if (header[pos++] != '"') |
| 146 | break; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | void TextReader::parseUnquotedHeader(const std::string& header) |
| 151 | { |
nothing calls this directly
no test coverage detected