SourcePro® API Reference Guide

Product Documentation:
   SourcePro
Documentation Home
List of all members | Public Member Functions | Related Functions
RWvistreamIterator< T > Class Template Reference

Input iterator that reads successive elements from the input stream for which it was constructed. More...

#include <rw/vstream.h>

Public Member Functions

 RWvistreamIterator ()
 
 RWvistreamIterator (RWvistream &s)
 
const T & operator* () const
 
RWvistreamIteratoroperator++ ()
 
RWvistreamIterator operator++ (int)
 
const T * operator-> () const
 

Related Functions

(Note that these are not member functions.)

bool operator!= (const RWvistreamIterator< T > &lhs, const RWvistreamIterator< T > &rhs)
 
bool operator== (const RWvistreamIterator< T > &lhs, const RWvistreamIterator< T > &rhs)
 

Detailed Description

template<typename T>
class RWvistreamIterator< T >

Class RWvistreamIterator is an input iterator that reads (using operator>>) successive elements from the input stream for which it was constructed. After it is constructed, and every time operator++() or operator++(int) is used, the iterator reads and stores a value of T.

The constructor with no arguments always constructs and end-of-stream input iterator object, which is the only legitimate iterator to be used for the end condition. The result of operator*() on an end-of-stream iterator is undefined. For any other iterator value, a const T& is returned. The result of operator->() on an end-of stream iterator is not defined. For any other iterator value, a const T* is returned. The behavior of a program that applies operator++() to an end-of-stream iterator is undefined. It is impossible to store things into RWvistream iterators.

Constructor & Destructor Documentation

template<typename T >
RWvistreamIterator< T >::RWvistreamIterator ( )
inline

Constructs an end-of-stream iterator.

template<typename T >
RWvistreamIterator< T >::RWvistreamIterator ( RWvistream s)
inline

Constructs an iterator that will use s as the source for all extraction operations. Extracts a single value of type T from the stream s. If the extraction fails, this iterator becomes an end-of-stream iterator, otherwise this iterator becomes a non-end-of-stream iterator.

Member Function Documentation

template<typename T >
const T& RWvistreamIterator< T >::operator* ( void  ) const
inline

Returns a reference to the last value read from the underlying stream.

template<typename T >
RWvistreamIterator& RWvistreamIterator< T >::operator++ ( )
inline

Extracts an item from the underlying stream and returns a reference to self. If the extraction operation fails, this iterator becomes an end-of-stream iterator.

template<typename T >
RWvistreamIterator RWvistreamIterator< T >::operator++ ( int  )
inline

Makes a copy of self, extracts an item from the underlying stream and, returns the copy that was made before the extraction. If the extract operation fails, this iterator becomes an end-of-stream iterator.

template<typename T >
const T* RWvistreamIterator< T >::operator-> ( void  ) const
inline

Returns a pointer to the last value read from the underlying stream.

Friends And Related Function Documentation

template<typename T >
bool operator!= ( const RWvistreamIterator< T > &  lhs,
const RWvistreamIterator< T > &  rhs 
)
friend

Returns true if lhs is not equal to rhs, otherwise false.

Two end-of-stream iterators are always equal. An end-of-stream iterator is not equal to a non-end-of-stream iterator. Two non-end-of-stream iterators are equal when they are associated with the same stream.

template<typename T >
bool operator== ( const RWvistreamIterator< T > &  lhs,
const RWvistreamIterator< T > &  rhs 
)
friend

Returns true if lhs is equal to rhs, otherwise false.

Two end-of-stream iterators are always equal. An end-of-stream iterator is not equal to a non-end-of-stream iterator. Two non-end-of-stream iterators are equal when they are associated with the same stream.

Copyright © 2021 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.