| 362 | } |
| 363 | |
| 364 | pair<size_t, size_t> Settings::sanityCheck() |
| 365 | { |
| 366 | size_t countProblems = 0; |
| 367 | size_t countCritical = 0; |
| 368 | |
| 369 | // check for unknown keywords |
| 370 | for (multimap<string, pair<string, size_t> >::const_iterator |
| 371 | it = contents.begin(); it != contents.end(); ++it) |
| 372 | { |
| 373 | if (knownKeywords.find((*it).first) == knownKeywords.end()) |
| 374 | { |
| 375 | countProblems++; |
| 376 | log.push_back(strpr( |
| 377 | "WARNING: Unknown keyword \"%s\" at line %zu.\n", |
| 378 | (*it).first.c_str(), |
| 379 | (*it).second.second + 1)); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | // check for multiple instances of known keywords (with exceptions) |
| 384 | for (KeywordList::const_iterator it = knownKeywords.begin(); |
| 385 | it != knownKeywords.end(); ++it) |
| 386 | { |
| 387 | if (contents.count((*it).first) > 1 |
| 388 | && (*it).first != "symfunction_short" |
| 389 | && (*it).first != "atom_energy" |
| 390 | && (*it).first != "element_nodes_short") |
| 391 | { |
| 392 | countProblems++; |
| 393 | countCritical++; |
| 394 | log.push_back(strpr( |
| 395 | "WARNING (CRITICAL): Multiple instances of \"%s\" detected.\n", |
| 396 | (*it).first.c_str())); |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | // Check for usage of multiple keyword versions. |
| 401 | for (KeywordList::const_iterator it = knownKeywords.begin(); |
| 402 | it != knownKeywords.end(); ++it) |
| 403 | { |
| 404 | if (it->second->isUnique()) continue; |
| 405 | vector<string> duplicates; |
| 406 | for (auto keyword : it->second->words) |
| 407 | { |
| 408 | if (contents.find(keyword) != contents.end()) |
| 409 | { |
| 410 | duplicates.push_back(keyword); |
| 411 | } |
| 412 | } |
| 413 | if (duplicates.size() > 1) |
| 414 | { |
| 415 | countProblems++; |
| 416 | countCritical++; |
| 417 | log.push_back(strpr( |
| 418 | "WARNING (CRITICAL): Multiple alternative versions of keyword " |
| 419 | "\"%s\" detected:.\n", (*it).first.c_str())); |
| 420 | for (auto d : duplicates) |
| 421 | { |