| 616 | } |
| 617 | |
| 618 | void ConfigObject::DumpModifiedAttributes(const std::function<void(const ConfigObject::Ptr&, const String&, const Value&)>& callback) |
| 619 | { |
| 620 | for (const Type::Ptr& type : Type::GetAllTypes()) { |
| 621 | auto *dtype = dynamic_cast<ConfigType *>(type.get()); |
| 622 | |
| 623 | if (!dtype) |
| 624 | continue; |
| 625 | |
| 626 | for (const ConfigObject::Ptr& object : dtype->GetObjects()) { |
| 627 | Dictionary::Ptr originalAttributes = object->GetOriginalAttributes(); |
| 628 | |
| 629 | if (!originalAttributes) |
| 630 | continue; |
| 631 | |
| 632 | ObjectLock olock(originalAttributes); |
| 633 | for (const Dictionary::Pair& kv : originalAttributes) { |
| 634 | String key = kv.first; |
| 635 | |
| 636 | Type::Ptr type = object->GetReflectionType(); |
| 637 | |
| 638 | std::vector<String> tokens = key.Split("."); |
| 639 | |
| 640 | String fieldName = tokens[0]; |
| 641 | int fid = type->GetFieldId(fieldName); |
| 642 | |
| 643 | Value currentValue = object->GetField(fid); |
| 644 | Value modifiedValue; |
| 645 | |
| 646 | if (tokens.size() > 1) { |
| 647 | Value current = currentValue; |
| 648 | |
| 649 | for (std::vector<String>::size_type i = 1; i < tokens.size() - 1; i++) { |
| 650 | if (!current.IsObjectType<Dictionary>()) |
| 651 | BOOST_THROW_EXCEPTION(std::invalid_argument("Value must be a dictionary.")); |
| 652 | |
| 653 | Dictionary::Ptr dict = current; |
| 654 | const String& key = tokens[i]; |
| 655 | |
| 656 | if (!dict->Contains(key)) |
| 657 | break; |
| 658 | |
| 659 | current = dict->Get(key); |
| 660 | } |
| 661 | |
| 662 | if (!current.IsObjectType<Dictionary>()) |
| 663 | BOOST_THROW_EXCEPTION(std::invalid_argument("Value must be a dictionary.")); |
| 664 | |
| 665 | Dictionary::Ptr dict = current; |
| 666 | const String& key = tokens[tokens.size() - 1]; |
| 667 | |
| 668 | modifiedValue = dict->Get(key); |
| 669 | } else |
| 670 | modifiedValue = currentValue; |
| 671 | |
| 672 | callback(object, key, modifiedValue); |
| 673 | } |
| 674 | } |
| 675 | } |
nothing calls this directly
no test coverage detected