| 638 | } |
| 639 | |
| 640 | bool cmGlobalVisualStudioVersionedGenerator::ParseGeneratorInstance( |
| 641 | std::string const& is, cmMakefile* mf) |
| 642 | { |
| 643 | this->GeneratorInstance.clear(); |
| 644 | this->GeneratorInstanceVersion.clear(); |
| 645 | |
| 646 | std::vector<std::string> const fields = |
| 647 | cmTokenize(is, ',', cmTokenizerMode::New); |
| 648 | if (fields.empty()) { |
| 649 | return true; |
| 650 | } |
| 651 | |
| 652 | auto fi = fields.begin(); |
| 653 | // The first field may be the VS instance. |
| 654 | if (fi->find('=') == fi->npos) { |
| 655 | this->GeneratorInstance = *fi; |
| 656 | ++fi; |
| 657 | } |
| 658 | |
| 659 | std::set<std::string> handled; |
| 660 | |
| 661 | // The rest of the fields must be key=value pairs. |
| 662 | for (; fi != fields.end(); ++fi) { |
| 663 | std::string::size_type pos = fi->find('='); |
| 664 | if (pos == fi->npos) { |
| 665 | mf->IssueMessage( |
| 666 | MessageType::FATAL_ERROR, |
| 667 | cmStrCat("Generator\n" |
| 668 | " ", |
| 669 | this->GetName(), |
| 670 | "\n" |
| 671 | "given instance specification\n" |
| 672 | " ", |
| 673 | is, |
| 674 | "\n" |
| 675 | "that contains a field after the first ',' with no '='.")); |
| 676 | return false; |
| 677 | } |
| 678 | std::string const key = fi->substr(0, pos); |
| 679 | std::string const value = fi->substr(pos + 1); |
| 680 | if (!handled.insert(key).second) { |
| 681 | mf->IssueMessage(MessageType::FATAL_ERROR, |
| 682 | cmStrCat("Generator\n" |
| 683 | " ", |
| 684 | this->GetName(), |
| 685 | "\n" |
| 686 | "given instance specification\n" |
| 687 | " ", |
| 688 | is, |
| 689 | "\n" |
| 690 | "that contains duplicate field key '", |
| 691 | key, "'.")); |
| 692 | return false; |
| 693 | } |
| 694 | if (!this->ProcessGeneratorInstanceField(key, value)) { |
| 695 | mf->IssueMessage(MessageType::FATAL_ERROR, |
| 696 | cmStrCat("Generator\n" |
| 697 | " ", |
no test coverage detected