60 lines
993 B
C++
60 lines
993 B
C++
#ifndef _OWLPS_POSITIONING_TEXTFILEREADER_HH_
|
|
#define _OWLPS_POSITIONING_TEXTFILEREADER_HH_
|
|
|
|
#include <string>
|
|
#include <fstream>
|
|
|
|
/// Read text from a file
|
|
class TextFileReader
|
|
{
|
|
private:
|
|
std::string file_name ;
|
|
std::ifstream file ;
|
|
|
|
/// Checks if the file is readable and closes it if not
|
|
bool eof_close(void) ;
|
|
|
|
public:
|
|
TextFileReader(const std::string &_file_name) ;
|
|
virtual ~TextFileReader(void) ;
|
|
|
|
/** @name Operations */
|
|
//@{
|
|
bool read_line(std::string &text) ;
|
|
bool eof(void) const ;
|
|
//@}
|
|
|
|
/** @name Accessors */
|
|
//@{
|
|
const std::string& get_name(void) const ;
|
|
//@}
|
|
} ;
|
|
|
|
|
|
|
|
/* *** Operations *** */
|
|
|
|
|
|
/**
|
|
* @return \em true if the end of file is reached.
|
|
* @return \em false if there is something more to read.
|
|
*/
|
|
inline bool TextFileReader::eof() const
|
|
{
|
|
return ! file && file.eof() ;
|
|
}
|
|
|
|
|
|
|
|
/* *** Accessors *** */
|
|
|
|
|
|
inline const std::string& TextFileReader::get_name() const
|
|
{
|
|
return file_name ;
|
|
}
|
|
|
|
|
|
|
|
#endif // _OWLPS_POSITIONING_TEXTFILEREADER_HH_
|