version 5.5.4
add PIValueTree::merge PIValueTreeConversions::from*File supports .override files (replace or add values) empty JSON arrays now 0 size
This commit is contained in:
@@ -124,6 +124,23 @@ void PIValueTree::applyValues(const PIValueTree & root, bool recursive) {
|
||||
}
|
||||
|
||||
|
||||
void PIValueTree::merge(const PIValueTree & root) {
|
||||
if (_is_null) return;
|
||||
for (const auto & c: root._children) {
|
||||
bool found = false;
|
||||
for (auto & i: _children) {
|
||||
if (c.name() == i.name()) {
|
||||
if (c.isValid()) i._value = c._value;
|
||||
i.merge(c);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) _children << c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PIVariant PIValueTree::childValue(const PIString & child_name, const PIVariant & default_value, bool * exists) const {
|
||||
const PIValueTree & node = child(child_name);
|
||||
if (node.isNull()) {
|
||||
|
||||
@@ -170,6 +170,13 @@ public:
|
||||
//! \param recursive Если установлено в true, то значения будут применяться рекурсивно к дочерним узлам.
|
||||
void applyValues(const PIValueTree & root, bool recursive = true);
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Set or add the values of a given %PIValueTree object to the current %PIValueTree object.
|
||||
//! \param root The %PIValueTree object whose values are to be merged.
|
||||
//! \~russian Устанавливает или добавляет значения данного объекта %PIValueTree к текущему объекту %PIValueTree.
|
||||
//! \param root Объект %PIValueTree, значения которого должны быть добавлены.
|
||||
void merge(const PIValueTree & root);
|
||||
|
||||
//! \~\brief
|
||||
//! \~english Returns the children of the current %PIValueTree object.
|
||||
//! \~russian Возвращает дочерние элементы текущего объекта %PIValueTree.
|
||||
|
||||
Reference in New Issue
Block a user