Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

CTBlineStream Class Reference

Line-oriented input stream. More...

#include "CTBlineStream.hxx"

Collaboration diagram for CTBlineStream:

Collaboration graph
[legend]
List of all members.

Public Methods

 CTBlineStream ()
 ~CTBlineStream ()
bool Open (const char *c_name)
void Attach (istream *p_is)
void Close ()
bool Get (CTBstring &line)
bool Get (const char *&c_line)
bool Unget ()
 operator bool ()
CTBlineStream & operator>> (CTBstring &line)
CTBlineStream & operator>> (const char *&c_line)

Private Methods

bool Get ()

Private Attributes

istream * mp_is
bool mb_attached
bool mb_valid_line
bool mb_reread_line
CTBstring m_line

Detailed Description

Line-oriented input stream.

A CTBlineStream object implements line oriented access to an input stream.

Definition at line 18 of file CTBlineStream.hxx.


Constructor & Destructor Documentation

CTBlineStream::CTBlineStream
 

Constructor.

Creates a disconnected line stream. One has to use Open() or Attach() to connect it to an input stream.

Definition at line 35 of file CTBlineStream.cxx.

CTBlineStream::~CTBlineStream
 

Destructor.

Uses Close() to close any opened input stream.

Definition at line 48 of file CTBlineStream.cxx.


Member Function Documentation

bool CTBlineStream::Open const char * c_name
 

Open an input file.

Creates a new input stream and tries to open the file c_name. However, if the file name c_name equals "-", an Attach() to cin is done. The function returns true if the open succeded.

Definition at line 61 of file CTBlineStream.cxx.

void CTBlineStream::Attach istream * p_is
 

Attach to an input stream.

This method stores a pointer to the input stream referred by p_is in the object and causes all future Get() requests to obtain input from this stream. Note, that CTBlineStream does not assume ownership of the stream p_is and will consequently neither close nor delete this stream when the CTBlineStream is destroyed. Attach() is for example usefull for attaching to standart streams like cin.

Definition at line 92 of file CTBlineStream.cxx.

Referenced by Open().

void CTBlineStream::Close
 

Close a line stream.

An stream connected with Open() will is closed, a stream connected with Attach() just disconnected from the CTBlineStream object.

Definition at line 111 of file CTBlineStream.cxx.

Referenced by Attach(), Open(), and ~CTBlineStream().

bool CTBlineStream::Get CTBstring & line
 

Get next line into a CTBstring.

Gets the next line and returns it in line. Returns true if this succeded.

Definition at line 131 of file CTBlineStream.cxx.

bool CTBlineStream::Get const char *& c_line
 

Get next line, return char* pointer.

Gets the next line and returns a pointer to an internally stored copy of the string to c_line. Returns true if this succeded.

Definition at line 146 of file CTBlineStream.cxx.

bool CTBlineStream::Unget
 

Unget last read line.

Unget() causes the current line to be returned again by the next call of Get(). Unget() should only be called if a stream is connected and at least one successful Get() has been executed and returns false if any of those conditions are not fullfilled.

Note, that only one line can be ungotten, that means between two calls of Unget() must be at least one successful call of Get().

Definition at line 166 of file CTBlineStream.cxx.

CTBlineStream::operator bool [inline]
 

Convert to bool.

Returns true if the stream is connected and in good state.

Definition at line 20 of file CTBlineStream.icc.

CTBlineStream & CTBlineStream::operator>> CTBstring & line [inline]
 

Gets next line into line.

Definition at line 28 of file CTBlineStream.icc.

CTBlineStream & CTBlineStream::operator>> const char *& c_line [inline]
 

Gets next line.

Gets the next line and returns a pointer to an internally stored copy of the string to c_line.

Definition at line 41 of file CTBlineStream.icc.

bool CTBlineStream::Get [private]
 

Definition at line 176 of file CTBlineStream.cxx.

Referenced by Get(), and operator>>().


Member Data Documentation

istream* CTBlineStream::mp_is [private]
 

Definition at line 43 of file CTBlineStream.hxx.

bool CTBlineStream::mb_attached [private]
 

Definition at line 44 of file CTBlineStream.hxx.

bool CTBlineStream::mb_valid_line [private]
 

Definition at line 45 of file CTBlineStream.hxx.

bool CTBlineStream::mb_reread_line [private]
 

Definition at line 46 of file CTBlineStream.hxx.

CTBstring CTBlineStream::m_line [private]
 

Definition at line 47 of file CTBlineStream.hxx.


The documentation for this class was generated from the following files:
Generated at Fri Oct 24 18:13:52 2003 for CTBbase by doxygen1.2.9-20010812 written by Dimitri van Heesch, © 1997-2001