#include <tRecorder.h>
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 &) | |
tTextFileRecorder & | operator= (tTextFileRecorder const &) |
Private Attributes | |
std::ifstream * | stream_ |
bool | eof_ |
the real stream to read from |
Definition at line 134 of file tRecorder.h.
tTextFileRecorder::tTextFileRecorder | ( | void | ) |
tTextFileRecorder::~tTextFileRecorder | ( | void | ) |
tTextFileRecorder::tTextFileRecorder | ( | tPath const & | searchPath, | |
char const * | fileName | |||
) |
constructor, opening a file directly (status can be queried later with EndOfFile)
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().
tTextFileRecorder::tTextFileRecorder | ( | tTextFileRecorder const & | ) | [private] |
bool tTextFileRecorder::Open | ( | tPath const & | searchPath, | |
char const * | fileName | |||
) |
opens a text file for reading
searchPath | the path to search for the file | |
fileName | the name of the file to open |
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 }
bool tTextFileRecorder::EndOfFile | ( | void | ) | const |
end of file query
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 }
std::string tTextFileRecorder::GetLine | ( | void | ) |
read one line, give it back as a stream
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 }
tTextFileRecorder& tTextFileRecorder::operator= | ( | tTextFileRecorder const & | ) | [private] |
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().