fixed array element updating problem in JSONConfiguration
This commit is contained in:
Родитель
0a46d7c7ac
Коммит
3880f76d82
|
@ -154,6 +154,9 @@ public:
|
|||
void add(const Dynamic::Var& value);
|
||||
/// Add the given value to the array
|
||||
|
||||
void set(unsigned int index, const Dynamic::Var &value);
|
||||
/// Update the element on the given index to specified value
|
||||
|
||||
void stringify(std::ostream& out, unsigned int indent = 0, int step = -1) const;
|
||||
/// Prints the array to out. When indent has zero value,
|
||||
/// the array will be printed without newline breaks and spaces between elements.
|
||||
|
@ -221,6 +224,13 @@ inline void Array::add(const Dynamic::Var& value)
|
|||
}
|
||||
|
||||
|
||||
inline void Array::set(unsigned int index, const Dynamic::Var &value)
|
||||
{
|
||||
if (index >= _values.size()) _values.resize(index + 1);
|
||||
_values[index] = value;
|
||||
}
|
||||
|
||||
|
||||
inline void Array::remove(unsigned int index)
|
||||
{
|
||||
_values.erase(_values.begin() + index);
|
||||
|
|
|
@ -295,7 +295,7 @@ void JSONConfiguration::setValue(const std::string& key, const Poco::DynamicAny&
|
|||
}
|
||||
arr = nextArray;
|
||||
}
|
||||
arr->add(value);
|
||||
arr->set(indexes.back(), value);
|
||||
}
|
||||
|
||||
if (eventsEnabled())
|
||||
|
|
Загрузка…
Ссылка в новой задаче