- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Friends

# StreamIterator Class Reference

This reference page is linked to from the following overview topics: Meta Data.

Search for all occurrences

## Detailed Description

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 ); }

`#include <adskDataStreamIterator.h>`

List of all members.

## Public Member Functions
| StreamIterator ()
| Default constructor.
| ~StreamIterator ()
| Destructor, does nothing.
| StreamIterator (const StreamIterator &)
| Copy constructor.
StreamIterator & | operator= (const StreamIterator &)
| Assignment operator.
bool | operator!= (const StreamIterator &) const
| Check to see if this iterator is not equal to the given one.
bool | operator== (const StreamIterator &) const
| Check to see if this iterator is equal to the given one.
Handle & | operator* ()
| Get a reference to the data at the current location of the iterator.
const Handle & | operator* () const
| Get a reference to the data at the current location of the iterator (const version)
Handle * | operator-> ()
| Get the data at the current location of the iterator.
const Handle * | operator-> () const
| Get the data at the current location of the iterator (const version)
StreamIterator & | operator++ ()
| Pre-increment operator.
StreamIterator | operator++ (int)
| Post-increment operator.
bool | valid () const
| Determine if the iterator is currently pointing to a valid Member.
Index | index () const
| Get the Index for the current iteration position.
## Protected Member Functions
StreamIteratorImpl const & | impl () const
| Get the implementation class in const form.
StreamIteratorImpl & | impl ()
| Get the implementation class.
| StreamIterator (StreamIteratorImpl *)
| Usual constructor, uses an implementation-specific iterator as the actual implementaton of this iterator.
## Friends
class | Stream
| Real implementation of the iterator. Search for all occurrences

## Constructor & Destructor Documentation

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.

Parameters:

  [in] | rhs | Iterator to copy

StreamIterator | ( | StreamIteratorImpl * | myImpl | ) | `[protected]`

Usual constructor, uses an implementation-specific iterator as the actual implementaton of this iterator.

Calls are all forwarded.

Parameters:

  [in] | myImpl | Implementation of the iterator

## Member Function Documentation

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

Parameters:

  [in] | rhs | Iterator to copy

bool operator!= | ( | const StreamIterator & | rhs | ) | const

Check to see if this iterator is not equal to the given one.

Parameters:

  [in] | rhs | Iterator to compare against

Returns:
  True if the two iterators are not the same

bool operator== | ( | const StreamIterator & | rhs | ) | const

Check to see if this iterator is equal to the given one.

Parameters:

  [in] | rhs | Iterator to compare against

Returns:
  True if the two iterators are equivalent

Handle & operator* | ( |  | ) |

Get a reference to the data at the current location of the iterator.

Exceptions:

  std::out_of_range | iterator is past the end.
  std::runtime_error | Thrown when no implementation is present

Returns:
  Reference to the current element Handle, throws if iteration is done

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.

Exceptions:

  std::out_of_range | iterator is past the end.
  std::runtime_error | Thrown when no implementation is present

Returns:
  Reference to the current element Handle, throws if iteration is done

Handle * operator-> | ( |  | ) |

Get the data at the current location of the iterator.

Exceptions:

  std::out_of_range | iterator is past the end.
  std::runtime_error | Thrown when no implementation is present

Returns:
  Pointer to the current element Handle, throws if iteration is done

const Handle * operator-> | ( |  | ) | const

Get the data at the current location of the iterator (const version)

Exceptions:

  std::out_of_range | iterator is past the end.
  std::runtime_error | Thrown when no implementation is present

Returns:
  Pointer to the current element Handle, throws if iteration is done

StreamIterator & operator++ | ( |  | ) |

Pre-increment operator.

Returns:
  Reference to this iterator, to allow use as a lhs

StreamIterator operator++ | ( | int | value | ) |

Post-increment operator.

Makes a copy - use pre-increment where possible

Parameters:

  [in] | value | Ignored

Returns:
  Copy of the iterator before the advance

bool valid | ( |  | ) | const

Search for all occurrences

Determine if the iterator is currently pointing to a valid Member.

Returns:
  True if the iterator position is legal (i.e. not done)

Index index | ( |  | ) | const

Search for all occurrences

Get the Index for the current iteration position.

Exceptions:

  std::runtime_error | Thrown when no implementation is present

Returns:
  Index where this Stream Iterator is pointed

StreamIteratorImpl const & impl | ( |  | ) | const`[protected]`

Search for all occurrences

Get the implementation class in const form.

Exceptions:

  std::runtime_error | Thrown when no implementation is present

Returns:
  Const reference to this class's implementation object

StreamIteratorImpl & impl | ( |  | ) | `[protected]`

Search for all occurrences

Get the implementation class.

Exceptions:

  std::runtime_error | Thrown when no implementation is present

Returns:
  Reference to this class's implementation object

StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator
StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator StreamIterator