tests/harness/index_utils.h

Go to the documentation of this file.
00001 /* index_utils.h - utility functions for indexing testcase data
00002  *
00003  * Copyright (C) 2005,2007 Olly Betts
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #ifndef XAPIAN_HGUARD_INDEX_UTILS_H
00021 #define XAPIAN_HGUARD_INDEX_UTILS_H
00022 
00023 #include <fstream>
00024 #include <string>
00025 #include <vector>
00026 
00027 #include <xapian.h>
00028 
00029 std::string munge_term(const std::string &term);
00030 
00031 class FileIndexer {
00032     std::string datadir;
00033     std::vector<std::string>::const_iterator file, end;
00034     std::ifstream input;
00035 
00036     void next_file();
00037 
00038   public:
00039     FileIndexer(const std::string & datadir_,
00040                 const std::vector<std::string> & files)
00041         : datadir(datadir_), file(files.begin()), end(files.end())
00042     {
00043         next_file();
00044     }
00045 
00046     operator bool() {
00047         return !(file == end && (!input.is_open() || input.eof()));
00048     }
00049 
00050     Xapian::Document next();
00051 };
00052 
00053 #endif /* XAPIAN_HGUARD_INDEX_UTILS_H */

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.