owlps/owlps-positioning/src/inputcsv.hh

76 lines
1.3 KiB
C++

#ifndef _OWLPS_POSITIONING_INPUTCSV_HH_
#define _OWLPS_POSITIONING_INPUTCSV_HH_
#include "inputmedium.hh"
#include <string>
#include <fstream>
/// Reads \link Request requests \endlink from a CSV file
class InputCSV: public InputMedium
{
protected:
std::string input_file_name ;
std::ifstream input_file ;
/// Current line contents
std::string current_line ;
/// Checks if the file is readable and closes it if not
bool eof_close(void) ;
void read_next_line(void) ;
public:
InputCSV(const std::string &filename) ;
~InputCSV(void) ;
/** @name Read accessors */
//@{
/// Checks if the end of the CSV file has been reached
bool eof(void) const ;
//@}
/** @name Operations */
//@{
/// Reads the next request
const Request& get_next_request(void) ;
//@}
/** @name Operators */
//@{
operator bool(void) const ;
//@}
} ;
/* *** Read accessors *** */
/**
* @return \em true if the end of file is reached.
* @return \em false if there is something more to read.
*/
inline bool InputCSV::eof() const
{
return ! input_file && input_file.eof() ;
}
/* *** Operators *** */
/**
* @return The bool value of #input_file.
* @sa std::ifstream
*/
inline InputCSV::operator bool() const
{
return input_file ;
}
#endif // _OWLPS_POSITIONING_INPUTCSV_HH_