MCPcopy Create free account
hub / github.com/axmolengine/axmol / mergeWith

Method mergeWith

core/base/Properties.cpp:586–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

584}
585
586void Properties::mergeWith(Properties* overrides)
587{
588 AXASSERT(overrides, "Invalid overrides");
589
590 // Overwrite or add each property found in child.
591 overrides->rewind();
592 const char* name = overrides->getNextProperty();
593 while (name)
594 {
595 this->setString(name, overrides->getString());
596 name = overrides->getNextProperty();
597 }
598 this->_propertiesItr = this->_properties.end();
599
600 // Merge all common nested namespaces, add new ones.
601 Properties* overridesNamespace = overrides->getNextNamespace();
602 while (overridesNamespace)
603 {
604 bool merged = false;
605
606 rewind();
607 Properties* derivedNamespace = getNextNamespace();
608 while (derivedNamespace)
609 {
610 if (derivedNamespace->getNamespace() == overridesNamespace->getNamespace() &&
611 derivedNamespace->getId() == overridesNamespace->getId())
612 {
613 derivedNamespace->mergeWith(overridesNamespace);
614 merged = true;
615 }
616
617 derivedNamespace = getNextNamespace();
618 }
619
620 if (!merged)
621 {
622 // Add this new namespace.
623 Properties* newNamespace = new Properties(*overridesNamespace);
624
625 this->_namespaces.emplace_back(newNamespace);
626 this->_namespacesItr = this->_namespaces.end();
627 }
628
629 overridesNamespace = overrides->getNextNamespace();
630 }
631}
632
633const char* Properties::getNextProperty()
634{

Callers 1

resolveInheritanceMethod · 0.80

Calls 9

setStringMethod · 0.95
getNextPropertyMethod · 0.80
getNextNamespaceMethod · 0.80
getNamespaceMethod · 0.80
rewindMethod · 0.45
getStringMethod · 0.45
endMethod · 0.45
getIdMethod · 0.45
emplace_backMethod · 0.45

Tested by

no test coverage detected