|
|
@ -56,14 +56,9 @@ namespace Jzon
|
|
|
|
|
|
|
|
|
|
|
|
std::string GetIndentation(unsigned int level) const
|
|
|
|
std::string GetIndentation(unsigned int level) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!format.newline)
|
|
|
|
if (format.newline)
|
|
|
|
{
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return std::string(format.indentSize * level, indentationChar);
|
|
|
|
return std::string(format.indentSize * level, indentationChar);
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline const std::string &GetNewline() const
|
|
|
|
inline const std::string &GetNewline() const
|
|
|
@ -104,57 +99,49 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsObject())
|
|
|
|
if (IsObject())
|
|
|
|
return static_cast<const Object&>(*this);
|
|
|
|
return static_cast<const Object&>(*this);
|
|
|
|
else
|
|
|
|
|
|
|
|
throw TypeException();
|
|
|
|
throw TypeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Array &Node::AsArray()
|
|
|
|
Array &Node::AsArray()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsArray())
|
|
|
|
if (IsArray())
|
|
|
|
return static_cast<Array &>(*this);
|
|
|
|
return static_cast<Array &>(*this);
|
|
|
|
else
|
|
|
|
|
|
|
|
throw TypeException();
|
|
|
|
throw TypeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const Array &Node::AsArray() const
|
|
|
|
const Array &Node::AsArray() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsArray())
|
|
|
|
if (IsArray())
|
|
|
|
return static_cast<const Array &>(*this);
|
|
|
|
return static_cast<const Array &>(*this);
|
|
|
|
else
|
|
|
|
|
|
|
|
throw TypeException();
|
|
|
|
throw TypeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Value &Node::AsValue()
|
|
|
|
Value &Node::AsValue()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsValue())
|
|
|
|
if (IsValue())
|
|
|
|
return static_cast<Value &>(*this);
|
|
|
|
return static_cast<Value &>(*this);
|
|
|
|
else
|
|
|
|
|
|
|
|
throw TypeException();
|
|
|
|
throw TypeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const Value &Node::AsValue() const
|
|
|
|
const Value &Node::AsValue() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsValue())
|
|
|
|
if (IsValue())
|
|
|
|
return static_cast<const Value &>(*this);
|
|
|
|
return static_cast<const Value &>(*this);
|
|
|
|
else
|
|
|
|
|
|
|
|
throw TypeException();
|
|
|
|
throw TypeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Node::Type Node::DetermineType(const std::string &json)
|
|
|
|
Node::Type Node::DetermineType(const std::string &json)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto jsonIt = json.begin();
|
|
|
|
auto jsonIt = std::find_if(json.begin(), json.end(), IsWhitespace);
|
|
|
|
|
|
|
|
|
|
|
|
while (jsonIt != json.end() && IsWhitespace(*jsonIt))
|
|
|
|
|
|
|
|
++jsonIt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (jsonIt == json.end())
|
|
|
|
if (jsonIt == json.end())
|
|
|
|
return T_VALUE;
|
|
|
|
return T_VALUE;
|
|
|
|
|
|
|
|
|
|
|
|
switch (*jsonIt)
|
|
|
|
switch (*jsonIt) {
|
|
|
|
{
|
|
|
|
case '{':
|
|
|
|
case '{' : return T_OBJECT;
|
|
|
|
return T_OBJECT;
|
|
|
|
case '[' : return T_ARRAY;
|
|
|
|
case '[':
|
|
|
|
default : return T_VALUE;
|
|
|
|
return T_ARRAY;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return T_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Value::Value() : Node()
|
|
|
|
Value::Value() : Node()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SetNull();
|
|
|
|
SetNull();
|
|
|
@ -213,11 +200,8 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return "null";
|
|
|
|
return "null";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return valueStr;
|
|
|
|
return valueStr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int Value::ToInt() const
|
|
|
|
int Value::ToInt() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsNumber())
|
|
|
|
if (IsNumber())
|
|
|
@ -227,11 +211,8 @@ namespace Jzon
|
|
|
|
sstr >> val;
|
|
|
|
sstr >> val;
|
|
|
|
return val;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float Value::ToFloat() const
|
|
|
|
float Value::ToFloat() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsNumber())
|
|
|
|
if (IsNumber())
|
|
|
@ -241,11 +222,8 @@ namespace Jzon
|
|
|
|
sstr >> val;
|
|
|
|
sstr >> val;
|
|
|
|
return val;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0.F;
|
|
|
|
return 0.F;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
double Value::ToDouble() const
|
|
|
|
double Value::ToDouble() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsNumber())
|
|
|
|
if (IsNumber())
|
|
|
@ -255,22 +233,16 @@ namespace Jzon
|
|
|
|
sstr >> val;
|
|
|
|
sstr >> val;
|
|
|
|
return val;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0.0;
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Value::ToBool() const
|
|
|
|
bool Value::ToBool() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IsBool())
|
|
|
|
if (IsBool())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return (valueStr == "true");
|
|
|
|
return (valueStr == "true");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Value::SetNull()
|
|
|
|
void Value::SetNull()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -323,10 +295,7 @@ namespace Jzon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void Value::Set(const bool value)
|
|
|
|
void Value::Set(const bool value)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
valueStr = value ? "true" : "false";
|
|
|
|
valueStr = "true";
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
valueStr = "false";
|
|
|
|
|
|
|
|
type = VT_BOOL;
|
|
|
|
type = VT_BOOL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -395,28 +364,20 @@ namespace Jzon
|
|
|
|
static const char *nullEscaped = "\0\0";
|
|
|
|
static const char *nullEscaped = "\0\0";
|
|
|
|
const char *&getEscaped(const char &c)
|
|
|
|
const char *&getEscaped(const char &c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < numEscapeChars; ++i)
|
|
|
|
for (unsigned int i = 0; i < numEscapeChars; ++i) {
|
|
|
|
{
|
|
|
|
if (c == charsUnescaped[i]) {
|
|
|
|
const char &ue = charsUnescaped[i];
|
|
|
|
return charsEscaped[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (c == ue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const char *&e = charsEscaped[i];
|
|
|
|
|
|
|
|
return e;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullEscaped;
|
|
|
|
return nullEscaped;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const char &getUnescaped(const char &c1, const char &c2)
|
|
|
|
const char &getUnescaped(const char &c1, const char &c2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < numEscapeChars; ++i)
|
|
|
|
for (unsigned int i = 0; i < numEscapeChars; ++i) {
|
|
|
|
{
|
|
|
|
|
|
|
|
const char *&e = charsEscaped[i];
|
|
|
|
const char *&e = charsEscaped[i];
|
|
|
|
|
|
|
|
|
|
|
|
if (c1 == e[0] && c2 == e[1])
|
|
|
|
if (c1 == e[0] && c2 == e[1]) {
|
|
|
|
{
|
|
|
|
return charsUnescaped[i];
|
|
|
|
const char &ue = charsUnescaped[i];
|
|
|
|
|
|
|
|
return ue;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nullUnescaped;
|
|
|
|
return nullUnescaped;
|
|
|
@ -426,16 +387,12 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string escaped;
|
|
|
|
std::string escaped;
|
|
|
|
|
|
|
|
|
|
|
|
for (const auto& c: value)
|
|
|
|
for (auto &&c : value) {
|
|
|
|
{
|
|
|
|
|
|
|
|
const char *&a = getEscaped(c);
|
|
|
|
const char *&a = getEscaped(c);
|
|
|
|
if (a[0] != '\0')
|
|
|
|
if (a[0] != '\0') {
|
|
|
|
{
|
|
|
|
|
|
|
|
escaped += a[0];
|
|
|
|
escaped += a[0];
|
|
|
|
escaped += a[1];
|
|
|
|
escaped += a[1];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
escaped += c;
|
|
|
|
escaped += c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -469,30 +426,22 @@ namespace Jzon
|
|
|
|
return unescaped;
|
|
|
|
return unescaped;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object::Object() : Node()
|
|
|
|
Object::Object() : Node()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object::Object(const Object &other) : Node()
|
|
|
|
Object::Object(const Object &other) : Node()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (auto it = other.children.cbegin(); it != other.children.cend(); ++it)
|
|
|
|
for (auto &&it : other.children) {
|
|
|
|
{
|
|
|
|
const std::string &name = it.first;
|
|
|
|
const std::string &name = (*it).first;
|
|
|
|
Node &value = *it.second;
|
|
|
|
Node &value = *(*it).second;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children.push_back(NamedNodePtr(name, value.GetCopy()));
|
|
|
|
children.push_back(NamedNodePtr(name, value.GetCopy()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object::Object(const Node &other) : Node()
|
|
|
|
Object::Object(const Node &other) : Node()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const Object &object = other.AsObject();
|
|
|
|
for (auto &&child : other.AsObject().children) {
|
|
|
|
|
|
|
|
children.push_back(NamedNodePtr(child.first, child.second->GetCopy()));
|
|
|
|
for (auto it = object.children.cbegin(); it != object.children.cend(); ++it)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const std::string &name = (*it).first;
|
|
|
|
|
|
|
|
Node &value = *(*it).second;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children.push_back(NamedNodePtr(name, value.GetCopy()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object::~Object()
|
|
|
|
Object::~Object()
|
|
|
@ -528,10 +477,9 @@ namespace Jzon
|
|
|
|
|
|
|
|
|
|
|
|
void Object::Clear()
|
|
|
|
void Object::Clear()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (auto it = children.begin(); it != children.end(); ++it)
|
|
|
|
for (auto &&child : children) {
|
|
|
|
{
|
|
|
|
delete child.second;
|
|
|
|
delete (*it).second;
|
|
|
|
child.second = nullptr;
|
|
|
|
(*it).second = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
children.clear();
|
|
|
|
children.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -540,7 +488,6 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Object::iterator(&children.front());
|
|
|
|
return Object::iterator(&children.front());
|
|
|
|
else
|
|
|
|
|
|
|
|
return Object::iterator(NULL);
|
|
|
|
return Object::iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -548,7 +495,6 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Object::const_iterator(&children.front());
|
|
|
|
return Object::const_iterator(&children.front());
|
|
|
|
else
|
|
|
|
|
|
|
|
return Object::const_iterator(NULL);
|
|
|
|
return Object::const_iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -556,27 +502,19 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Object::iterator(&children.back() + 1);
|
|
|
|
return Object::iterator(&children.back() + 1);
|
|
|
|
else
|
|
|
|
|
|
|
|
return Object::iterator(NULL);
|
|
|
|
return Object::iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object::const_iterator Object::end() const
|
|
|
|
Object::const_iterator Object::end() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Object::const_iterator(&children.back() + 1);
|
|
|
|
return Object::const_iterator(&children.back() + 1);
|
|
|
|
else
|
|
|
|
|
|
|
|
return Object::const_iterator(NULL);
|
|
|
|
return Object::const_iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool Object::Has(const std::string &name) const
|
|
|
|
bool Object::Has(const std::string &name) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (ChildList::const_iterator it = children.begin(); it != children.end(); ++it)
|
|
|
|
return std::any_of(children.begin(), children.end(),
|
|
|
|
{
|
|
|
|
[&](const NamedNodePtr &child) { return child.first == name; });
|
|
|
|
if ((*it).first == name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
size_t Object::GetCount() const
|
|
|
|
size_t Object::GetCount() const
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -584,11 +522,9 @@ namespace Jzon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Node &Object::Get(const std::string &name) const
|
|
|
|
Node &Object::Get(const std::string &name) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (ChildList::const_iterator it = children.begin(); it != children.end(); ++it)
|
|
|
|
for (auto &&child : children) {
|
|
|
|
{
|
|
|
|
if (child.first == name) {
|
|
|
|
if ((*it).first == name)
|
|
|
|
return *child.second;
|
|
|
|
{
|
|
|
|
|
|
|
|
return *(*it).second;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -600,17 +536,14 @@ namespace Jzon
|
|
|
|
return new Object(*this);
|
|
|
|
return new Object(*this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Array::Array() : Node()
|
|
|
|
Array::Array() : Node()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Array::Array(const Array &other) : Node()
|
|
|
|
Array::Array(const Array &other) : Node()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (auto it = other.children.cbegin(); it != other.children.cend(); ++it)
|
|
|
|
for (auto &&value : other.children) {
|
|
|
|
{
|
|
|
|
children.push_back(value->GetCopy());
|
|
|
|
const Node &value = *(*it);
|
|
|
|
|
|
|
|
children.push_back(value.GetCopy());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -618,10 +551,8 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const Array &array = other.AsArray();
|
|
|
|
const Array &array = other.AsArray();
|
|
|
|
|
|
|
|
|
|
|
|
for (auto it = array.children.cbegin(); it != array.children.cend(); ++it)
|
|
|
|
for (auto &&value : array.children) {
|
|
|
|
{
|
|
|
|
children.push_back(value->GetCopy());
|
|
|
|
const Node &value = *(*it);
|
|
|
|
|
|
|
|
children.push_back(value.GetCopy());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -645,8 +576,7 @@ namespace Jzon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void Array::Remove(size_t index)
|
|
|
|
void Array::Remove(size_t index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (index < children.size())
|
|
|
|
if (index < children.size()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
ChildList::iterator it = children.begin() + index;
|
|
|
|
ChildList::iterator it = children.begin() + index;
|
|
|
|
delete (*it);
|
|
|
|
delete (*it);
|
|
|
|
children.erase(it);
|
|
|
|
children.erase(it);
|
|
|
@ -654,10 +584,9 @@ namespace Jzon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void Array::Clear()
|
|
|
|
void Array::Clear()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (ChildList::iterator it = children.begin(); it != children.end(); ++it)
|
|
|
|
for (auto &&child : children) {
|
|
|
|
{
|
|
|
|
delete child;
|
|
|
|
delete (*it);
|
|
|
|
child = nullptr;
|
|
|
|
(*it) = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
children.clear();
|
|
|
|
children.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -666,28 +595,24 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Array::iterator(&children.front());
|
|
|
|
return Array::iterator(&children.front());
|
|
|
|
else
|
|
|
|
|
|
|
|
return Array::iterator(NULL);
|
|
|
|
return Array::iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Array::const_iterator Array::begin() const
|
|
|
|
Array::const_iterator Array::begin() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Array::const_iterator(&children.front());
|
|
|
|
return Array::const_iterator(&children.front());
|
|
|
|
else
|
|
|
|
|
|
|
|
return Array::const_iterator(NULL);
|
|
|
|
return Array::const_iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Array::iterator Array::end()
|
|
|
|
Array::iterator Array::end()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Array::iterator(&children.back() + 1);
|
|
|
|
return Array::iterator(&children.back() + 1);
|
|
|
|
else
|
|
|
|
|
|
|
|
return Array::iterator(NULL);
|
|
|
|
return Array::iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Array::const_iterator Array::end() const
|
|
|
|
Array::const_iterator Array::end() const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!children.empty())
|
|
|
|
if (!children.empty())
|
|
|
|
return Array::const_iterator(&children.back() + 1);
|
|
|
|
return Array::const_iterator(&children.back() + 1);
|
|
|
|
else
|
|
|
|
|
|
|
|
return Array::const_iterator(NULL);
|
|
|
|
return Array::const_iterator(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -697,8 +622,7 @@ namespace Jzon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Node &Array::Get(size_t index) const
|
|
|
|
Node &Array::Get(size_t index) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (index < children.size())
|
|
|
|
if (index < children.size()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return *children.at(index);
|
|
|
|
return *children.at(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -710,7 +634,6 @@ namespace Jzon
|
|
|
|
return new Array(*this);
|
|
|
|
return new Array(*this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileWriter::FileWriter(const std::string &filename) : filename(filename)
|
|
|
|
FileWriter::FileWriter(const std::string &filename) : filename(filename)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -759,11 +682,8 @@ namespace Jzon
|
|
|
|
error = parser.GetError();
|
|
|
|
error = parser.GetError();
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Node::Type FileReader::DetermineType()
|
|
|
|
Node::Type FileReader::DetermineType()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1193,11 +1113,8 @@ namespace Jzon
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return json.at(cursor+1);
|
|
|
|
return json.at(cursor+1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return '\0';
|
|
|
|
return '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parser::jumpToNext(char c)
|
|
|
|
void Parser::jumpToNext(char c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
++cursor;
|
|
|
|
++cursor;
|
|
|
@ -1265,26 +1182,12 @@ namespace Jzon
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool number = true;
|
|
|
|
bool number = std::all_of(value.begin(), value.end(), IsNumber);
|
|
|
|
for (std::string::const_iterator it = value.begin(); it != value.end(); ++it)
|
|
|
|
if (!number) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!IsNumber(*it))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
number = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (number)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data.push(std::make_pair(Value::VT_NUMBER, value));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data.push(std::make_pair(Value::VT_NUMBER, value));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace Jzon
|
|
|
|
} // namespace Jzon
|
|
|
|