mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-26 10:32:56 +01:00
back-port JSON and accompanying Foundation portions (JSONString, Dynamic::Var etc)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user