// Quick hack... // If you find this really is faster then using std::ifstream, let me know // as I can always spend some more time to improve it. namespace lexertl { template class basic_fast_filebuf : public std::basic_streambuf { public: basic_fast_filebuf (const char *filename_) : _fp (0) { _fp = ::fopen(filename_, "r"); } virtual ~basic_fast_filebuf() { ::fclose(_fp); _fp = 0; } protected: FILE *_fp; virtual std::streamsize xsgetn (CharT *ptr_, std::streamsize count_) { return ::fread (ptr_, sizeof(CharT), static_cast(count_), _fp); } }; typedef basic_fast_filebuf > fast_filebuf; typedef basic_fast_filebuf > wfast_filebuf; } // Usage: // lexertl::rules rules_; // lexertl::state_machine state_machine_; // fast_filebuf buf ("Unicode/PropList.txt"); // std::istream if_(&buf); // lexertl::stream_shared_iterator iter_ (if_); // lexertl::stream_shared_iterator end_; // lexertl::match_results // results_(iter_, end_);