C++ API Reference
|
Class handling iteration over Stream members. More...
#include <adskDataStreamIterator.h>
Public Member Functions | |
StreamIterator () | |
Default constructor. More... | |
~StreamIterator () | |
Destructor, does nothing. | |
StreamIterator (const StreamIterator &) | |
Copy constructor. More... | |
StreamIterator & | operator= (const StreamIterator &) |
Assignment operator. More... | |
bool | operator!= (const StreamIterator &) const |
Check to see if this iterator is not equal to the given one. More... | |
bool | operator== (const StreamIterator &) const |
Check to see if this iterator is equal to the given one. More... | |
Handle & | operator* () |
Get a reference to the data at the current location of the iterator. More... | |
const Handle & | operator* () const |
Get a reference to the data at the current location of the iterator (const version) More... | |
Handle * | operator-> () |
Get the data at the current location of the iterator. More... | |
const Handle * | operator-> () const |
Get the data at the current location of the iterator (const version) More... | |
StreamIterator & | operator++ () |
Pre-increment operator. More... | |
StreamIterator | operator++ (int) |
Post-increment operator. More... | |
bool | valid () const |
Determine if the iterator is currently pointing to a valid Member. More... | |
Index | index () const |
Get the Index for the current iteration position. More... | |
Protected Member Functions | |
StreamIteratorImpl const & | impl () const |
Get the implementation class in const form. More... | |
StreamIteratorImpl & | impl () |
Get the implementation class. More... | |
StreamIterator (StreamIteratorImpl *) | |
Usual constructor, uses an implementation-specific iterator as the actual implementaton of this iterator. More... | |
Friends | |
class | Stream |
Real implementation of the iterator. | |
Class handling iteration over Stream members.
The Stream data is not necessarily stored sequentially or as a packed array so this iterator is necessary in order to provide a consistent way to access all Stream elements.
By default the Handle pointed to by the iterator will be positioned at the first Structure member. If you wish a different member you should reposition it after retrieval. (It's recommended for efficiency that you position by Member index rather than by name since that works faster.)
For technical reasons this class lives outside the Stream though really it is part of it. A typedef is set up inside the Stream so that you can use it like a standard iterator:
for( Stream::iterator iterator = myStream.begin(); iterator != myStream.end(); ++iterator ) { processMember( *iterator ); }
If you are processing multiple independent values in your Structure it's most efficient to run multiple loops repositioning the Handle between each loop:
Stream::iterator idIterator = myStream.begin(); colorIterator->setPositionByMemberName( "ID" ); for( ; iterator != myStream.end(); ++iterator ) { processIDMember( iterator->asInt32() ); } Stream::iterator colorIterator = myStream.begin(); colorIterator->setPositionByMemberName( "Color" ); for( ; iterator != myStream.end(); ++iterator ) { processColorMember( iterator->asFloat() ); }
If the values are not independent and are needed at the same time you can still access both values within the same loop by repositioning the Handle each time through the loop:
for( Stream::iterator iterator = myStream.begin(); iterator != myStream.end(); ++iterator ) { iterator->setPositionByMemberIndex( 0 ); int* idValue = iterator->asInt32(); iterator->setPositionByMemberIndex( 1 ); float* colorValues = iterator->asFloat(); processData( idValue, colorValues ); }
StreamIterator | ( | ) |
Default constructor.
Should only be used as a temporary object before an assignment operator.
Any access operations called on an iterator with no implementaiton will throw an exception.
StreamIterator | ( | const StreamIterator & | rhs | ) |
Copy constructor.
[in] | rhs | Iterator to copy |
|
protected |
Usual constructor, uses an implementation-specific iterator as the actual implementaton of this iterator.
Calls are all forwarded.
[in] | myImpl | Implementation of the iterator |
StreamIterator & operator= | ( | const StreamIterator & | rhs | ) |
Assignment operator.
Copy the members, as pointers.
This copy means that any two iterators constructed or copied from one another will actually point to the same spot in the iteration
[in] | rhs | Iterator to copy |
bool operator!= | ( | const StreamIterator & | rhs | ) | const |
Check to see if this iterator is not equal to the given one.
[in] | rhs | Iterator to compare against |
bool operator== | ( | const StreamIterator & | rhs | ) | const |
Check to see if this iterator is equal to the given one.
[in] | rhs | Iterator to compare against |
Handle & operator* | ( | ) |
Get a reference to the data at the current location of the iterator.
std::out_of_range | iterator is past the end. |
std::runtime_error | Thrown when no implementation is present |
const Handle & operator* | ( | ) | const |
Get a reference to the data at the current location of the iterator (const version)
The value returned is the Stream element Index. The Handle containing the actual value is always accessible through the handle() method.
std::out_of_range | iterator is past the end. |
std::runtime_error | Thrown when no implementation is present |
Handle * operator-> | ( | ) |
Get the data at the current location of the iterator.
std::out_of_range | iterator is past the end. |
std::runtime_error | Thrown when no implementation is present |
const Handle * operator-> | ( | ) | const |
Get the data at the current location of the iterator (const version)
std::out_of_range | iterator is past the end. |
std::runtime_error | Thrown when no implementation is present |
StreamIterator & operator++ | ( | ) |
Pre-increment operator.
StreamIterator operator++ | ( | int | value | ) |
Post-increment operator.
Makes a copy - use pre-increment where possible
[in] | value | Ignored |
bool valid | ( | ) | const |
Determine if the iterator is currently pointing to a valid Member.
Index index | ( | ) | const |
|
protected |
Get the implementation class in const form.
std::runtime_error | Thrown when no implementation is present |
|
protected |
Get the implementation class.
std::runtime_error | Thrown when no implementation is present |