/* ImageDirIterator.h * * Copyright (c) 2007 Machine Perception Laboratory * University of California San Diego. * Authors: Andrew Salamon * * A simple iterator that returns all image files in a given directory. */ #include #include "boost/filesystem/path.hpp" #include "boost/filesystem/operations.hpp" namespace bf = boost::filesystem; class ImageDirIterator { public: static std::string getExtension( const std::string &fname ); ImageDirIterator( const std::string dir ); ~ImageDirIterator(); bool operator++(); bool operator++(int); std::string operator*() const; private: std::string currentPath; bf::path directory; bf::directory_iterator dirIterator; bf::directory_iterator endIterator; bool validExtension( std::string &fname ); };