| 198 | } |
| 199 | |
| 200 | void BibTeXFile::parseFields(BibTeXFile::Entry & e, const QString & block, const size_type startPos) |
| 201 | { |
| 202 | QChar startDelim, endDelim; |
| 203 | size_type pos{startPos}; |
| 204 | |
| 205 | do { |
| 206 | size_type start{pos}; |
| 207 | pos = block.indexOf(QChar::fromLatin1('='), start); |
| 208 | if (pos < 0) break; |
| 209 | const QString key = block.mid(start, pos - start).trimmed(); |
| 210 | QString val; |
| 211 | |
| 212 | start = -1; |
| 213 | |
| 214 | // Skip initial whitespace |
| 215 | size_type i; |
| 216 | for (i = pos + 1; i < block.size() && start < 0; ++i) { |
| 217 | if (!block[i].isSpace()) start = i; |
| 218 | } |
| 219 | |
| 220 | for (i = start; i < block.size(); ++i) { |
| 221 | if (block[i] == QChar::fromLatin1(',')) { |
| 222 | // Skip ',' and break out of the loop |
| 223 | ++i; |
| 224 | break; |
| 225 | } |
| 226 | if (block[i] == QChar::fromLatin1('{')) { |
| 227 | startDelim = QChar::fromLatin1('{'); |
| 228 | endDelim = QChar::fromLatin1('}'); |
| 229 | } |
| 230 | else if (block[i] == QChar::fromLatin1('"')) { |
| 231 | startDelim = QChar::fromLatin1('"'); |
| 232 | endDelim = QChar::fromLatin1('"'); |
| 233 | } |
| 234 | else { |
| 235 | val += block[i]; |
| 236 | continue; |
| 237 | } |
| 238 | |
| 239 | size_type end = findBlock(block, i, startDelim, endDelim); |
| 240 | if (end < 0) { |
| 241 | val += block.mid(i); |
| 242 | i = block.size(); |
| 243 | } |
| 244 | else { |
| 245 | val += block.mid(i, end - i + 1); |
| 246 | i = end; |
| 247 | } |
| 248 | } |
| 249 | e._fields[key] = val.trimmed(); |
| 250 | pos = i; |
| 251 | } while (pos >= 0 && pos + 1 < block.size()); |
| 252 | } |
| 253 | |
| 254 | unsigned int BibTeXFile::numEntries() const |
| 255 | { |
nothing calls this directly
no test coverage detected