style
This commit is contained in:
parent
2592cd0442
commit
1877767614
@ -203,7 +203,7 @@ json::tree::parse (const char *first, const char *last)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Type conversion
|
// Type conversion
|
||||||
|
|
||||||
const json::tree::object&
|
const json::tree::object&
|
||||||
@ -338,12 +338,13 @@ json::tree::node::operator[] (const std::string &key) const
|
|||||||
{ return as_object ()[key]; }
|
{ return as_object ()[key]; }
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
const json::tree::node&
|
const json::tree::node&
|
||||||
json::tree::node::operator[] (unsigned int idx) const
|
json::tree::node::operator[] (unsigned int idx) const
|
||||||
{ return as_array()[idx]; }
|
{ return as_array()[idx]; }
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Object
|
// Object
|
||||||
|
|
||||||
json::tree::object::~object ()
|
json::tree::object::~object ()
|
||||||
@ -365,7 +366,8 @@ json::tree::object::clone (void) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
json::tree::object::operator ==(const json::tree::object &rhs) const {
|
json::tree::object::operator ==(const json::tree::object &rhs) const
|
||||||
|
{
|
||||||
for (auto i = rhs.m_values.begin (), j = m_values.begin ();
|
for (auto i = rhs.m_values.begin (), j = m_values.begin ();
|
||||||
i != rhs.m_values.end () && j != m_values.end ();
|
i != rhs.m_values.end () && j != m_values.end ();
|
||||||
++i, ++j)
|
++i, ++j)
|
||||||
@ -380,9 +382,13 @@ json::tree::object::operator ==(const json::tree::object &rhs) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
json::tree::object::insert (const std::string &_key, unique_ptr<json::tree::node> &&value)
|
json::tree::object::insert (const std::string &_key, unique_ptr<json::tree::node> &&value)
|
||||||
{ m_values[_key] = move(value); }
|
{
|
||||||
|
m_values[_key] = move(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
json::tree::node&
|
json::tree::node&
|
||||||
@ -408,8 +414,10 @@ json::tree::object::operator[](const std::string &key) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
json::tree::object::has (const std::string &key) const {
|
json::tree::object::has (const std::string &key) const
|
||||||
|
{
|
||||||
return m_values.find (key) != m_values.end ();
|
return m_values.find (key) != m_values.end ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,18 +437,21 @@ json::tree::object::erase (const std::string &key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
json::tree::object::const_iterator
|
json::tree::object::const_iterator
|
||||||
json::tree::object::begin (void) const
|
json::tree::object::begin (void) const
|
||||||
{ return m_values.begin (); }
|
{ return m_values.begin (); }
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
json::tree::object::const_iterator
|
json::tree::object::const_iterator
|
||||||
json::tree::object::end (void) const
|
json::tree::object::end (void) const
|
||||||
{ return m_values.end (); }
|
{ return m_values.end (); }
|
||||||
|
|
||||||
|
|
||||||
std::ostream&
|
std::ostream&
|
||||||
json::tree::object::write (std::ostream &os) const {
|
json::tree::object::write (std::ostream &os) const
|
||||||
|
{
|
||||||
os << "{\n";
|
os << "{\n";
|
||||||
{
|
{
|
||||||
indenter raii(os);
|
indenter raii(os);
|
||||||
@ -458,7 +469,7 @@ json::tree::object::write (std::ostream &os) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Array
|
// Array
|
||||||
|
|
||||||
json::tree::array::~array()
|
json::tree::array::~array()
|
||||||
@ -488,8 +499,10 @@ json::tree::array::insert (unique_ptr<json::tree::node> &&_value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
json::tree::array::operator ==(const json::tree::array &rhs) const {
|
json::tree::array::operator==(const json::tree::array &rhs) const
|
||||||
|
{
|
||||||
for (auto i = rhs.m_values.begin (), j = m_values.begin ();
|
for (auto i = rhs.m_values.begin (), j = m_values.begin ();
|
||||||
i != rhs.m_values.end () && j != m_values.end ();
|
i != rhs.m_values.end () && j != m_values.end ();
|
||||||
++i, ++j)
|
++i, ++j)
|
||||||
@ -534,7 +547,7 @@ json::tree::array::write (std::ostream &os) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// String
|
// String
|
||||||
|
|
||||||
std::unique_ptr<json::tree::node>
|
std::unique_ptr<json::tree::node>
|
||||||
@ -546,23 +559,26 @@ json::tree::string::clone (void) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
std::ostream&
|
std::ostream&
|
||||||
json::tree::string::write (std::ostream &os) const {
|
json::tree::string::write (std::ostream &os) const
|
||||||
|
{
|
||||||
os << '"' << m_value << '"';
|
os << '"' << m_value << '"';
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
json::tree::string::operator ==(const json::tree::string &rhs) const
|
json::tree::string::operator== (const json::tree::string &rhs) const
|
||||||
{ return rhs.m_value == m_value; }
|
{ return rhs.m_value == m_value; }
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
json::tree::string::operator ==(const char *rhs) const
|
json::tree::string::operator== (const char *rhs) const
|
||||||
{ return rhs == m_value; }
|
{ return rhs == m_value; }
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Number
|
// Number
|
||||||
|
|
||||||
std::unique_ptr<json::tree::node>
|
std::unique_ptr<json::tree::node>
|
||||||
@ -574,18 +590,20 @@ json::tree::number::clone (void) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
std::ostream&
|
std::ostream&
|
||||||
json::tree::number::write (std::ostream &os) const {
|
json::tree::number::write (std::ostream &os) const
|
||||||
|
{
|
||||||
os << setprecision (numeric_limits<double>::digits10) << m_value;
|
os << setprecision (numeric_limits<double>::digits10) << m_value;
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
json::tree::number::operator ==(const json::tree::number &rhs) const
|
json::tree::number::operator ==(const json::tree::number &rhs) const
|
||||||
{ return almost_equal (rhs.m_value, m_value); }
|
{ return almost_equal (rhs.m_value, m_value); }
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Boolean
|
// Boolean
|
||||||
|
|
||||||
std::unique_ptr<json::tree::node>
|
std::unique_ptr<json::tree::node>
|
||||||
@ -597,17 +615,20 @@ json::tree::boolean::clone (void) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
std::ostream&
|
std::ostream&
|
||||||
json::tree::boolean::write (std::ostream &os) const {
|
json::tree::boolean::write (std::ostream &os) const
|
||||||
|
{
|
||||||
os << (m_value ? "true" : "false");
|
os << (m_value ? "true" : "false");
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
bool
|
bool
|
||||||
json::tree::boolean::operator ==(const json::tree::boolean &rhs) const
|
json::tree::boolean::operator ==(const json::tree::boolean &rhs) const
|
||||||
{ return rhs.m_value == m_value; }
|
{ return rhs.m_value == m_value; }
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Null
|
// Null
|
||||||
|
|
||||||
std::unique_ptr<json::tree::node>
|
std::unique_ptr<json::tree::node>
|
||||||
@ -619,11 +640,14 @@ json::tree::null::clone (void) const
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
std::ostream&
|
std::ostream&
|
||||||
json::tree::null::write (std::ostream &os) const {
|
json::tree::null::write (std::ostream &os) const
|
||||||
|
{
|
||||||
os << "null";
|
os << "null";
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
ostream&
|
ostream&
|
||||||
json::tree::operator <<(ostream &os, const json::tree::node &n)
|
json::tree::operator <<(ostream &os, const json::tree::node &n)
|
||||||
{ return n.write (os); }
|
{ return n.write (os); }
|
||||||
|
@ -131,8 +131,8 @@ namespace json { namespace tree {
|
|||||||
|
|
||||||
virtual void insert (const std::string &key, std::unique_ptr<node>&& value);
|
virtual void insert (const std::string &key, std::unique_ptr<node>&& value);
|
||||||
virtual const node& operator[](const std::string &key) const;
|
virtual const node& operator[](const std::string &key) const;
|
||||||
virtual bool has (const std::string&) const;
|
|
||||||
virtual node& operator[](const std::string &key);
|
virtual node& operator[](const std::string &key);
|
||||||
|
virtual bool has (const std::string&) const;
|
||||||
|
|
||||||
virtual void clear (void);
|
virtual void clear (void);
|
||||||
virtual void erase (const std::string &key);
|
virtual void erase (const std::string &key);
|
||||||
|
Loading…
Reference in New Issue
Block a user