OpenTREP Logo  0.07.20
C++ Open Travel Request Parsing Library
Loading...
Searching...
No Matches
opentrep-dbmgr.cpp
Go to the documentation of this file.
1// STL
2#include <cassert>
3#include <iostream>
4#include <sstream>
5#include <fstream>
6#include <vector>
7#include <string>
8// Boost (Extended STL)
9#include <boost/date_time/posix_time/posix_time.hpp>
10#include <boost/date_time/gregorian/gregorian.hpp>
11#include <boost/regex.hpp>
12#include <boost/program_options.hpp>
13// GNU Readline Wrapper
15// OpenTREP
17#include <opentrep/Location.hpp>
21#include <opentrep/config/opentrep-paths.hpp>
23
24
25// //////// Type definitions ///////
26typedef std::vector<std::string> WordList_T;
27
28
29// //////// Constants //////
33const std::string K_OPENTREP_DEFAULT_LOG_FILENAME ("opentrep-dbmgr.log");
34
35
36// ///////// Parsing of Options & Configuration /////////
39
44typedef std::vector<std::string> TokenList_T;
45
77
78// ///////// Parsing of Options & Configuration /////////
79// A helper function to simplify the main part.
80template<class T> std::ostream& operator<< (std::ostream& os,
81 const std::vector<T>& v) {
82 std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout, " "));
83 return os;
84}
85
89int readConfiguration (int argc, char* argv[],
90 std::string& ioPORFilepath,
91 std::string& ioXapianDBFilepath,
92 std::string& ioSQLDBTypeString,
93 std::string& ioSQLDBConnectionString,
94 unsigned short& ioDeploymentNumber,
95 bool& ioIncludeNonIATAPOR,
96 bool& ioIndexPORInXapian,
97 bool& ioAddPORInDB,
98 std::string& ioLogFilename) {
99
100 // Declare a group of options that will be allowed only on command line
101 boost::program_options::options_description generic ("Generic options");
102 generic.add_options()
103 ("prefix", "print installation prefix")
104 ("version,v", "print version string")
105 ("help,h", "produce help message");
106
107 // Declare a group of options that will be allowed both on command
108 // line and in config file
109 boost::program_options::options_description config ("Configuration");
110 config.add_options()
111 ("porfile,p",
112 boost::program_options::value< std::string >(&ioPORFilepath)->default_value(OPENTREP::DEFAULT_OPENTREP_POR_FILEPATH),
113 "POR file-path (e.g., ori_por_public.csv)")
114 ("xapiandb,d",
115 boost::program_options::value< std::string >(&ioXapianDBFilepath)->default_value(OPENTREP::DEFAULT_OPENTREP_XAPIAN_DB_FILEPATH),
116 "Xapian database filepath (e.g., /tmp/opentrep/xapian_traveldb)")
117 ("sqldbtype,t",
118 boost::program_options::value< std::string >(&ioSQLDBTypeString)->default_value(OPENTREP::DEFAULT_OPENTREP_SQL_DB_TYPE),
119 "SQL database type (e.g., nodb for no SQL database, sqlite for SQLite, mysql for MariaDB/MySQL, pg for PostgreSQL)")
120 ("sqldbconx,s",
121 boost::program_options::value< std::string >(&ioSQLDBConnectionString),
122 "SQL database connection string (e.g., ~/tmp/opentrep/sqlite_travel.db for SQLite, \"db=trep_trep user=trep password=trep\" for MariaDB/MySQL or PostgreSQL)")
123 ("deploymentnb,m",
124 boost::program_options::value<unsigned short>(&ioDeploymentNumber)->default_value(OPENTREP::DEFAULT_OPENTREP_DEPLOYMENT_NUMBER),
125 "Deployment number (from to N, where N=1 normally)")
126 ("noniata,n",
127 boost::program_options::value<bool>(&ioIncludeNonIATAPOR)->default_value(OPENTREP::DEFAULT_OPENTREP_INCLUDE_NONIATA_POR),
128 "Whether or not to include POR not referenced by IATA (0 = only IATA-referenced POR, 1 = all POR are included)")
129 ("xapianindex,x",
130 boost::program_options::value<bool>(&ioIndexPORInXapian)->default_value(OPENTREP::DEFAULT_OPENTREP_INDEX_IN_XAPIAN),
131 "Whether or not to index the POR in Xapian (0 = do not touch the Xapian index, 1 = re-index all the POR in Xapian)")
132 ("dbadd,a",
133 boost::program_options::value<bool>(&ioAddPORInDB)->default_value(OPENTREP::DEFAULT_OPENTREP_ADD_IN_DB),
134 "Whether or not to add and index the POR in the SQL-based database (0 = do not touch the SQL-based database, 1 = add and re-index all the POR in the SQL-based database)")
135 ("log,l",
136 boost::program_options::value< std::string >(&ioLogFilename)->default_value(K_OPENTREP_DEFAULT_LOG_FILENAME),
137 "Filepath for the logs")
138 ;
139
140 // Hidden options, will be allowed both on command line and
141 // in config file, but will not be shown to the user.
142 boost::program_options::options_description hidden ("Hidden options");
143 hidden.add_options()
144 ("copyright",
145 boost::program_options::value< std::vector<std::string> >(),
146 "Show the copyright (license)");
147
148 boost::program_options::options_description cmdline_options;
149 cmdline_options.add(generic).add(config).add(hidden);
150
151 boost::program_options::options_description config_file_options;
152 config_file_options.add(config).add(hidden);
153
154 boost::program_options::options_description visible ("Allowed options");
155 visible.add(generic).add(config);
156
157 boost::program_options::positional_options_description p;
158 p.add ("copyright", -1);
159
160 boost::program_options::variables_map vm;
161 boost::program_options::
162 store (boost::program_options::command_line_parser (argc, argv).
163 options (cmdline_options).positional(p).run(), vm);
164
165 std::ifstream ifs ("opentrep-dbmgr.cfg");
166 boost::program_options::store (parse_config_file (ifs, config_file_options),
167 vm);
168 boost::program_options::notify (vm);
169
170 if (vm.count ("help")) {
171 std::cout << visible << std::endl;
173 }
174
175 if (vm.count ("version")) {
176 std::cout << PACKAGE_NAME << ", version " << PACKAGE_VERSION << std::endl;
178 }
179
180 if (vm.count ("prefix")) {
181 std::cout << "Installation prefix: " << PREFIXDIR << std::endl;
183 }
184
185 if (vm.count ("porfile")) {
186 ioPORFilepath = vm["porfile"].as< std::string >();
187 }
188
189 if (vm.count ("deploymentnb")) {
190 ioDeploymentNumber = vm["deploymentnb"].as< unsigned short >();
191 std::cout << "Deployment number " << ioDeploymentNumber << std::endl;
192 }
193
194 if (vm.count ("xapiandb")) {
195 ioXapianDBFilepath = vm["xapiandb"].as< std::string >();
196 std::cout << "Xapian index/database filepath is: " << ioXapianDBFilepath
197 << ioDeploymentNumber << std::endl;
198 }
199
200 // Parse the SQL database type, if any is given
201 if (vm.count ("sqldbtype")) {
202 ioSQLDBTypeString = vm["sqldbtype"].as< std::string >();
203 std::cout << "SQL database type is: " << ioSQLDBTypeString
204 << std::endl;
205 }
206
218 const OPENTREP::DBType lDBType (ioSQLDBTypeString);
219 if (lDBType == OPENTREP::DBType::NODB) {
220 ioAddPORInDB = false;
221 ioSQLDBConnectionString = "";
222
223 } else if (lDBType == OPENTREP::DBType::SQLITE3) {
224 ioAddPORInDB = true;
225 ioSQLDBConnectionString = OPENTREP::DEFAULT_OPENTREP_SQLITE_DB_FILEPATH;
226
227 } else if (lDBType == OPENTREP::DBType::PG) {
228 ioAddPORInDB = true;
229 ioSQLDBConnectionString = OPENTREP::DEFAULT_OPENTREP_PG_CONN_STRING;
230
231 } else if (lDBType == OPENTREP::DBType::MYSQL) {
232 ioAddPORInDB = true;
233 ioSQLDBConnectionString = OPENTREP::DEFAULT_OPENTREP_MYSQL_CONN_STRING;
234 }
235
236 // Set the SQL database connection string, if any is given
237 if (vm.count ("sqldbconx")) {
238 ioSQLDBConnectionString = vm["sqldbconx"].as< std::string >();
239 }
240
241 // Reporting of the SQL database connection string
242 if (lDBType == OPENTREP::DBType::SQLITE3
243 || lDBType == OPENTREP::DBType::MYSQL
244 || lDBType == OPENTREP::DBType::PG) {
245 const std::string& lSQLDBConnString =
247 ioSQLDBConnectionString,
248 ioDeploymentNumber);
249 //
250 std::cout << "SQL database connection string is: " << lSQLDBConnString
251 << std::endl;
252 }
253
254 std::cout << "Are non-IATA-referenced POR included? "
255 << ioIncludeNonIATAPOR << std::endl;
256
257 std::cout << "Index the POR in Xapian? "
258 << ioIndexPORInXapian << std::endl;
259
260 std::cout << "Add and re-index the POR in the SQL-based database? "
261 << ioAddPORInDB << std::endl;
262
263 if (vm.count ("log")) {
264 ioLogFilename = vm["log"].as< std::string >();
265 }
266
267 // Information
268 std::cout << "Type the 'info' command to get a few details (e.g., file-path)"
269 << std::endl;
270
271 return 0;
272}
273
274// //////////////////////////////////////////////////////////////////
275void initReadline (swift::SReadline& ioInputReader) {
276
277 // Prepare the list of my own completers
278 std::vector<std::string> Completers;
279
280 // The following is supported:
281 // - "identifiers"
282 // - special identifier %file - means to perform a file name completion
283 Completers.push_back ("help");
284 Completers.push_back ("info");
285 Completers.push_back ("tutorial");
286 Completers.push_back ("create_user");
287 Completers.push_back ("reset_connection_string %connection_string");
288 Completers.push_back ("create_tables");
289 Completers.push_back ("create_indexes");
290 Completers.push_back ("toggle_deployment_number");
291 Completers.push_back ("toggle_noniata_indexing_flag");
292 Completers.push_back ("toggle_xapian_idexing_flag");
293 Completers.push_back ("toggle_sqldb_inserting_flag");
294 Completers.push_back ("fill_from_por_file");
295 Completers.push_back ("list_by_iata %iata_code");
296 Completers.push_back ("list_by_icao %icao_code");
297 Completers.push_back ("list_by_faa %faa_code");
298 Completers.push_back ("list_by_unlocode %unlocode_code");
299 Completers.push_back ("list_by_uiccode %uic_code");
300 Completers.push_back ("list_by_geonameid %geoname_id");
301 Completers.push_back ("list_nb");
302 Completers.push_back ("list_all");
303 Completers.push_back ("list_cont");
304 Completers.push_back ("quit");
305
306 // Now register the completers.
307 // Actually it is possible to re-register another set at any time
308 ioInputReader.RegisterCompletions (Completers);
309}
310
311// //////////////////////////////////////////////////////////////////
314
315 // Interpret the user input
316 if (ioTokenList.empty() == false) {
317 TokenList_T::iterator itTok = ioTokenList.begin();
318 std::string lCommand (*itTok);
319 boost::algorithm::to_lower (lCommand);
320 if (lCommand == "help") {
321 oCommandType = Command_T::HELP;
322
323 } else if (lCommand == "info") {
324 oCommandType = Command_T::INFO;
325
326 } else if (lCommand == "tutorial") {
327 oCommandType = Command_T::TUTORIAL;
328
329 } else if (lCommand == "create_user") {
330 oCommandType = Command_T::CREATE_USER;
331
332 } else if (lCommand == "reset_connection_string") {
334
335 } else if (lCommand == "create_tables") {
336 oCommandType = Command_T::CREATE_TABLES;
337
338 } else if (lCommand == "create_indexes") {
339 oCommandType = Command_T::CREATE_INDEXES;
340
341 } else if (lCommand == "toggle_deployment_number") {
343
344 } else if (lCommand == "toggle_noniata_indexing_flag") {
346
347 } else if (lCommand == "toggle_xapian_idexing_flag") {
349
350 } else if (lCommand == "toggle_sqldb_inserting_flag") {
352
353 } else if (lCommand == "fill_from_por_file") {
354 oCommandType = Command_T::FILL_FROM_POR_FILE;
355
356 } else if (lCommand == "list_by_iata") {
357 oCommandType = Command_T::LIST_BY_IATA;
358
359 } else if (lCommand == "list_by_icao") {
360 oCommandType = Command_T::LIST_BY_ICAO;
361
362 } else if (lCommand == "list_by_faa") {
363 oCommandType = Command_T::LIST_BY_FAA;
364
365 } else if (lCommand == "list_by_unlocode") {
366 oCommandType = Command_T::LIST_BY_UNLOCODE;
367
368 } else if (lCommand == "list_by_uiccode") {
369 oCommandType = Command_T::LIST_BY_UICCODE;
370
371 } else if (lCommand == "list_by_geonameid") {
372 oCommandType = Command_T::LIST_BY_GEONAMEID;
373
374 } else if (lCommand == "list_nb") {
375 oCommandType = Command_T::LIST_NB;
376
377 } else if (lCommand == "list_all") {
378 oCommandType = Command_T::LIST_ALL;
379
380 } else if (lCommand == "list_cont") {
381 oCommandType = Command_T::LIST_CONT;
382
383 } else if (lCommand == "quit") {
384 oCommandType = Command_T::QUIT;
385 }
386
387 // Remove the first token (the command), as the corresponding information
388 // has been extracted in the form of the returned command type enumeration
389 ioTokenList.erase (itTok);
390
391 } else {
392 oCommandType = Command_T::NOP;
393 }
394
395 return oCommandType;
396}
397
398// //////////////////////////////////////////////////////////////////
399void parseConnectionString (const TokenList_T& iTokenList,
400 std::string& ioConnectionString) {
401 // Interpret the user input
402 if (iTokenList.empty() == false) {
403
404 // Read the database connection string
405 TokenList_T::const_iterator itTok = iTokenList.begin();
406 if (itTok->empty() == false) {
407 ioConnectionString = *itTok;
408 }
409 }
410}
411
412// //////////////////////////////////////////////////////////////////
413void parsePlaceKey (const TokenList_T& iTokenList, std::string& ioPlaceKey) {
414 // Interpret the user input
415 if (iTokenList.empty() == false) {
416
417 // Read the IATA code
418 TokenList_T::const_iterator itTok = iTokenList.begin();
419 if (itTok->empty() == false) {
420 ioPlaceKey = *itTok;
421 }
422 }
423}
424
425// /////////////////////////////////////////////////////////
426std::string toString (const TokenList_T& iTokenList) {
427 std::ostringstream oStr;
428
429 // Re-create the string with all the tokens, trimmed by read-line
430 unsigned short idx = 0;
431 for (TokenList_T::const_iterator itTok = iTokenList.begin();
432 itTok != iTokenList.end(); ++itTok, ++idx) {
433 if (idx != 0) {
434 oStr << " ";
435 }
436 oStr << *itTok;
437 }
438
439 return oStr.str();
440}
441
442// /////////////////////////////////////////////////////////
444 const std::string& iRegularExpression) {
445 TokenList_T oTokenList;
446
447 // Re-create the string with all the tokens (which had been trimmed
448 // by read-line)
449 const std::string lFullLine = toString (iTokenList);
450
451 // See the caller for the regular expression
452 boost::regex expression (iRegularExpression);
453
454 std::string::const_iterator start = lFullLine.begin();
455 std::string::const_iterator end = lFullLine.end();
456
457 boost::match_results<std::string::const_iterator> what;
458 boost::match_flag_type flags = boost::match_default | boost::format_sed;
459 regex_search (start, end, what, expression, flags);
460
461 // Put the matched strings in the list of tokens to be returned back
462 // to the caller
463 const unsigned short lMatchSetSize = what.size();
464 for (unsigned short matchIdx = 1; matchIdx != lMatchSetSize; ++matchIdx) {
465 const std::string lMatchedString (std::string (what[matchIdx].first,
466 what[matchIdx].second));
467 //if (lMatchedString.empty() == false) {
468 oTokenList.push_back (lMatchedString);
469 //}
470 }
471
472 // DEBUG
473 // std::cout << "After (token list): " << oTokenList << std::endl;
474
475 return oTokenList;
476}
477
478// /////////////////////////////////////////////////////////
485 const std::string lRegEx ("^([[:alpha:]]{3})$");
486
487 //
488 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
489 return oTokenList;
490}
491
492// /////////////////////////////////////////////////////////
499 const std::string lRegEx ("^(([[:alpha:]]|[[:digit:]]){4})$");
500
501 //
502 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
503 return oTokenList;
504}
505
506// /////////////////////////////////////////////////////////
513 const std::string lRegEx ("^(([[:alpha:]]|[[:digit:]]){3,4})$");
514
515 //
516 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
517 return oTokenList;
518}
519
520// /////////////////////////////////////////////////////////
527 const std::string lRegEx ("^(([[:alpha:]]|[[:digit:]]){5})$");
528
529 //
530 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
531 return oTokenList;
532}
533
534// /////////////////////////////////////////////////////////
541 const std::string lRegEx ("^([[:digit:]]{1,11})$");
542
543 //
544 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
545 return oTokenList;
546}
547
548// /////////////////////////////////////////////////////////
555 const std::string lRegEx ("^([[:digit:]]{1,11})$");
556
557 //
558 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
559 return oTokenList;
560}
561
562
563// /////////////// M A I N /////////////////
564int main (int argc, char* argv[]) {
565
566 // Readline history
567 const unsigned int lHistorySize (100);
568 const std::string lHistoryFilename ("opentrep-dbmgr.hist");
569 const std::string lHistoryBackupFilename ("opentrep-dbmgr.hist.bak");
570
571 // Output log File
572 std::string lLogFilename;
573
574 // File-path of POR (points of reference)
575 std::string lPORFilepathStr;
576
577 // Xapian database name (directory of the index)
578 std::string lXapianDBNameStr;
579
580 // SQL database type
581 std::string lSQLDBTypeStr;
582
583 // SQL database connection string
584 std::string lSQLDBConnectionStr;
585
586 // Deployment number/version
587 OPENTREP::DeploymentNumber_T lDeploymentNumber;
588
589 // Whether or not to include non-IATA-referenced POR
590 OPENTREP::shouldIndexNonIATAPOR_T lIncludeNonIATAPOR;
591
592 // Whether or not to index the POR in Xapian
593 OPENTREP::shouldIndexPORInXapian_T lShouldIndexPORInXapian;
594
595 // Whether or not to insert the POR in the SQL database
596 OPENTREP::shouldAddPORInSQLDB_T lShouldAddPORInSQLDB;
597
598 // Call the command-line option parser
599 const int lOptionParserStatus =
600 readConfiguration (argc, argv, lPORFilepathStr, lXapianDBNameStr,
601 lSQLDBTypeStr, lSQLDBConnectionStr, lDeploymentNumber,
602 lIncludeNonIATAPOR, lShouldIndexPORInXapian,
603 lShouldAddPORInSQLDB, lLogFilename);
604
605 if (lOptionParserStatus == K_OPENTREP_EARLY_RETURN_STATUS) {
606 return 0;
607 }
608
609 // Set the log parameters
610 std::ofstream logOutputFile;
611 // open and clean the log outputfile
612 logOutputFile.open (lLogFilename.c_str());
613 logOutputFile.clear();
614
615 // Initialise the context
616 const OPENTREP::PORFilePath_T lPORFilepath (lPORFilepathStr);
617 const OPENTREP::TravelDBFilePath_T lXapianDBName (lXapianDBNameStr);
618 const OPENTREP::DBType lDBType (lSQLDBTypeStr);
619 const OPENTREP::SQLDBConnectionString_T lSQLDBConnStr (lSQLDBConnectionStr);
620 OPENTREP::OPENTREP_Service opentrepService (logOutputFile, lPORFilepath,
621 lXapianDBName,
622 lDBType, lSQLDBConnStr,
623 lDeploymentNumber,
624 lIncludeNonIATAPOR,
625 lShouldIndexPORInXapian,
626 lShouldAddPORInSQLDB);
627
628 // DEBUG
629 OPENTREP_LOG_DEBUG ("====================================================");
630 OPENTREP_LOG_DEBUG ("= Beginning of the interactive session =");
631 OPENTREP_LOG_DEBUG ("====================================================");
632
633 // Initialise the GNU readline wrapper
634 swift::SReadline lReader (lHistoryFilename, lHistorySize);
635 initReadline (lReader);
636
637 // Now we can ask user for a line
638 std::string lUserInput;
639 bool EndOfInput (false);
640 Command_T::Type_T lCommandType (Command_T::NOP);
641
642 while (lCommandType != Command_T::QUIT && EndOfInput == false) {
643 // Prompt
644 std::ostringstream oPromptStr;
645 oPromptStr << "opentrep> ";
646
647 // Call read-line, which will fill the list of tokens
648 TokenList_T lTokenListByReadline;
649 lUserInput = lReader.GetLine (oPromptStr.str(), lTokenListByReadline,
650 EndOfInput);
651
652 // The history can be saved to an arbitrary file at any time
653 lReader.SaveHistory (lHistoryBackupFilename);
654
655 // The end-of-input typically corresponds to a CTRL-D typed by the user
656 if (EndOfInput) {
657 std::cout << std::endl;
658 break;
659 }
660
661 // Interpret the user input
662 lCommandType = extractCommand (lTokenListByReadline);
663
664 switch (lCommandType) {
665
666 // ////////////////////////////// Help ////////////////////////
667 case Command_T::HELP: {
668 std::cout << std::endl;
669 std::cout << "Commands: " << std::endl;
670 std::cout << " CTRL-L (Control and L keys)" << "\t" << "Clean the screen"
671 << std::endl;
672 std::cout << " help" << "\t\t\t\t" << "Display this help" << std::endl;
673 std::cout << " info" << "\t\t\t\t"
674 << "Display details for the current session "
675 << "(e.g., file-paths for the log file, SQL database)"
676 << std::endl;
677 std::cout << " tutorial" << "\t\t\t" << "Display examples" << std::endl;
678 std::cout << " quit" << "\t\t\t\t" << "Quit the application" << std::endl;
679 std::cout << " create_user" << "\t\t\t"
680 << "On SQL database, create the 'trep' user and the 'trep_trep' "
681 << "database. SQL database administrative rights are required."
682 << std::endl;
683 std::cout << " reset_connection_string" << "\t"
684 << "Reset/update the connection string to a MySQL or PostgreSQL database."
685 << " The connection string must be given"
686 << std::endl;
687 std::cout << " create_tables" << "\t\t\t"
688 << "Create/reset the SQL database (eg, SQLite3, PostgreSQL, MySQL) tables"
689 << std::endl;
690 std::cout << " create_indexes" << "\t\t\t"
691 << "Create/reset the SQL database (eg, SQLite3, PostgreSQL, MySQL) indices"
692 << std::endl;
693 std::cout << " toggle_deployment_number" << "\t"
694 << "Toggle the deployment number/version. "
695 << "To see the deployment version/number, type 'info'"
696 << std::endl;
697 std::cout << " toggle_noniata_indexing_flag" << "\t"
698 << "Toggle the flag for the indexing (or not) of the non-IATA referenced POR."
699 << " To see the flag, type 'info'"
700 << std::endl;
701 std::cout << " toggle_xapian_idexing_flag" << "\t"
702 << "Toggle the flag for the Xapian indexing (or not) of the POR."
703 << " To see the flag, type 'info'"
704 << std::endl;
705 std::cout << " toggle_sqldb_inserting_flag" << "\t"
706 << "Toggle the flag for inserting (or not) the POR into the SQL database."
707 << " To see the flag, type 'info'"
708 << std::endl;
709 std::cout << " fill_from_por_file" << "\t\t"
710 << "Parse the file of POR and fill-in the SQL database optd_por table."
711 << std::endl << "\t\t\t\t"
712 << "That command (re-)creates both the Xapian index and the SQL tables (as well as the indices), if needed."
713 << std::endl << "\t\t\t\t"
714 << "Note that, as that command takes minutes, the connection to the SQL database may be lost and the program will exit abnormally."
715 << std::endl << "\t\t\t\t"
716 << "In that latter case, just re-execute the program and check how far the indexation went by executing the following command."
717 << std::endl;
718 std::cout << " list_nb" << "\t\t\t"
719 << "Display the number of the entries of the database."
720 << std::endl;
721 std::cout << " list_all" << "\t\t\t"
722 << "List all the entries of the database, page by page."
723 << "Type the 'list_cont' command for a page down" << std::endl;
724 std::cout << " list_by_iata" << "\t\t\t"
725 << "List all the entries for a given IATA code"
726 << std::endl;
727 std::cout << " list_by_icao" << "\t\t\t"
728 << "List all the entries for a given ICAO code"
729 << std::endl;
730 std::cout << " list_by_faa" << "\t\t\t"
731 << "List all the entries for a given FAA code"
732 << std::endl;
733 std::cout << " list_by_unlocode" << "\t\t\t"
734 << "List all the entries for a given UN/LOCODE code"
735 << std::endl;
736 std::cout << " list_by_uiccode" << "\t\t\t"
737 << "List all the entries for a given UIC code"
738 << std::endl;
739 std::cout << " list_by_geonameid" << "\t\t"
740 << "List all the entries for a given Geoname ID"
741 << std::endl;
742 std::cout << std::endl;
743 break;
744 }
745
746 // ////////////////////////////// Information ////////////////////////
747 case Command_T::INFO: {
749 opentrepService.getFilePaths();
751 lFPSet.second;
752 const OPENTREP::TravelDBFilePath_T& lXapianDBFP = lDBFPPair.first;
753 const OPENTREP::SQLDBConnectionString_T& lSQLConnStr = lDBFPPair.second;
754 std::cout << std::endl;
755 std::cout << "Log file-path: " << "\t\t\t\t\t" << lLogFilename
756 << std::endl;
757 std::cout << "POR file-path: " << "\t\t\t\t\t" << lPORFilepathStr
758 << std::endl;
759 std::cout << "Xapian index/database file-path: " << "\t\t"
760 << lXapianDBFP << std::endl;
761 std::cout << "SQL database type: " << "\t\t\t\t" << lDBType.describe()
762 << std::endl;
763 std::cout << "SQL database connection string: " << "\t\t" << lSQLConnStr
764 << std::endl;
765 std::cout << "Deployment number/version: " << "\t\t\t"
766 << lDeploymentNumber << "/"
768 << std::endl;
769 std::cout << "Whether to index NON-IATA-referenced POR: " << "\t"
770 << lIncludeNonIATAPOR << std::endl;
771 std::cout << "Whether to index the POR in Xapian: " << "\t\t"
772 << lShouldIndexPORInXapian << std::endl;
773 std::cout << "Whether to insert the POR in the SQL DB: " << "\t"
774 << lShouldAddPORInSQLDB << std::endl;
775 std::cout << std::endl;
776 break;
777 }
778
779 // /////////////////////////// Help with Examples //////////////////////
780 case Command_T::TUTORIAL: {
781 std::cout << std::endl;
782 std::cout << "Typical succession of commands" << std::endl;
783 std::cout << " -------- " << std::endl;
784 std::cout << "Check with the 'info' command and adjust the various flags:"
785 << std::endl;
786 std::cout << " toggle_deployment_number" << std::endl;
787 std::cout << " toggle_noniata_indexing_flag" << std::endl;
788 std::cout << " toggle_xapian_idexing_flag" << std::endl;
789 std::cout << " toggle_sqldb_inserting_flag" << std::endl;
790 std::cout << std::endl;
791 std::cout << " -------- " << std::endl;
792 std::cout << "Re-indexing of the POR data file:" << std::endl;
793 std::cout << " fill_from_por_file" << std::endl;
794 std::cout << std::endl;
795 std::cout << " -------- " << std::endl;
796 std::cout << "Check the content of the SQL database:" << std::endl;
797 std::cout << " list_nb" << std::endl;
798 std::cout << " list_by_iata nce" << std::endl;
799 std::cout << " list_by_icao lfmn" << std::endl;
800 std::cout << " list_by_faa jfk" << std::endl;
801 std::cout << " list_by_unlocode deham" << std::endl;
802 std::cout << " list_by_uiccode 87775007" << std::endl;
803 std::cout << " list_by_geonameid 6299418" << std::endl;
804 std::cout << std::endl;
805 std::cout << " -------- " << std::endl;
806 std::cout << "Management of the database user and database:" << std::endl;
807 std::cout << "* For PostgreSQL:" << std::endl;
808 std::cout <<" reset_connection_string db=postgres user=$USER password=<passwd>"
809 << std::endl;
810 std::cout << "* For MySQL:" << std::endl;
811 std::cout <<" reset_connection_string db=mysql user=root password=<passwd>"
812 << std::endl;
813 std::cout << " create_user" << std::endl;
814 std::cout <<" reset_connection_string db=trep_trep user=trep password=trep"
815 << std::endl;
816 std::cout << " create_tables" << std::endl;
817 std::cout << " create_indexes" << std::endl;
818 std::cout << std::endl;
819 break;
820 }
821
822 // ////////////////////////////// Quit ////////////////////////
823 case Command_T::QUIT: {
824 break;
825 }
826
827 // ////////////////////////////// List Number /////////////////////////
828 case Command_T::LIST_NB: {
829 // Call the underlying OpenTREP service
830 if (lDBType == OPENTREP::DBType::NODB) {
831 const OPENTREP::NbOfDBEntries_T nbOfEntries =
832 opentrepService.getIndexSize();
833
834 // Reporting
835 std::cout << nbOfEntries
836 << " POR (points of reference) have been found in the Xapian "
837 << "index. Type 'info' to know where that Xapian index is "
838 "located." << std::endl;
839
840 } else {
841 const OPENTREP::NbOfDBEntries_T nbOfEntries =
842 opentrepService.getNbOfPORFromDB();
843
844 // Reporting
845 std::cout << nbOfEntries
846 << " POR (points of reference) have been found in the "
847 << lDBType.describe() << " database" << std::endl;
848 }
849
850 break;
851 }
852
853 // ////////////////////////////// List All /////////////////////////
854 case Command_T::LIST_ALL: {
855 // For now, just hard code a single IATA code.
856 // TODO: implement the page down process, so that the full list
857 // can be retrieved and browsed.
858 const std::string lIataCodeStr ("NCE");
859
860 // Call the underlying OpenTREP service
861 const OPENTREP::IATACode_T lIataCode (lIataCodeStr);
862 OPENTREP::LocationList_T lLocationList;
863 const OPENTREP::NbOfMatches_T nbOfMatches =
864 opentrepService.listByIataCode (lIataCode, lLocationList);
865
866 //
867 std::cout << nbOfMatches << " (geographical) location(s) have been found "
868 << "matching the IATA code ('" << lIataCodeStr << "')."
869 << std::endl;
870
871 if (nbOfMatches != 0) {
873 for (OPENTREP::LocationList_T::const_iterator itLocation =
874 lLocationList.begin();
875 itLocation != lLocationList.end(); ++itLocation, ++idx) {
876 const OPENTREP::Location& lLocation = *itLocation;
877 std::cout << " [" << idx << "]: " << lLocation.toString() << std::endl;
878 }
879
880 } else {
881 std::cout << "List of unmatched words:" << std::endl;
882 std::cout << " [" << 1 << "]: " << lIataCodeStr << std::endl;
883 }
884
885 break;
886 }
887
888 // ////////////////////////// List by IATA code ////////////////////////
890 //
891 TokenList_T lTokenList = extractTokenListForIataCode(lTokenListByReadline);
892
893 // Parse the parameters given by the user, giving default values
894 // in case the user does not specify some (or all) of them
895 std::string lIataCodeStr ("nce");
896 parsePlaceKey (lTokenList, lIataCodeStr);
897
898 // Call the underlying OpenTREP service
899 const OPENTREP::IATACode_T lIataCode (lIataCodeStr);
900 OPENTREP::LocationList_T lLocationList;
901 const OPENTREP::NbOfMatches_T nbOfMatches =
902 opentrepService.listByIataCode (lIataCode, lLocationList);
903
904 //
905 std::cout << nbOfMatches << " (geographical) location(s) have been found "
906 << "matching the IATA code ('" << lIataCodeStr << "')."
907 << std::endl;
908
909 if (nbOfMatches != 0) {
911 for (OPENTREP::LocationList_T::const_iterator itLocation =
912 lLocationList.begin();
913 itLocation != lLocationList.end(); ++itLocation, ++idx) {
914 const OPENTREP::Location& lLocation = *itLocation;
915 std::cout << " [" << idx << "]: " << lLocation << std::endl;
916 }
917
918 } else {
919 std::cout << "List of unmatched words:" << std::endl;
920 std::cout << " [" << 1 << "]: " << lIataCodeStr << std::endl;
921 }
922
923 break;
924 }
925
926 // ////////////////////////// List by ICAO code ////////////////////////
928 //
929 TokenList_T lTokenList = extractTokenListForIcaoCode(lTokenListByReadline);
930
931 // Parse the parameters given by the user, giving default values
932 // in case the user does not specify some (or all) of them
933 std::string lIcaoCodeStr ("lfmn");
934 parsePlaceKey (lTokenList, lIcaoCodeStr);
935
936 // Call the underlying OpenTREP service
937 const OPENTREP::ICAOCode_T lIcaoCode (lIcaoCodeStr);
938 OPENTREP::LocationList_T lLocationList;
939 const OPENTREP::NbOfMatches_T nbOfMatches =
940 opentrepService.listByIcaoCode (lIcaoCode, lLocationList);
941
942 //
943 std::cout << nbOfMatches << " (geographical) location(s) have been found "
944 << "matching the ICAO code ('" << lIcaoCodeStr << "')."
945 << std::endl;
946
947 if (nbOfMatches != 0) {
949 for (OPENTREP::LocationList_T::const_iterator itLocation =
950 lLocationList.begin();
951 itLocation != lLocationList.end(); ++itLocation, ++idx) {
952 const OPENTREP::Location& lLocation = *itLocation;
953 std::cout << " [" << idx << "]: " << lLocation << std::endl;
954 }
955
956 } else {
957 std::cout << "List of unmatched words:" << std::endl;
958 std::cout << " [" << 1 << "]: " << lIcaoCodeStr << std::endl;
959 }
960
961 break;
962 }
963
964 // ////////////////////////// List by FAA code ////////////////////////
966 //
967 TokenList_T lTokenList = extractTokenListForFaaCode(lTokenListByReadline);
968
969 // Parse the parameters given by the user, giving default values
970 // in case the user does not specify some (or all) of them
971 std::string lFaaCodeStr ("jfk");
972 parsePlaceKey (lTokenList, lFaaCodeStr);
973
974 // Call the underlying OpenTREP service
975 const OPENTREP::FAACode_T lFaaCode (lFaaCodeStr);
976 OPENTREP::LocationList_T lLocationList;
977 const OPENTREP::NbOfMatches_T nbOfMatches =
978 opentrepService.listByFaaCode (lFaaCode, lLocationList);
979
980 //
981 std::cout << nbOfMatches << " (geographical) location(s) have been found "
982 << "matching the FAA code ('" << lFaaCodeStr << "')."
983 << std::endl;
984
985 if (nbOfMatches != 0) {
987 for (OPENTREP::LocationList_T::const_iterator itLocation =
988 lLocationList.begin();
989 itLocation != lLocationList.end(); ++itLocation, ++idx) {
990 const OPENTREP::Location& lLocation = *itLocation;
991 std::cout << " [" << idx << "]: " << lLocation << std::endl;
992 }
993
994 } else {
995 std::cout << "List of unmatched words:" << std::endl;
996 std::cout << " [" << 1 << "]: " << lFaaCodeStr << std::endl;
997 }
998
999 break;
1000 }
1001
1002 // //////////////////////// List by UN/LOCODE code //////////////////////
1004 //
1005 TokenList_T lTokenList = extractTokenListForUNLOCode(lTokenListByReadline);
1006
1007 // Parse the parameters given by the user, giving default values
1008 // in case the user does not specify some (or all) of them
1009 std::string lUNLOCodeStr ("deham");
1010 parsePlaceKey (lTokenList, lUNLOCodeStr);
1011
1012 // Call the underlying OpenTREP service
1013 const OPENTREP::UNLOCode_T lUNLOCode (lUNLOCodeStr);
1014 OPENTREP::LocationList_T lLocationList;
1015 const OPENTREP::NbOfMatches_T nbOfMatches =
1016 opentrepService.listByUNLOCode (lUNLOCode, lLocationList);
1017
1018 //
1019 std::cout << nbOfMatches << " (geographical) location(s) have been found "
1020 << "matching the UN/LOCODE code ('" << lUNLOCodeStr << "')."
1021 << std::endl;
1022
1023 if (nbOfMatches != 0) {
1025 for (OPENTREP::LocationList_T::const_iterator itLocation =
1026 lLocationList.begin();
1027 itLocation != lLocationList.end(); ++itLocation, ++idx) {
1028 const OPENTREP::Location& lLocation = *itLocation;
1029 std::cout << " [" << idx << "]: " << lLocation << std::endl;
1030 }
1031
1032 } else {
1033 std::cout << "List of unmatched words:" << std::endl;
1034 std::cout << " [" << 1 << "]: " << lUNLOCodeStr << std::endl;
1035 }
1036
1037 break;
1038 }
1039
1040 // //////////////////////// List by UIC code //////////////////////
1042 //
1043 TokenList_T lTokenList = extractTokenListForUICCode(lTokenListByReadline);
1044
1045 // Parse the parameters given by the user, giving default values
1046 // in case the user does not specify some (or all) of them
1047 std::string lUICCodeStr ("87775007");
1048 parsePlaceKey (lTokenList, lUICCodeStr);
1049
1050 // Convert the string into an integer
1051 OPENTREP::UICCode_T lUICCode;
1052
1053 try {
1054
1055 lUICCode = boost::lexical_cast<OPENTREP::UICCode_T> (lUICCodeStr);
1056
1057 } catch (boost::bad_lexical_cast& eCast) {
1058 lUICCode = 87775007;
1059 std::cerr << "The UIC code ('" << lUICCodeStr
1060 << "') cannot be understood. The default value ("
1061 << lUICCode << ") is kept." << std::endl;
1062 }
1063
1064 // Call the underlying OpenTREP service
1065 OPENTREP::LocationList_T lLocationList;
1066 const OPENTREP::NbOfMatches_T nbOfMatches =
1067 opentrepService.listByUICCode (lUICCode, lLocationList);
1068
1069 //
1070 std::cout << nbOfMatches << " (geographical) location(s) have been found "
1071 << "matching the UIC code ('" << lUICCodeStr << "')."
1072 << std::endl;
1073
1074 if (nbOfMatches != 0) {
1076 for (OPENTREP::LocationList_T::const_iterator itLocation =
1077 lLocationList.begin();
1078 itLocation != lLocationList.end(); ++itLocation, ++idx) {
1079 const OPENTREP::Location& lLocation = *itLocation;
1080 std::cout << " [" << idx << "]: " << lLocation << std::endl;
1081 }
1082
1083 } else {
1084 std::cout << "List of unmatched words:" << std::endl;
1085 std::cout << " [" << 1 << "]: " << lUICCodeStr << std::endl;
1086 }
1087
1088 break;
1089 }
1090
1091 // ////////////////////////// List by Geoname ID ////////////////////////
1093 //
1094 TokenList_T lTokenList =
1095 extractTokenListForGeonameID (lTokenListByReadline);
1096
1097 // Parse the parameters given by the user, giving default values
1098 // in case the user does not specify some (or all) of them
1099 std::string lGeonameIDStr ("6299418");
1100 parsePlaceKey (lTokenList, lGeonameIDStr);
1101
1102 // Convert the string into an integer
1103 OPENTREP::GeonamesID_T lGeonameID;
1104
1105 try {
1106
1107 lGeonameID = boost::lexical_cast<OPENTREP::GeonamesID_T> (lGeonameIDStr);
1108
1109 } catch (boost::bad_lexical_cast& eCast) {
1110 lGeonameID = 6299418;
1111 std::cerr << "The Geoname ID ('" << lGeonameIDStr
1112 << "') cannot be understood. The default value ("
1113 << lGeonameID << ") is kept." << std::endl;
1114 }
1115
1116 // Call the underlying OpenTREP service
1117 OPENTREP::LocationList_T lLocationList;
1118 const OPENTREP::NbOfMatches_T nbOfMatches =
1119 opentrepService.listByGeonameID (lGeonameID, lLocationList);
1120
1121 //
1122 std::cout << nbOfMatches << " (geographical) location(s) have been found "
1123 << "matching the Geoname ID ('" << lGeonameIDStr << "')."
1124 << std::endl;
1125
1126 if (nbOfMatches != 0) {
1128 for (OPENTREP::LocationList_T::const_iterator itLocation =
1129 lLocationList.begin();
1130 itLocation != lLocationList.end(); ++itLocation, ++idx) {
1131 const OPENTREP::Location& lLocation = *itLocation;
1132 std::cout << " [" << idx << "]: " << lLocation << std::endl;
1133 }
1134
1135 } else {
1136 std::cout << "List of unmatched items:" << std::endl;
1137 std::cout << " [" << 1 << "]: " << lGeonameIDStr << std::endl;
1138 }
1139
1140 break;
1141 }
1142
1143 // ///////////////////////// Database Creation /////////////////////////
1145 //
1146 std::cout << "Creating the 'trep' user and 'trep_trep' database"
1147 << std::endl;
1148
1149 // On MySQL/MariaDB and PostgreSQL, create the 'trep' user and 'trep_trep'
1150 // database.
1151 // On SQLite, delete the directory hosting the database, and re-create it.
1152 // On other database types, do nothing.
1153 const bool lCreationSuccessful = opentrepService.createSQLDBUser();
1154
1155 // Reporting
1156 if (lCreationSuccessful == true) {
1157 std::cout << "The 'trep' user and 'trep_trep' database have been created"
1158 << std::endl;
1159 }
1160
1161 break;
1162 }
1163
1164 // ///////////////////// Database connection string //////////////////////
1166 // Parse the parameters given by the user, giving default values
1167 // in case the user does not specify some (or all) of them
1168 const std::string lConnectionStringStr = toString (lTokenListByReadline);
1169
1170 //
1171 std::cout << "Reset the connection string" << std::endl;
1172
1173 // Reset the connection string
1175 lConnectionString (lConnectionStringStr);
1176 opentrepService.setSQLDBConnectString (lConnectionString);
1177
1178 //
1179 std::cout << "The connection string has been reset" << std::endl;
1180
1181 break;
1182 }
1183
1184 // /////////////////// Deployment number/version /////////////////////
1186 // Toggle the deployment number/version
1187 lDeploymentNumber = opentrepService.toggleDeploymentNumber();
1188
1189 // Reporting
1190 std::cout << "The new deployment number/version is: " << lDeploymentNumber
1192 << std::endl;
1193
1194 break;
1195 }
1196
1197 // /////////////////// Index or not non-IATA POR /////////////////////
1199 // Toggle the flag
1200 lIncludeNonIATAPOR = opentrepService.toggleShouldIncludeAllPORFlag();
1201
1202 // Reporting
1203 std::cout << "The new flag is: " << lIncludeNonIATAPOR << std::endl;
1204
1205 break;
1206 }
1207
1208 // ///////////////////// Index or not in Xapian ///////////////////////
1210 // Toggle the flag
1211 lShouldIndexPORInXapian =
1212 opentrepService.toggleShouldIndexPORInXapianFlag();
1213
1214 // Reporting
1215 std::cout << "The new flag is: " << lShouldIndexPORInXapian << std::endl;
1216
1217 break;
1218 }
1219
1220 // ///////////////////// Add or not in SQL DB ///////////////////////
1222 // Toggle the flag
1223 lShouldAddPORInSQLDB = opentrepService.toggleShouldAddPORInSQLDBFlag();
1224
1225 // Reporting
1226 std::cout << "The new flag is: " << lShouldAddPORInSQLDB << std::endl;
1227
1228 break;
1229 }
1230
1231 // ///////////////////////// Tables Creation /////////////////////////
1233 //
1234 std::cout << "Creating/resetting the " << lDBType.describe()
1235 << " database tables" << std::endl;
1236
1237 // Create/reset the tables (on SQLite3, PostgreSQL, MySQL)
1238 opentrepService.createSQLDBTables();
1239
1240 //
1241 std::cout << "The " << lDBType.describe()
1242 << " tables has been created/resetted" << std::endl;
1243
1244 break;
1245 }
1246
1247 // ///////////////////////// Indexes Creation /////////////////////////
1249 //
1250 std::cout << "Creating/resetting the " << lDBType.describe()
1251 << " database indices" << std::endl;
1252
1253 // Create/reset the indices (on SQLite3, PostgreSQL, MySQL)
1254 opentrepService.createSQLDBIndexes();
1255
1256 //
1257 std::cout << "The " << lDBType.describe()
1258 << " indices has been created/resetted" << std::endl;
1259
1260 break;
1261 }
1262
1263 // ///////////////////////// POR File Indexing /////////////////////////
1265 //
1266 std::cout << "Indexing the POR file and filling in the SQL database may "
1267 << "take a few minutes on some architectures "
1268 << "(and a few seconds on fastest ones)..."
1269 << std::endl;
1270
1271 // Launch the indexation
1272 const OPENTREP::NbOfDBEntries_T lNbOfEntries =
1273 opentrepService.insertIntoDBAndXapian();
1274
1275 //
1276 std::cout << lNbOfEntries << " entries have been processed" << std::endl;
1277
1278 break;
1279 }
1280
1281 // /////////////////////////// Default / No value ///////////////////////
1282 case Command_T::NOP: {
1283 break;
1284 }
1285
1287 default: {
1288 // DEBUG
1289 std::ostringstream oStr;
1290 oStr << "That command is not yet understood: '" << lUserInput
1291 << "' => " << lTokenListByReadline;
1292 OPENTREP_LOG_DEBUG (oStr.str());
1293 std::cout << oStr.str() << std::endl;
1294 }
1295 }
1296 }
1297
1298 // DEBUG
1299 OPENTREP_LOG_DEBUG ("End of the session. Exiting.");
1300 std::cout << "End of the session. Exiting." << std::endl;
1301
1302 // Close the Log outputFile
1303 logOutputFile.close();
1304
1305 return 0;
1306}
#define OPENTREP_LOG_DEBUG(iToBeLogged)
Definition Logger.hpp:33
C++ wrapper around libreadline.
Interface for the OPENTREP Services.
NbOfMatches_T listByIataCode(const IATACode_T &, LocationList_T &)
NbOfMatches_T listByUNLOCode(const UNLOCode_T &, LocationList_T &)
void setSQLDBConnectString(const SQLDBConnectionString_T &)
OPENTREP::shouldIndexNonIATAPOR_T toggleShouldIncludeAllPORFlag()
std::pair< const PORFilePath_T, const DBFilePathPair_T > FilePathSet_T
FilePathSet_T getFilePaths() const
NbOfMatches_T listByFaaCode(const FAACode_T &, LocationList_T &)
NbOfMatches_T listByUICCode(const UICCode_T &, LocationList_T &)
NbOfMatches_T listByIcaoCode(const ICAOCode_T &, LocationList_T &)
NbOfMatches_T listByGeonameID(const GeonamesID_T &, LocationList_T &)
OPENTREP::shouldIndexPORInXapian_T toggleShouldIndexPORInXapianFlag()
std::pair< const TravelDBFilePath_T, const SQLDBConnectionString_T > DBFilePathPair_T
NbOfDBEntries_T insertIntoDBAndXapian()
OPENTREP::DeploymentNumber_T toggleDeploymentNumber()
OPENTREP::shouldAddPORInSQLDB_T toggleShouldAddPORInSQLDBFlag()
The readline library wrapper.
bool SaveHistory(std::ostream &OS)
Saves the history to the given file stream.
std::string GetLine(const std::string &Prompt)
Gets a single line from a user.
void RegisterCompletions(const ContainerType &Container)
Allows to register custom completers.
const std::string DEFAULT_OPENTREP_SQLITE_DB_FILEPATH
unsigned int UICCode_T
const std::string DEFAULT_OPENTREP_PG_CONN_STRING
bool shouldAddPORInSQLDB_T
const unsigned short DEFAULT_OPENTREP_DEPLOYMENT_NUMBER_SIZE
unsigned int NbOfDBEntries_T
const bool DEFAULT_OPENTREP_INCLUDE_NONIATA_POR
const std::string DEFAULT_OPENTREP_SQL_DB_TYPE
std::string parseAndDisplayConnectionString(const DBType &iDBType, const std::string &iSQLDBConnStr, const DeploymentNumber_T &iDeploymentNumber)
std::list< Location > LocationList_T
const bool DEFAULT_OPENTREP_INDEX_IN_XAPIAN
const unsigned short DEFAULT_OPENTREP_DEPLOYMENT_NUMBER
bool shouldIndexPORInXapian_T
const std::string DEFAULT_OPENTREP_MYSQL_CONN_STRING
unsigned short DeploymentNumber_T
const std::string DEFAULT_OPENTREP_XAPIAN_DB_FILEPATH
unsigned short NbOfMatches_T
const bool DEFAULT_OPENTREP_ADD_IN_DB
unsigned int GeonamesID_T
const std::string DEFAULT_OPENTREP_POR_FILEPATH
bool shouldIndexNonIATAPOR_T
int main(int argc, char *argv[])
void parseConnectionString(const TokenList_T &iTokenList, std::string &ioConnectionString)
TokenList_T extractTokenListForIataCode(const TokenList_T &iTokenList)
TokenList_T extractTokenListForIcaoCode(const TokenList_T &iTokenList)
std::string toString(const TokenList_T &iTokenList)
TokenList_T extractTokenList(const TokenList_T &iTokenList, const std::string &iRegularExpression)
const std::string K_OPENTREP_DEFAULT_LOG_FILENAME("opentrep-dbmgr.log")
void parsePlaceKey(const TokenList_T &iTokenList, std::string &ioPlaceKey)
std::ostream & operator<<(std::ostream &os, const std::vector< T > &v)
TokenList_T extractTokenListForGeonameID(const TokenList_T &iTokenList)
TokenList_T extractTokenListForFaaCode(const TokenList_T &iTokenList)
void initReadline(swift::SReadline &ioInputReader)
int readConfiguration(int argc, char *argv[], std::string &ioPORFilepath, std::string &ioXapianDBFilepath, std::string &ioSQLDBTypeString, std::string &ioSQLDBConnectionString, unsigned short &ioDeploymentNumber, bool &ioIncludeNonIATAPOR, bool &ioIndexPORInXapian, bool &ioAddPORInDB, std::string &ioLogFilename)
TokenList_T extractTokenListForUNLOCode(const TokenList_T &iTokenList)
TokenList_T extractTokenListForUICCode(const TokenList_T &iTokenList)
Command_T::Type_T extractCommand(TokenList_T &ioTokenList)
std::vector< std::string > TokenList_T
const int K_OPENTREP_EARLY_RETURN_STATUS
std::vector< std::string > WordList_T
const std::string K_OPENTREP_DEFAULT_LOG_FILENAME("opentrep-indexer.log")
@ TOGGLE_XAPIAN_IDEXING_FLAG
@ TOGGLE_SQLDB_INSERTING_FLAG
@ TOGGLE_NONIATA_INDEXING_FLAG
Enumeration of database types.
Definition DBType.hpp:17
const std::string describe() const
Definition DBType.cpp:135
Structure modelling a (geographical) location.
Definition Location.hpp:25
std::string toString() const
Definition Location.cpp:282