#include "mpt_dataIterator.h" #include #include #include #include #include mpt_dataIterator::mpt_dataIterator( std::string &filepath ) : ifstr( filepath.c_str() ), lines( ifstr ) { } mpt_dataIterator::mpt_dataIterator( std::istream &_is ) : lines( _is ) { } mpt_dataIterator::~mpt_dataIterator() { } unsigned int mpt_dataIterator::line() { return lines.line(); } bool mpt_dataIterator::eof() { return lines.eof(); } bool mpt_dataIterator::nextDataLine( std::string &filename, float &eye_angle, mpt::eyes &_eyes ) { if( lines.eof() ) return false; std::string dataline = lines.nextLine(); if( (dataline.length() > 0) && ('#' != dataline.at(0)) ) { char buf[256]; std::istringstream instr( dataline.c_str() ); // parse the data line // /Users/testbot/Images/SanDiego/Females/US_SanDiego_1632821.jpg -13.862246 Left: {110.982, 77.7905} Right: {66.7772, 88.6993} instr >> filename >> eye_angle; instr.getline( buf, 256, '{' ); // read up to the first eye data bracket instr >> _eyes.left.x; instr.get(); // Should be the comma instr >> _eyes.left.y; instr.getline( buf, 256, '{' ); // read up to the second eye data bracket instr >> _eyes.right.x; instr.get(); // Should be the comma instr >> _eyes.right.y; return true; } else { return false; } }