19#ifndef ICUB_FILEREADERT__
20#define ICUB_FILEREADERT__
27namespace learningmachine {
47 std::ifstream* f_stream;
54 if(this->f_stream != (std::ifstream*) 0) {
55 this->f_stream->close();
59 delete this->f_stream;
60 this->f_stream = (std::ifstream*) 0;
69 if(this->stream == (std::istream*) 0) {
70 throw std::runtime_error(
"no stream opened.");
79 stream = (std::istream*) 0;
80 f_stream = (std::ifstream*) 0;
95 virtual void open(std::istream& s) {
105 virtual void open(
const std::string&
f) {
109 this->f_stream =
new std::ifstream(
f.c_str());
110 if(!this->f_stream->is_open()) {
112 throw std::runtime_error(std::string(
"could not open file '" +
f +
"'"));
114 return this->
open(*this->f_stream);
126 this->stream->peek();
127 return !this->stream->eof();
135 this->stream->clear();
136 this->stream->seekg(0, std::ios::beg);
151 throw std::runtime_error(
"end of stream.");
156 getline(*this->stream, line);
160 obj->fromString(line.c_str());
Template class that supports reading lines of a file to object instances using a fromString(char* lin...
virtual bool hasNext()
Checks whether there are more items left in the stream.
virtual void reset()
Resets the stream to the beginning.
~FileReaderT()
Default destructor.
virtual void open(std::istream &s)
Opens the given stream for reading.
T * getNext()
Returns a pointer to the next item in the file.
virtual void open(const std::string &f)
Opens a stream to the given filename for reading.
FileReaderT()
Default constructor.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.