Corrade::Utility::JsonIterator class new in Git master

JSON iterator.

Iterator for JsonView, which is returned from Json::tokens() and JsonToken::children(), and additionally directly returned from JsonToken::firstChild(), JsonToken::parent(), JsonToken::find(), JsonObjectView::find() and JsonArrayView::find(), where it indicates a potentially invalid value.

Compared to JsonObjectIterator and JsonArrayIterator iterates all tokens in a depth-first manner instead of just the immediate children, and can go both ways, not just forward. See Tokenization and parsing process for more information about the internal representation.

Constructors, destructors, conversion operators

JsonIterator()
Default constructor.
JsonIterator(JsonToken token) noexcept
Construct from a token.
operator bool() const explicit
Whether the iterator is valid.

Public functions

auto operator==(const JsonIterator& other) const -> bool
Equality comparison.
auto operator!=(const JsonIterator& other) const -> bool
Non-equality comparison.
auto operator--() -> JsonIterator&
Advance to previous position.
auto operator++() -> JsonIterator&
Advance to next position.
auto operator*() const -> JsonToken
Dereference.
auto operator->() const -> const JsonToken*
Dereference.

Function documentation

Corrade::Utility::JsonIterator::JsonIterator()

Default constructor.

Creates an invalid iterator, i.e. one with operator bool() returning false.

Corrade::Utility::JsonIterator::operator bool() const explicit

Whether the iterator is valid.

Returns false if the iterator is default-constructed, returned from JsonToken::firstChild() of a token that has no children, from JsonToken::parent() of a token that has no parent, from JsonToken::find(), JsonObjectView::find() or JsonArrayView::find() if given key or index wasn't found, or if it was advanced outside of the bounds of the token stream, true otherwise.

JsonIterator& Corrade::Utility::JsonIterator::operator--()

Advance to previous position.

The iterator is expected to be valid and not at the begin of the token stream. Note that compared to JsonObjectIterator and JsonArrayIterator it advances in a depth-first manner instead of just the immediate children.

JsonIterator& Corrade::Utility::JsonIterator::operator++()

Advance to next position.

The iterator is expected to be valid. Note that compared to JsonObjectIterator and JsonArrayIterator it advances in a depth-first manner instead of just the immediate children.

JsonToken Corrade::Utility::JsonIterator::operator*() const

Dereference.

The iterator is expected to be valid.

const JsonToken* Corrade::Utility::JsonIterator::operator->() const

Dereference.

The iterator is expected to be valid.