libfossil
fsl::FslListIterator< VT > Class Template Reference

A utility class for iterating over fsl_list instances. More...

#include "fossil.hpp"

Public Types

typedef VT value_type
 STL-compatible value_type typedef. More...
 
typedef VT ValueType
 API-conventional ValueType. More...
 

Public Member Functions

 FslListIterator (fsl_list const &list)
 Initializes this iterator to point to the first item im list (if list.used>0) or to be equivalent to the end iterator (if the list is empty). More...
 
 FslListIterator ()
 Initializes an end iterator. More...
 
bool operator!= (FslListIterator const &rhs) const throw ()
 
ValueType operator* ()
 Returns the current element's value (possibly NULL!). More...
 
FslListIteratoroperator++ ()
 Increments the iterator to point at the next list entry. More...
 
bool operator== (FslListIterator const &rhs) const throw ()
 

Protected Member Functions

VT currentValue () const throw ()
 

Detailed Description

template<typename VT>
class fsl::FslListIterator< VT >

A utility class for iterating over fsl_list instances.

VT must be a pointer-qualified type because fsl_list only holds arrays of pointers.

Modification of the list invalidates any active iterators (semantically, but not technically, so be careful!).

Example usage:

typedef FslListIterator<char const *> Iter;
// assume d is a fsl_deck instance.
Iter it(d.P);
Iter end;
for( ; it != end; ++it ){
char const * str = *it;
if(str){...}
}

Note that this is not type-safe per se - it relies on the underlying list having only entries of the given type or NULL.

When used in conjunction with the various fsl_list members of fsl_deck, it is important to remember that traversing over fsl_deck::F.list will often, but not always, behave much differently then FCardIterator because this class traverses only the F-cards found directly in that deck, which for delta manifests is only a small fraction of the F-cards actually in that version (the rest are inherited from its baseline manifest). FCardIterator is generally the right way to traverse the F-cards (though this approach has its uses as well).

Definition at line 1436 of file fossil.hpp.

Member Typedef Documentation

template<typename VT>
typedef VT fsl::FslListIterator< VT >::value_type

STL-compatible value_type typedef.

Definition at line 1447 of file fossil.hpp.

template<typename VT>
typedef VT fsl::FslListIterator< VT >::ValueType

API-conventional ValueType.

Definition at line 1449 of file fossil.hpp.

Constructor & Destructor Documentation

template<typename VT>
fsl::FslListIterator< VT >::FslListIterator ( fsl_list const &  list)
inlineexplicit

Initializes this iterator to point to the first item im list (if list.used>0) or to be equivalent to the end iterator (if the list is empty).

Changes to the list semantically invalidate all iterators, and using them afterwars invokes undefined behaviour.

Definition at line 1459 of file fossil.hpp.

template<typename VT>
fsl::FslListIterator< VT >::FslListIterator ( )
inline

Initializes an end iterator.

Definition at line 1470 of file fossil.hpp.

Member Function Documentation

template<typename VT>
VT fsl::FslListIterator< VT >::currentValue ( ) const
throw (
)
inlineprotected

Definition at line 1442 of file fossil.hpp.

template<typename VT>
bool fsl::FslListIterator< VT >::operator!= ( FslListIterator< VT > const &  rhs) const
throw (
)
inline

Definition at line 1508 of file fossil.hpp.

template<typename VT>
ValueType fsl::FslListIterator< VT >::operator* ( )
inline

Returns the current element's value (possibly NULL!).

Throws for an end iterator.

Definition at line 1496 of file fossil.hpp.

template<typename VT>
FslListIterator& fsl::FslListIterator< VT >::operator++ ( )
inline

Increments the iterator to point at the next list entry.

Throws if called on an end iterator or if called after the end of the list has been reached.

Definition at line 1479 of file fossil.hpp.

template<typename VT>
bool fsl::FslListIterator< VT >::operator== ( FslListIterator< VT > const &  rhs) const
throw (
)
inline

Definition at line 1504 of file fossil.hpp.


The documentation for this class was generated from the following file: