From d743cc66d8b81cd4ae4c1413e71d1bfce792a15b Mon Sep 17 00:00:00 2001 From: peri4 Date: Tue, 7 Feb 2023 23:24:43 +0300 Subject: [PATCH] PIValueTree::applyValues --- libs/main/types/pivaluetree.cpp | 13 +++++++++++++ libs/main/types/pivaluetree.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/libs/main/types/pivaluetree.cpp b/libs/main/types/pivaluetree.cpp index 9bceb519..57eaa740 100644 --- a/libs/main/types/pivaluetree.cpp +++ b/libs/main/types/pivaluetree.cpp @@ -105,6 +105,19 @@ void PIValueTree::mergeAttributes(const PIVariantMap & a) { } +void PIValueTree::applyValues(const PIValueTree & root) { + if (_is_null) return; + for (const auto & c: root._children) { + for (auto & i: _children) { + if (c.name() == i.name()) { + i._value.setValueFromString(c.value().toString()); + break; + } + } + } +} + + bool PIValueTree::contains(const PIString & name) const { if (_is_null) return true; for (const auto & c: _children) diff --git a/libs/main/types/pivaluetree.h b/libs/main/types/pivaluetree.h index 8b3ce941..fd760ed9 100644 --- a/libs/main/types/pivaluetree.h +++ b/libs/main/types/pivaluetree.h @@ -88,6 +88,8 @@ public: void setAttribute(const PIString & n, const PIVariant & a); void mergeAttributes(const PIVariantMap & a); + void applyValues(const PIValueTree & root); + const PIVector & children() const { return _children; } void clearChildren() { _children.clear(); }