back-port JSON and accompanying Foundation portions (JSONString, Dynamic::Var etc)

This commit is contained in:
Alex Fabijanic
2017-09-25 15:15:05 -05:00
parent 741fead666
commit 6efab2cd58
103 changed files with 22184 additions and 29859 deletions

View File

@@ -26,16 +26,56 @@ namespace Poco {
namespace JSON {
Array::Array()
Array::Array(): _modified(false)
{
}
Array::Array(const Array& copy) : _values(copy._values)
Array::Array(const Array& other) : _values(other._values),
_pArray(other._pArray),
_modified(other._modified)
{
}
Array &Array::operator=(const Array& other)
{
if (&other != this)
{
_values = other._values;
_pArray = other._pArray;
_modified = other._modified;
}
return *this;
}
#ifdef POCO_ENABLE_CPP11
Array::Array(Array&& other) :
_values(std::move(other._values)),
_pArray(!other._modified ? other._pArray : 0),
_modified(other._modified)
{
_pArray = 0;
}
Array &Array::operator= (Array&& other)
{
if (&other != this)
{
_values = std::move(other._values);
_pArray = other._pArray;
other._pArray = 0;
_modified = other._modified;
}
return *this;
}
#endif // POCO_ENABLE_CPP11
Array::~Array()
{
}
@@ -144,13 +184,26 @@ void Array::stringify(std::ostream& out, unsigned int indent, int step) const
}
Array::operator const Poco::Dynamic::Array& () const
void Array::resetDynArray() const
{
if (!_pArray)
_pArray = new Poco::Dynamic::Array;
else
_pArray->clear();
}
Array::operator const Poco::Dynamic::Array& () const
{
if (!_values.size())
{
resetDynArray();
}
else if (_modified)
{
ValueVec::const_iterator it = _values.begin();
ValueVec::const_iterator end = _values.end();
_pArray = new Poco::Dynamic::Array;
resetDynArray();
int index = 0;
for (; it != end; ++it, ++index)
{
@@ -167,6 +220,7 @@ Array::operator const Poco::Dynamic::Array& () const
_pArray->insert(_pArray->end(), *it);
}
}
_modified = false;
}
return *_pArray;