fix-4.0-template-merge.patch
| src/template/Template.cc | ||
|---|---|---|
| 697 | 697 |
|
| 698 | 698 |
for (it = from_tmpl->attributes.begin(); it != from_tmpl->attributes.end(); ++it) |
| 699 | 699 |
{
|
| 700 |
this->erase(it->first); |
|
| 701 |
} |
|
| 700 |
// Check if an attribute already exists with given name |
|
| 701 |
vector<Attribute *> matches; |
|
| 702 |
get(it->first, matches); |
|
| 702 | 703 |
|
| 703 |
for (it = from_tmpl->attributes.begin(); it != from_tmpl->attributes.end(); ++it) |
|
| 704 |
{
|
|
| 705 |
this->set(it->second->clone()); |
|
| 704 |
if (matches.size() == 0) |
|
| 705 |
{
|
|
| 706 |
// Add new attribute |
|
| 707 |
this->set(it->second->clone()); |
|
| 708 |
continue; |
|
| 709 |
} |
|
| 710 |
|
|
| 711 |
Attribute * attr = matches[0]; |
|
| 712 |
|
|
| 713 |
if (attr->type() != it->second->type() || attr->type() == Attribute::SIMPLE) |
|
| 714 |
{
|
|
| 715 |
// Replace existing attribute |
|
| 716 |
this->erase(it->first); |
|
| 717 |
this->set(it->second->clone()); |
|
| 718 |
} |
|
| 719 |
else if (attr->type() == Attribute::VECTOR) |
|
| 720 |
{
|
|
| 721 |
// Replace values of the first vector that matched |
|
| 722 |
const map<string,string> values = ((VectorAttribute*) it->second)->value(); |
|
| 723 |
|
|
| 724 |
map<string,string>::const_iterator it; |
|
| 725 |
|
|
| 726 |
for (it = values.begin(); it != values.end(); ++it) |
|
| 727 |
{
|
|
| 728 |
((VectorAttribute*) attr)->replace(it->first, it->second); |
|
| 729 |
} |
|
| 730 |
} |
|
| 706 | 731 |
} |
| 707 | 732 |
|
| 708 | 733 |
return 0; |
| 709 |
- |
|