#include "mpt_AUIterator.h" #include #include #include #include #include mpt_AUIterator::mpt_AUIterator( const char *filepath ) : ifstr( filepath ), lines( ifstr ) { } mpt_AUIterator::mpt_AUIterator( const std::string &filepath ) : ifstr( filepath.c_str() ), lines( ifstr ) { } mpt_AUIterator::mpt_AUIterator( std::istream &_is ) : lines( _is ) { } mpt_AUIterator::~mpt_AUIterator() { } unsigned int mpt_AUIterator::line() { return lines.line(); } bool mpt_AUIterator::eof() { return lines.eof(); } bool mpt_AUIterator::nextDataLine( std::string &filename, std::vector &AUs ) { if( lines.eof() ) return false; std::string dataline = lines.nextLine(); while( !lines.eof() && ( (dataline.length() == 0) || ( (dataline.length() > 0) && ('#' == dataline.at(0)) ) ) ) { dataline = lines.nextLine(); } AUs.clear(); if( (dataline.length() > 0) && ('#' != dataline.at(0)) ) { std::istringstream instr( dataline.c_str() ); char buf[256]; // parse the data line // /Users/testbot/Images/SanDiego/Females/US_SanDiego_1632821.jpg AUs: 1 2 3 4 5 6 7 8 instr >> filename; instr.getline( buf, 256, ':' ); // read up to the colon after 'AUs' for( int cnt=0; cnt < 8; ++cnt ) { float tmp; instr >> tmp; AUs.push_back( tmp ); } return true; } else { return false; } }