tTextFileRecorder Class Reference

text file loading recorder More...

#include <tRecorder.h>

Inheritance diagram for tTextFileRecorder:

Inheritance graph
[legend]
Collaboration diagram for tTextFileRecorder:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 tTextFileRecorder ()
 ~tTextFileRecorder ()
bool Open (tPath const &searchPath, char const *fileName)
 opens a text file for reading
 tTextFileRecorder (tPath const &searchPath, char const *fileName)
 constructor, opening a file directly (status can be queried later with EndOfFile)
bool EndOfFile () const
 end of file query
std::string GetLine ()
 read one line, give it back as a stream

Private Member Functions

 tTextFileRecorder (tTextFileRecorder const &)
tTextFileRecorderoperator= (tTextFileRecorder const &)

Private Attributes

std::ifstream * stream_
bool eof_
 the real stream to read from


Detailed Description

text file loading recorder

Definition at line 134 of file tRecorder.h.


Constructor & Destructor Documentation

tTextFileRecorder::tTextFileRecorder ( void   ) 

Definition at line 687 of file tRecorder.cpp.

References NULL, and stream_.

00688         : stream_(NULL), eof_(false)
00689 {
00690     stream_ = NULL;
00691 }

tTextFileRecorder::~tTextFileRecorder ( void   ) 

Definition at line 702 of file tRecorder.cpp.

References NULL, and stream_.

00703 {
00704     delete stream_;
00705     stream_ = NULL;
00706 }

tTextFileRecorder::tTextFileRecorder ( tPath const &  searchPath,
char const *  fileName 
)

constructor, opening a file directly (status can be queried later with EndOfFile)

Parameters:
searchPath the path to search for the file
fileName the name of the file to open

Definition at line 672 of file tRecorder.cpp.

References Open().

00673         : stream_(NULL), eof_(false)
00674 {
00675     Open( searchPath, fileName );
00676 }

Here is the call graph for this function:

tTextFileRecorder::tTextFileRecorder ( tTextFileRecorder const &   )  [private]


Member Function Documentation

bool tTextFileRecorder::Open ( tPath const &  searchPath,
char const *  fileName 
)

opens a text file for reading

Parameters:
searchPath the path to search for the file
fileName the name of the file to open
Returns:
true if opening succeeded

Definition at line 642 of file tRecorder.cpp.

References eof_, tPath::Open(), tRecorder::Playback(), tRecorder::Record(), st_fileOpen, stream_, tASSERT, and tNEW.

Referenced by tTextFileRecorder().

00643 {
00644     tASSERT( !stream_ );
00645 
00646     bool result = false;
00647 
00648     // try to read opening state from recording
00649     if ( !tRecorder::Playback( st_fileOpen, result, eof_ ) )
00650     {
00651         // open the stream (if not in recording mode)
00652         stream_ = tNEW( std::ifstream );
00653         result = searchPath.Open( *stream_, fileName );
00654         eof_ = !result || !stream_->good() || stream_->eof();
00655     }
00656     tRecorder::Record( st_fileOpen, result, eof_ );
00657 
00658     return result;
00659 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool tTextFileRecorder::EndOfFile ( void   )  const

end of file query

Returns:
true if the end of file (or any other error that has the same effect) has been reached

Definition at line 718 of file tRecorder.cpp.

References eof_.

Referenced by uMenuItemStringWithHistory::history_t::history_t(), and gAICharacter::LoadAll().

00719 {
00720     return eof_;
00721 }

Here is the caller graph for this function:

std::string tTextFileRecorder::GetLine ( void   ) 

read one line, give it back as a stream

Returns:
the line read from the file or a recording thereof

Definition at line 733 of file tRecorder.cpp.

References eof_, tRecorder::Playback(), tString::ReadLine(), tRecorder::Record(), st_fileRead, stream_, and tASSERT.

Referenced by uMenuItemStringWithHistory::history_t::history_t(), and gAICharacter::LoadAll().

00734 {
00735     // try to read opening state from recording
00736     tLineString line;
00737     if ( !tRecorder::Playback( st_fileRead, line, eof_ ) )
00738     {
00739         // read a line
00740         tASSERT( stream_ );
00741         line.ReadLine( *stream_ );
00742         std::ws( *stream_ );
00743         eof_ = !stream_->good() || stream_->eof();
00744     }
00745     tRecorder::Record( st_fileRead, line, eof_ );
00746 
00747     // convert and return read line
00748     return std::string(line);
00749 }

Here is the call graph for this function:

Here is the caller graph for this function:

tTextFileRecorder& tTextFileRecorder::operator= ( tTextFileRecorder const &   )  [private]


Member Data Documentation

std::ifstream* tTextFileRecorder::stream_ [private]

Definition at line 156 of file tRecorder.h.

Referenced by GetLine(), Open(), tTextFileRecorder(), and ~tTextFileRecorder().

bool tTextFileRecorder::eof_ [private]

the real stream to read from

Definition at line 157 of file tRecorder.h.

Referenced by EndOfFile(), GetLine(), and Open().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:59:47 2008 for Armagetron Advanced by  doxygen 1.5.4