14.2Class BSONIter

Iterator for BSON objects

Class BSONIter( bson )
bson A BSON object

Example:


        iter = BSONIter( bson )
        while iter.next()
            doSomething( iter.key(), iter.value() )
        end

The iterator copies data from given BSON object, and is completely independant and cannot be changed or updated. (This is of course suboptimal and could be optimized later.)

Methods
findReturn true when (and set iterator position where) name is found in the BSON.
keyGet the current BSON key string
nextReturn true if there is more data to iterate over
resetReset to start of iterator.
valueGet the current BSON value

Methods

find

Return true when (and set iterator position where) name is found in the BSON.

BSONIter.find( name )
name Key name
ReturnTrue if the key can be found, false otherwise.

If false is returned, iterator is at end (and you may have to reset it). This method does a reset before searching.

key

Get the current BSON key string

BSONIter.key()
ReturnThe current key.

next

Return true if there is more data to iterate over

BSONIter.next()
ReturnTrue if the iterator could advance, false if it was the last element.

reset

Reset to start of iterator.

BSONIter.reset()

value

Get the current BSON value

BSONIter.value()
ReturnThe current value.
Made with http://www.falconpl.org