mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-01 09:24:55 +02:00
fixed GH #2249: Poco::JSON::Object::set() should return reference to this to allow chaining
This commit is contained in:
parent
35ba02e4a9
commit
5a1bf5eb4a
@ -172,10 +172,10 @@ public:
|
||||
return value;
|
||||
}
|
||||
|
||||
void add(const Dynamic::Var& value);
|
||||
Array& add(const Dynamic::Var& value);
|
||||
/// Add the given value to the array
|
||||
|
||||
void set(unsigned int index, const Dynamic::Var& value);
|
||||
Array& 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;
|
||||
@ -264,18 +264,20 @@ inline bool Array::isArray(ConstIterator& it) const
|
||||
}
|
||||
|
||||
|
||||
inline void Array::add(const Dynamic::Var& value)
|
||||
inline Array& Array::add(const Dynamic::Var& value)
|
||||
{
|
||||
_values.push_back(value);
|
||||
_modified = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline void Array::set(unsigned int index, const Dynamic::Var& value)
|
||||
inline Array& Array::set(unsigned int index, const Dynamic::Var& value)
|
||||
{
|
||||
if (index >= _values.size()) _values.resize(index + 1);
|
||||
_values[index] = value;
|
||||
_modified = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,7 +209,7 @@ public:
|
||||
std::size_t size() const;
|
||||
/// Returns the number of properties.
|
||||
|
||||
void set(const std::string& key, const Dynamic::Var& value);
|
||||
Object& set(const std::string& key, const Dynamic::Var& value);
|
||||
/// Sets a new value.
|
||||
|
||||
void stringify(std::ostream& out, unsigned int indent = 0, int step = -1) const;
|
||||
|
@ -199,7 +199,7 @@ const std::string& Object::getKey(KeyList::const_iterator& iter) const
|
||||
}
|
||||
|
||||
|
||||
void Object::set(const std::string& key, const Dynamic::Var& value)
|
||||
Object& Object::set(const std::string& key, const Dynamic::Var& value)
|
||||
{
|
||||
std::pair<ValueMap::iterator, bool> ret = _values.insert(ValueMap::value_type(key, value));
|
||||
if (!ret.second) ret.first->second = value;
|
||||
@ -209,11 +209,12 @@ void Object::set(const std::string& key, const Dynamic::Var& value)
|
||||
KeyList::iterator end = _keys.end();
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
if (key == (*it)->first) return;
|
||||
if (key == (*it)->first) return *this;
|
||||
}
|
||||
_keys.push_back(ret.first);
|
||||
}
|
||||
_modified = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user