9 #include <boost/date_time/posix_time/posix_time.hpp>
10 #include <boost/date_time/gregorian/gregorian.hpp>
11 #include <boost/program_options.hpp>
15 #include <opentrep/config/opentrep-paths.hpp>
35 std::string& ioPORFilepath,
36 std::string& ioXapianDBFilepath,
37 std::string& ioSQLiteDBFilepath,
38 std::string& ioLogFilename) {
41 boost::program_options::options_description
generic (
"Generic options");
43 (
"prefix",
"print installation prefix")
44 (
"version,v",
"print version string")
45 (
"help,h",
"produce help message");
49 boost::program_options::options_description config (
"Configuration");
53 "POR file-path (e.g., ori_por_public.csv)")
56 "Xapian database filepath (e.g., /tmp/opentrep/traveldb)")
59 "SQLite3 database filepath (e.g., ~/tmp/opentrep/traveldb/ori_por_public.db)")
62 "Filepath for the logs")
67 boost::program_options::options_description hidden (
"Hidden options");
70 boost::program_options::value< std::vector<std::string> >(),
71 "Show the copyright (license)");
73 boost::program_options::options_description cmdline_options;
74 cmdline_options.add(
generic).add(config).add(hidden);
76 boost::program_options::options_description config_file_options;
77 config_file_options.add(config).add(hidden);
79 boost::program_options::options_description visible (
"Allowed options");
80 visible.add(
generic).add(config);
82 boost::program_options::positional_options_description p;
83 p.add (
"copyright", -1);
85 boost::program_options::variables_map vm;
86 boost::program_options::
87 store (boost::program_options::command_line_parser (argc, argv).
88 options (cmdline_options).positional(p).run(), vm);
90 std::ifstream ifs (
"opentrep-indexer.cfg");
91 boost::program_options::store (parse_config_file (ifs, config_file_options),
93 boost::program_options::notify (vm);
95 if (vm.count (
"help")) {
96 std::cout << visible << std::endl;
100 if (vm.count (
"version")) {
101 std::cout << PACKAGE_NAME <<
", version " << PACKAGE_VERSION << std::endl;
105 if (vm.count (
"prefix")) {
106 std::cout <<
"Installation prefix: " << PREFIXDIR << std::endl;
110 if (vm.count (
"porfile")) {
111 ioPORFilepath = vm[
"porfile"].as< std::string >();
112 std::cout <<
"POR file-path is: " << ioPORFilepath << std::endl;
115 if (vm.count (
"xapiandb")) {
116 ioXapianDBFilepath = vm[
"xapiandb"].as< std::string >();
117 std::cout <<
"Xapian database filepath is: " << ioXapianDBFilepath
121 if (vm.count (
"sqlitedb")) {
122 ioSQLiteDBFilepath = vm[
"sqlitedb"].as< std::string >();
123 std::cout <<
"SQLite3 database filepath is: " << ioSQLiteDBFilepath
127 if (vm.count (
"log")) {
128 ioLogFilename = vm[
"log"].as< std::string >();
129 std::cout <<
"Log filename is: " << ioLogFilename << std::endl;
137 int main (
int argc,
char* argv[]) {
140 std::string lLogFilename;
143 std::string lPORFilepathStr;
146 std::string lXapianDBNameStr;
149 std::string lSQLiteDBFilePathStr;
152 const int lOptionParserStatus =
154 lXapianDBNameStr, lSQLiteDBFilePathStr, lLogFilename);
161 std::ofstream logOutputFile;
163 logOutputFile.open (lLogFilename.c_str());
164 logOutputFile.clear();
167 std::cout <<
"Creating the Xapian index/database may take a few minutes "
168 <<
"on some architectures (and a few seconds on fastest ones)..."
176 lXapianDBName, lSQLiteDBFilePath);
183 logOutputFile.close();
186 std::cout << lNbOfEntries <<
" entries have been processed" << std::endl;
int main(int argc, char *argv[])
const std::string K_OPENTREP_DEFAULT_LOG_FILENAME("opentrep-indexer.log")
const std::string DEFAULT_OPENTREP_SQLITE_DB_FILEPATH
unsigned int NbOfDBEntries_T
Interface for the OPENTREP Services.
std::vector< std::string > WordList_T
int readConfiguration(int argc, char *argv[], std::string &ioPORFilepath, std::string &ioXapianDBFilepath, std::string &ioSQLiteDBFilepath, std::string &ioLogFilename)
NbOfDBEntries_T buildSearchIndex()
const std::string DEFAULT_OPENTREP_XAPIAN_DB_FILEPATH
const std::string DEFAULT_OPENTREP_POR_FILEPATH
const int K_OPENTREP_EARLY_RETURN_STATUS