proj home

Files   Classes   Functions   Hierarchy  

printcontainer< Iter > Class Template Reference

General printing with iterators. More...

#include <print.h>

Collaboration diagram for printcontainer< Iter >:

List of all members.

Public Member Functions

 printcontainer (Iter ibeg_, Iter iend_, stringc &space_=" ")
 Pass in the container with its iterators.
ostreamprint (ostream &os) const
 The vector prints each sequential element and a space.

Public Attributes

Iter ibeg
 The start iterator.
Iter iend
 The end iterator.
string space
 The client can configure the space between elements.


Detailed Description

template<typename Iter>
class printcontainer< Iter >

General printing with iterators.

Global functions forward the printing to this class as they are the interface and this is the back end.

Example
#include <print.h>
...
  vector<double> v; ...
  cout << print(v,"\n") << endl;
Example
#include <print.h>
...
  double a1[] = { 2.0, 4.0, 6.0, 8.0, 10.0 };
  cout << print(a1,a1+5) << endl;

Definition at line 33 of file print.h.


Constructor & Destructor Documentation

template<typename Iter>
printcontainer< Iter >::printcontainer ( Iter  ibeg_,
Iter  iend_,
stringc space_ = " " 
) [inline]

Pass in the container with its iterators.

Definition at line 47 of file print.h.

Referenced by print().

00052     : ibeg(ibeg_), iend(iend_), space(space_) {}


Member Function Documentation

template<typename Iter >
ostream & printcontainer< Iter >::print ( ostream os  )  const [inline]

The vector prints each sequential element and a space.

Definition at line 92 of file print.h.

References printcontainer< Iter >::iend, and printcontainer< Iter >::space.

00093 {
00094   Iter i=ibeg;
00095   if (i!=iend)
00096     os << *i++;
00097   for ( ; i!=iend; )
00098     os << space << *i++;
00099 
00100   return os;
00101 }


Member Data Documentation

template<typename Iter>
Iter printcontainer< Iter >::ibeg

The start iterator.

Definition at line 38 of file print.h.

template<typename Iter>
Iter printcontainer< Iter >::iend

The end iterator.

Definition at line 40 of file print.h.

Referenced by printcontainer< Iter >::print().

template<typename Iter>
string printcontainer< Iter >::space

The client can configure the space between elements.

Definition at line 43 of file print.h.

Referenced by printcontainer< Iter >::print().


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

Generated on Fri Mar 4 00:50:10 2011 for Chelton Evans Source by  doxygen 1.5.8