mirror of
https://github.com/pocoproject/poco.git
synced 2025-05-29 15:34:07 +02:00
fixed array element updating problem in JSONConfiguration
This commit is contained in:
parent
0a46d7c7ac
commit
3880f76d82
@ -154,6 +154,9 @@ public:
|
|||||||
void add(const Dynamic::Var& value);
|
void add(const Dynamic::Var& value);
|
||||||
/// Add the given value to the array
|
/// 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;
|
void stringify(std::ostream& out, unsigned int indent = 0, int step = -1) const;
|
||||||
/// Prints the array to out. When indent has zero value,
|
/// Prints the array to out. When indent has zero value,
|
||||||
/// the array will be printed without newline breaks and spaces between elements.
|
/// 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)
|
inline void Array::remove(unsigned int index)
|
||||||
{
|
{
|
||||||
_values.erase(_values.begin() + index);
|
_values.erase(_values.begin() + index);
|
||||||
|
@ -295,7 +295,7 @@ void JSONConfiguration::setValue(const std::string& key, const Poco::DynamicAny&
|
|||||||
}
|
}
|
||||||
arr = nextArray;
|
arr = nextArray;
|
||||||
}
|
}
|
||||||
arr->add(value);
|
arr->set(indexes.back(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eventsEnabled())
|
if (eventsEnabled())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user