|
|
@@ -58,10 +58,9 @@ class JSONElement
|
|
|
{
|
|
|
public:
|
|
|
|
|
|
- /// Used only to forward-instantiate elements.
|
|
|
- /// In order to be able to use the element, it must be
|
|
|
- /// obtained from JSONParser::root() or copied from an
|
|
|
- /// already existent and valid element.
|
|
|
+ /// Construct the nil JSONElement.
|
|
|
+ /// Used to forward-instantiate elements or as a special
|
|
|
+ /// nil element.
|
|
|
JSONElement();
|
|
|
JSONElement(const JSONElement& other);
|
|
|
|
|
|
@@ -70,9 +69,13 @@ public:
|
|
|
/// Returns the @a i -th item of the current array.
|
|
|
JSONElement& operator[](uint32_t i);
|
|
|
|
|
|
- /// @copydoc JSONParser::operator[]
|
|
|
+ /// @copydoc JSONElement::operator[]
|
|
|
JSONElement& index(uint32_t i);
|
|
|
|
|
|
+ /// Returns the @a i -th item of the current array or
|
|
|
+ /// the special nil JSONElement() if the index does not exist.
|
|
|
+ JSONElement index_or_nil(uint32_t i);
|
|
|
+
|
|
|
/// Returns the element corresponding to key @a k of the
|
|
|
/// current object.
|
|
|
/// @note
|
|
|
@@ -80,6 +83,10 @@ public:
|
|
|
/// key in order of appearance will be selected.
|
|
|
JSONElement& key(const char* k);
|
|
|
|
|
|
+ /// Returns the element corresponding to key @a k of the current
|
|
|
+ /// object, or the special nil JSONElement() if the key does not exist.
|
|
|
+ JSONElement key_or_nil(const char* k);
|
|
|
+
|
|
|
/// Returns whether the element has the @a k key.
|
|
|
bool has_key(const char* k) const;
|
|
|
|