IDProperty: New util function to merge groups recursively
This commit is contained in:
parent
53d59af364
commit
3cb0e8e1af
|
@ -91,6 +91,7 @@ void IDP_ReplaceGroupInGroup(struct IDProperty *dest, const struct IDProperty *s
|
|||
void IDP_ReplaceInGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
|
||||
void IDP_ReplaceInGroup_ex(struct IDProperty *group, struct IDProperty *prop, struct IDProperty *prop_exist);
|
||||
void IDP_MergeGroup(IDProperty *dest, const IDProperty *src, const bool do_overwrite) ATTR_NONNULL();
|
||||
void IDP_MergeGroupValues(IDProperty *dest, IDProperty *src);
|
||||
bool IDP_AddToGroup(struct IDProperty *group, struct IDProperty *prop) ATTR_NONNULL();
|
||||
bool IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous,
|
||||
struct IDProperty *pnew) ATTR_NONNULL(1 /* group */, 3 /* pnew */);
|
||||
|
|
|
@ -599,6 +599,31 @@ void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop)
|
|||
IDP_ReplaceInGroup_ex(group, prop, prop_exist);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as IDP_MergeGroup but recursively
|
||||
*/
|
||||
void IDP_MergeGroupValues(IDProperty *dest, IDProperty *src)
|
||||
{
|
||||
IDProperty *prop;
|
||||
|
||||
BLI_assert(dest->type == IDP_GROUP);
|
||||
BLI_assert(src->type == IDP_GROUP);
|
||||
|
||||
for (prop = src->data.group.first; prop; prop = prop->next) {
|
||||
if (prop->type == IDP_GROUP) {
|
||||
IDProperty *prop_exist = IDP_GetPropertyFromGroup(dest, prop->name);
|
||||
|
||||
if (prop_exist != NULL) {
|
||||
IDP_MergeGroupValues(prop_exist, prop);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
IDProperty *copy = IDP_CopyProperty(prop);
|
||||
IDP_ReplaceInGroup(dest, copy);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If a property is missing in \a dest, add it.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue