OpenTREP Logo  0.07.18
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)")
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)")
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::MYSQL) {
228 ioAddPORInDB = true;
229 ioSQLDBConnectionString = OPENTREP::DEFAULT_OPENTREP_MYSQL_CONN_STRING;
230 }
231
232 // Set the SQL database connection string, if any is given
233 if (vm.count ("sqldbconx")) {
234 ioSQLDBConnectionString = vm["sqldbconx"].as< std::string >();
235 }
236
237 // Reporting of the SQL database connection string
238 if (lDBType == OPENTREP::DBType::SQLITE3
239 || lDBType == OPENTREP::DBType::MYSQL) {
240 const std::string& lSQLDBConnString =
242 ioSQLDBConnectionString,
243 ioDeploymentNumber);
244 //
245 std::cout << "SQL database connection string is: " << lSQLDBConnString
246 << std::endl;
247 }
248
249 std::cout << "Are non-IATA-referenced POR included? "
250 << ioIncludeNonIATAPOR << std::endl;
251
252 std::cout << "Index the POR in Xapian? "
253 << ioIndexPORInXapian << std::endl;
254
255 std::cout << "Add and re-index the POR in the SQL-based database? "
256 << ioAddPORInDB << std::endl;
257
258 if (vm.count ("log")) {
259 ioLogFilename = vm["log"].as< std::string >();
260 }
261
262 // Information
263 std::cout << "Type the 'info' command to get a few details (e.g., file-path)"
264 << std::endl;
265
266 return 0;
267}
268
269// //////////////////////////////////////////////////////////////////
270void initReadline (swift::SReadline& ioInputReader) {
271
272 // Prepare the list of my own completers
273 std::vector<std::string> Completers;
274
275 // The following is supported:
276 // - "identifiers"
277 // - special identifier %file - means to perform a file name completion
278 Completers.push_back ("help");
279 Completers.push_back ("info");
280 Completers.push_back ("tutorial");
281 Completers.push_back ("create_user");
282 Completers.push_back ("reset_connection_string %connection_string");
283 Completers.push_back ("create_tables");
284 Completers.push_back ("create_indexes");
285 Completers.push_back ("toggle_deployment_number");
286 Completers.push_back ("toggle_noniata_indexing_flag");
287 Completers.push_back ("toggle_xapian_idexing_flag");
288 Completers.push_back ("toggle_sqldb_inserting_flag");
289 Completers.push_back ("fill_from_por_file");
290 Completers.push_back ("list_by_iata %iata_code");
291 Completers.push_back ("list_by_icao %icao_code");
292 Completers.push_back ("list_by_faa %faa_code");
293 Completers.push_back ("list_by_unlocode %unlocode_code");
294 Completers.push_back ("list_by_uiccode %uic_code");
295 Completers.push_back ("list_by_geonameid %geoname_id");
296 Completers.push_back ("list_nb");
297 Completers.push_back ("list_all");
298 Completers.push_back ("list_cont");
299 Completers.push_back ("quit");
300
301 // Now register the completers.
302 // Actually it is possible to re-register another set at any time
303 ioInputReader.RegisterCompletions (Completers);
304}
305
306// //////////////////////////////////////////////////////////////////
309
310 // Interpret the user input
311 if (ioTokenList.empty() == false) {
312 TokenList_T::iterator itTok = ioTokenList.begin();
313 std::string lCommand (*itTok);
314 boost::algorithm::to_lower (lCommand);
315 if (lCommand == "help") {
316 oCommandType = Command_T::HELP;
317
318 } else if (lCommand == "info") {
319 oCommandType = Command_T::INFO;
320
321 } else if (lCommand == "tutorial") {
322 oCommandType = Command_T::TUTORIAL;
323
324 } else if (lCommand == "create_user") {
325 oCommandType = Command_T::CREATE_USER;
326
327 } else if (lCommand == "reset_connection_string") {
329
330 } else if (lCommand == "create_tables") {
331 oCommandType = Command_T::CREATE_TABLES;
332
333 } else if (lCommand == "create_indexes") {
334 oCommandType = Command_T::CREATE_INDEXES;
335
336 } else if (lCommand == "toggle_deployment_number") {
338
339 } else if (lCommand == "toggle_noniata_indexing_flag") {
341
342 } else if (lCommand == "toggle_xapian_idexing_flag") {
344
345 } else if (lCommand == "toggle_sqldb_inserting_flag") {
347
348 } else if (lCommand == "fill_from_por_file") {
349 oCommandType = Command_T::FILL_FROM_POR_FILE;
350
351 } else if (lCommand == "list_by_iata") {
352 oCommandType = Command_T::LIST_BY_IATA;
353
354 } else if (lCommand == "list_by_icao") {
355 oCommandType = Command_T::LIST_BY_ICAO;
356
357 } else if (lCommand == "list_by_faa") {
358 oCommandType = Command_T::LIST_BY_FAA;
359
360 } else if (lCommand == "list_by_unlocode") {
361 oCommandType = Command_T::LIST_BY_UNLOCODE;
362
363 } else if (lCommand == "list_by_uiccode") {
364 oCommandType = Command_T::LIST_BY_UICCODE;
365
366 } else if (lCommand == "list_by_geonameid") {
367 oCommandType = Command_T::LIST_BY_GEONAMEID;
368
369 } else if (lCommand == "list_nb") {
370 oCommandType = Command_T::LIST_NB;
371
372 } else if (lCommand == "list_all") {
373 oCommandType = Command_T::LIST_ALL;
374
375 } else if (lCommand == "list_cont") {
376 oCommandType = Command_T::LIST_CONT;
377
378 } else if (lCommand == "quit") {
379 oCommandType = Command_T::QUIT;
380 }
381
382 // Remove the first token (the command), as the corresponding information
383 // has been extracted in the form of the returned command type enumeration
384 ioTokenList.erase (itTok);
385
386 } else {
387 oCommandType = Command_T::NOP;
388 }
389
390 return oCommandType;
391}
392
393// //////////////////////////////////////////////////////////////////
394void parseConnectionString (const TokenList_T& iTokenList,
395 std::string& ioConnectionString) {
396 // Interpret the user input
397 if (iTokenList.empty() == false) {
398
399 // Read the database connection string
400 TokenList_T::const_iterator itTok = iTokenList.begin();
401 if (itTok->empty() == false) {
402 ioConnectionString = *itTok;
403 }
404 }
405}
406
407// //////////////////////////////////////////////////////////////////
408void parsePlaceKey (const TokenList_T& iTokenList, std::string& ioPlaceKey) {
409 // Interpret the user input
410 if (iTokenList.empty() == false) {
411
412 // Read the IATA code
413 TokenList_T::const_iterator itTok = iTokenList.begin();
414 if (itTok->empty() == false) {
415 ioPlaceKey = *itTok;
416 }
417 }
418}
419
420// /////////////////////////////////////////////////////////
421std::string toString (const TokenList_T& iTokenList) {
422 std::ostringstream oStr;
423
424 // Re-create the string with all the tokens, trimmed by read-line
425 unsigned short idx = 0;
426 for (TokenList_T::const_iterator itTok = iTokenList.begin();
427 itTok != iTokenList.end(); ++itTok, ++idx) {
428 if (idx != 0) {
429 oStr << " ";
430 }
431 oStr << *itTok;
432 }
433
434 return oStr.str();
435}
436
437// /////////////////////////////////////////////////////////
439 const std::string& iRegularExpression) {
440 TokenList_T oTokenList;
441
442 // Re-create the string with all the tokens (which had been trimmed
443 // by read-line)
444 const std::string lFullLine = toString (iTokenList);
445
446 // See the caller for the regular expression
447 boost::regex expression (iRegularExpression);
448
449 std::string::const_iterator start = lFullLine.begin();
450 std::string::const_iterator end = lFullLine.end();
451
452 boost::match_results<std::string::const_iterator> what;
453 boost::match_flag_type flags = boost::match_default | boost::format_sed;
454 regex_search (start, end, what, expression, flags);
455
456 // Put the matched strings in the list of tokens to be returned back
457 // to the caller
458 const unsigned short lMatchSetSize = what.size();
459 for (unsigned short matchIdx = 1; matchIdx != lMatchSetSize; ++matchIdx) {
460 const std::string lMatchedString (std::string (what[matchIdx].first,
461 what[matchIdx].second));
462 //if (lMatchedString.empty() == false) {
463 oTokenList.push_back (lMatchedString);
464 //}
465 }
466
467 // DEBUG
468 // std::cout << "After (token list): " << oTokenList << std::endl;
469
470 return oTokenList;
471}
472
473// /////////////////////////////////////////////////////////
480 const std::string lRegEx ("^([[:alpha:]]{3})$");
481
482 //
483 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
484 return oTokenList;
485}
486
487// /////////////////////////////////////////////////////////
494 const std::string lRegEx ("^(([[:alpha:]]|[[:digit:]]){4})$");
495
496 //
497 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
498 return oTokenList;
499}
500
501// /////////////////////////////////////////////////////////
508 const std::string lRegEx ("^(([[:alpha:]]|[[:digit:]]){3,4})$");
509
510 //
511 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
512 return oTokenList;
513}
514
515// /////////////////////////////////////////////////////////
522 const std::string lRegEx ("^(([[:alpha:]]|[[:digit:]]){5})$");
523
524 //
525 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
526 return oTokenList;
527}
528
529// /////////////////////////////////////////////////////////
536 const std::string lRegEx ("^([[:digit:]]{1,11})$");
537
538 //
539 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
540 return oTokenList;
541}
542
543// /////////////////////////////////////////////////////////
550 const std::string lRegEx ("^([[:digit:]]{1,11})$");
551
552 //
553 const TokenList_T& oTokenList = extractTokenList (iTokenList, lRegEx);
554 return oTokenList;
555}
556
557
558// /////////////// M A I N /////////////////
559int main (int argc, char* argv[]) {
560
561 // Readline history
562 const unsigned int lHistorySize (100);
563 const std::string lHistoryFilename ("opentrep-dbmgr.hist");
564 const std::string lHistoryBackupFilename ("opentrep-dbmgr.hist.bak");
565
566 // Output log File
567 std::string lLogFilename;
568
569 // File-path of POR (points of reference)
570 std::string lPORFilepathStr;
571
572 // Xapian database name (directory of the index)
573 std::string lXapianDBNameStr;
574
575 // SQL database type
576 std::string lSQLDBTypeStr;
577
578 // SQL database connection string
579 std::string lSQLDBConnectionStr;
580
581 // Deployment number/version
582 OPENTREP::DeploymentNumber_T lDeploymentNumber;
583
584 // Whether or not to include non-IATA-referenced POR
585 OPENTREP::shouldIndexNonIATAPOR_T lIncludeNonIATAPOR;
586
587 // Whether or not to index the POR in Xapian
588 OPENTREP::shouldIndexPORInXapian_T lShouldIndexPORInXapian;
589
590 // Whether or not to insert the POR in the SQL database
591 OPENTREP::shouldAddPORInSQLDB_T lShouldAddPORInSQLDB;
592
593 // Call the command-line option parser
594 const int lOptionParserStatus =
595 readConfiguration (argc, argv, lPORFilepathStr, lXapianDBNameStr,
596 lSQLDBTypeStr, lSQLDBConnectionStr, lDeploymentNumber,
597 lIncludeNonIATAPOR, lShouldIndexPORInXapian,
598 lShouldAddPORInSQLDB, lLogFilename);
599
600 if (lOptionParserStatus == K_OPENTREP_EARLY_RETURN_STATUS) {
601 return 0;
602 }
603
604 // Set the log parameters
605 std::ofstream logOutputFile;
606 // open and clean the log outputfile
607 logOutputFile.open (lLogFilename.c_str());
608 logOutputFile.clear();
609
610 // Initialise the context
611 const OPENTREP::PORFilePath_T lPORFilepath (lPORFilepathStr);
612 const OPENTREP::TravelDBFilePath_T lXapianDBName (lXapianDBNameStr);
613 const OPENTREP::DBType lDBType (lSQLDBTypeStr);
614 const OPENTREP::SQLDBConnectionString_T lSQLDBConnStr (lSQLDBConnectionStr);
615 OPENTREP::OPENTREP_Service opentrepService (logOutputFile, lPORFilepath,
616 lXapianDBName,
617 lDBType, lSQLDBConnStr,
618 lDeploymentNumber,
619 lIncludeNonIATAPOR,
620 lShouldIndexPORInXapian,
621 lShouldAddPORInSQLDB);
622
623 // DEBUG
624 OPENTREP_LOG_DEBUG ("====================================================");
625 OPENTREP_LOG_DEBUG ("= Beginning of the interactive session =");
626 OPENTREP_LOG_DEBUG ("====================================================");
627
628 // Initialise the GNU readline wrapper
629 swift::SReadline lReader (lHistoryFilename, lHistorySize);
630 initReadline (lReader);
631
632 // Now we can ask user for a line
633 std::string lUserInput;
634 bool EndOfInput (false);
635 Command_T::Type_T lCommandType (Command_T::NOP);
636
637 while (lCommandType != Command_T::QUIT && EndOfInput == false) {
638 // Prompt
639 std::ostringstream oPromptStr;
640 oPromptStr << "opentrep> ";
641
642 // Call read-line, which will fill the list of tokens
643 TokenList_T lTokenListByReadline;
644 lUserInput = lReader.GetLine (oPromptStr.str(), lTokenListByReadline,
645 EndOfInput);
646
647 // The history can be saved to an arbitrary file at any time
648 lReader.SaveHistory (lHistoryBackupFilename);
649
650 // The end-of-input typically corresponds to a CTRL-D typed by the user
651 if (EndOfInput) {
652 std::cout << std::endl;
653 break;
654 }
655
656 // Interpret the user input
657 lCommandType = extractCommand (lTokenListByReadline);
658
659 switch (lCommandType) {
660
661 // ////////////////////////////// Help ////////////////////////
662 case Command_T::HELP: {
663 std::cout << std::endl;
664 std::cout << "Commands: " << std::endl;
665 std::cout << " CTRL-L (Control and L keys)" << "\t" << "Clean the screen"
666 << std::endl;
667 std::cout << " help" << "\t\t\t\t" << "Display this help" << std::endl;
668 std::cout << " info" << "\t\t\t\t"
669 << "Display details for the current session "
670 << "(e.g., file-paths for the log file, SQL database)"
671 << std::endl;
672 std::cout << " tutorial" << "\t\t\t" << "Display examples" << std::endl;
673 std::cout << " quit" << "\t\t\t\t" << "Quit the application" << std::endl;
674 std::cout << " create_user" << "\t\t\t"
675 << "On SQL database, create the 'trep' user and the 'trep_trep' "
676 << "database. SQL database administrative rights are required."
677 << std::endl;
678 std::cout << " reset_connection_string" << "\t"
679 << "Reset/update the connection string to a MySQL database."
680 << " The connection string must be given"
681 << std::endl;
682 std::cout << " create_tables" << "\t\t\t"
683 << "Create/reset the SQL database (eg, SQLite3, MySQL) tables"
684 << std::endl;
685 std::cout << " create_indexes" << "\t\t\t"
686 << "Create/reset the SQL database (eg, SQLite3, MySQL) indices"
687 << std::endl;
688 std::cout << " toggle_deployment_number" << "\t"
689 << "Toggle the deployment number/version. "
690 << "To see the deployment version/number, type 'info'"
691 << std::endl;
692 std::cout << " toggle_noniata_indexing_flag" << "\t"
693 << "Toggle the flag for the indexing (or not) of the non-IATA referenced POR."
694 << " To see the flag, type 'info'"
695 << std::endl;
696 std::cout << " toggle_xapian_idexing_flag" << "\t"
697 << "Toggle the flag for the Xapian indexing (or not) of the POR."
698 << " To see the flag, type 'info'"
699 << std::endl;
700 std::cout << " toggle_sqldb_inserting_flag" << "\t"
701 << "Toggle the flag for inserting (or not) the POR into the SQL database."
702 << " To see the flag, type 'info'"
703 << std::endl;
704 std::cout << " fill_from_por_file" << "\t\t"
705 << "Parse the file of POR and fill-in the SQL database optd_por table."
706 << std::endl << "\t\t\t\t"
707 << "That command (re-)creates both the Xapian index and the SQL tables (as well as the indices), if needed."
708 << std::endl << "\t\t\t\t"
709 << "Note that, as that command takes minutes, the connection to the SQL database may be lost and the program will exit abnormally."
710 << std::endl << "\t\t\t\t"
711 << "In that latter case, just re-execute the program and check how far the indexation went by executing the following command."
712 << std::endl;
713 std::cout << " list_nb" << "\t\t\t"
714 << "Display the number of the entries of the database."
715 << std::endl;
716 std::cout << " list_all" << "\t\t\t"
717 << "List all the entries of the database, page by page."
718 << "Type the 'list_cont' command for a page down" << std::endl;
719 std::cout << " list_by_iata" << "\t\t\t"
720 << "List all the entries for a given IATA code"
721 << std::endl;
722 std::cout << " list_by_icao" << "\t\t\t"
723 << "List all the entries for a given ICAO code"
724 << std::endl;
725 std::cout << " list_by_faa" << "\t\t\t"
726 << "List all the entries for a given FAA code"
727 << std::endl;
728 std::cout << " list_by_unlocode" << "\t\t\t"
729 << "List all the entries for a given UN/LOCODE code"
730 << std::endl;
731 std::cout << " list_by_uiccode" << "\t\t\t"
732 << "List all the entries for a given UIC code"
733 << std::endl;
734 std::cout << " list_by_geonameid" << "\t\t"
735 << "List all the entries for a given Geoname ID"
736 << std::endl;
737 std::cout << std::endl;
738 break;
739 }
740
741 // ////////////////////////////// Information ////////////////////////
742 case Command_T::INFO: {
744 opentrepService.getFilePaths();
746 lFPSet.second;
747 const OPENTREP::TravelDBFilePath_T& lXapianDBFP = lDBFPPair.first;
748 const OPENTREP::SQLDBConnectionString_T& lSQLConnStr = lDBFPPair.second;
749 std::cout << std::endl;
750 std::cout << "Log file-path: " << "\t\t\t\t\t" << lLogFilename
751 << std::endl;
752 std::cout << "POR file-path: " << "\t\t\t\t\t" << lPORFilepathStr
753 << std::endl;
754 std::cout << "Xapian index/database file-path: " << "\t\t"
755 << lXapianDBFP << std::endl;
756 std::cout << "SQL database type: " << "\t\t\t\t" << lDBType.describe()
757 << std::endl;
758 std::cout << "SQL database connection string: " << "\t\t" << lSQLConnStr
759 << std::endl;
760 std::cout << "Deployment number/version: " << "\t\t\t"
761 << lDeploymentNumber << "/"
763 << std::endl;
764 std::cout << "Whether to index NON-IATA-referenced POR: " << "\t"
765 << lIncludeNonIATAPOR << std::endl;
766 std::cout << "Whether to index the POR in Xapian: " << "\t\t"
767 << lShouldIndexPORInXapian << std::endl;
768 std::cout << "Whether to insert the POR in the SQL DB: " << "\t"
769 << lShouldAddPORInSQLDB << std::endl;
770 std::cout << std::endl;
771 break;
772 }
773
774 // /////////////////////////// Help with Examples //////////////////////
775 case Command_T::TUTORIAL: {
776 std::cout << std::endl;
777 std::cout << "Typical succession of commands" << std::endl;
778 std::cout << " -------- " << std::endl;
779 std::cout << "Check with the 'info' command and adjust the various flags:"
780 << std::endl;
781 std::cout << " toggle_deployment_number" << std::endl;
782 std::cout << " toggle_noniata_indexing_flag" << std::endl;
783 std::cout << " toggle_xapian_idexing_flag" << std::endl;
784 std::cout << " toggle_sqldb_inserting_flag" << std::endl;
785 std::cout << std::endl;
786 std::cout << " -------- " << std::endl;
787 std::cout << "Re-indexing of the POR data file:" << std::endl;
788 std::cout << " fill_from_por_file" << std::endl;
789 std::cout << std::endl;
790 std::cout << " -------- " << std::endl;
791 std::cout << "Check the content of the SQL database:" << std::endl;
792 std::cout << " list_nb" << std::endl;
793 std::cout << " list_by_iata nce" << std::endl;
794 std::cout << " list_by_icao lfmn" << std::endl;
795 std::cout << " list_by_faa jfk" << std::endl;
796 std::cout << " list_by_unlocode deham" << std::endl;
797 std::cout << " list_by_uiccode 87775007" << std::endl;
798 std::cout << " list_by_geonameid 6299418" << std::endl;
799 std::cout << std::endl;
800 std::cout << " -------- " << std::endl;
801 std::cout << "Management of the database user and database:" << std::endl;
802 std::cout <<" reset_connection_string db=mysql user=root password=<passwd>"
803 << std::endl;
804 std::cout << " create_user" << std::endl;
805 std::cout <<" reset_connection_string db=trep_trep user=trep password=trep"
806 << std::endl;
807 std::cout << " create_tables" << std::endl;
808 std::cout << " create_indexes" << std::endl;
809 std::cout << std::endl;
810 break;
811 }
812
813 // ////////////////////////////// Quit ////////////////////////
814 case Command_T::QUIT: {
815 break;
816 }
817
818 // ////////////////////////////// List Number /////////////////////////
819 case Command_T::LIST_NB: {
820 // Call the underlying OpenTREP service
821 if (lDBType == OPENTREP::DBType::NODB) {
822 const OPENTREP::NbOfDBEntries_T nbOfEntries =
823 opentrepService.getIndexSize();
824
825 // Reporting
826 std::cout << nbOfEntries
827 << " POR (points of reference) have been found in the Xapian "
828 << "index. Type 'info' to know where that Xapian index is "
829 "located." << std::endl;
830
831 } else {
832 const OPENTREP::NbOfDBEntries_T nbOfEntries =
833 opentrepService.getNbOfPORFromDB();
834
835 // Reporting
836 std::cout << nbOfEntries
837 << " POR (points of reference) have been found in the "
838 << lDBType.describe() << " database" << std::endl;
839 }
840
841 break;
842 }
843
844 // ////////////////////////////// List All /////////////////////////
845 case Command_T::LIST_ALL: {
846 // For now, just hard code a single IATA code.
847 // TODO: implement the page down process, so that the full list
848 // can be retrieved and browsed.
849 const std::string lIataCodeStr ("NCE");
850
851 // Call the underlying OpenTREP service
852 const OPENTREP::IATACode_T lIataCode (lIataCodeStr);
853 OPENTREP::LocationList_T lLocationList;
854 const OPENTREP::NbOfMatches_T nbOfMatches =
855 opentrepService.listByIataCode (lIataCode, lLocationList);
856
857 //
858 std::cout << nbOfMatches << " (geographical) location(s) have been found "
859 << "matching the IATA code ('" << lIataCodeStr << "')."
860 << std::endl;
861
862 if (nbOfMatches != 0) {
864 for (OPENTREP::LocationList_T::const_iterator itLocation =
865 lLocationList.begin();
866 itLocation != lLocationList.end(); ++itLocation, ++idx) {
867 const OPENTREP::Location& lLocation = *itLocation;
868 std::cout << " [" << idx << "]: " << lLocation.toString() << std::endl;
869 }
870
871 } else {
872 std::cout << "List of unmatched words:" << std::endl;
873 std::cout << " [" << 1 << "]: " << lIataCodeStr << std::endl;
874 }
875
876 break;
877 }
878
879 // ////////////////////////// List by IATA code ////////////////////////
881 //
882 TokenList_T lTokenList = extractTokenListForIataCode(lTokenListByReadline);
883
884 // Parse the parameters given by the user, giving default values
885 // in case the user does not specify some (or all) of them
886 std::string lIataCodeStr ("nce");
887 parsePlaceKey (lTokenList, lIataCodeStr);
888
889 // Call the underlying OpenTREP service
890 const OPENTREP::IATACode_T lIataCode (lIataCodeStr);
891 OPENTREP::LocationList_T lLocationList;
892 const OPENTREP::NbOfMatches_T nbOfMatches =
893 opentrepService.listByIataCode (lIataCode, lLocationList);
894
895 //
896 std::cout << nbOfMatches << " (geographical) location(s) have been found "
897 << "matching the IATA code ('" << lIataCodeStr << "')."
898 << std::endl;
899
900 if (nbOfMatches != 0) {
902 for (OPENTREP::LocationList_T::const_iterator itLocation =
903 lLocationList.begin();
904 itLocation != lLocationList.end(); ++itLocation, ++idx) {
905 const OPENTREP::Location& lLocation = *itLocation;
906 std::cout << " [" << idx << "]: " << lLocation << std::endl;
907 }
908
909 } else {
910 std::cout << "List of unmatched words:" << std::endl;
911 std::cout << " [" << 1 << "]: " << lIataCodeStr << std::endl;
912 }
913
914 break;
915 }
916
917 // ////////////////////////// List by ICAO code ////////////////////////
919 //
920 TokenList_T lTokenList = extractTokenListForIcaoCode(lTokenListByReadline);
921
922 // Parse the parameters given by the user, giving default values
923 // in case the user does not specify some (or all) of them
924 std::string lIcaoCodeStr ("lfmn");
925 parsePlaceKey (lTokenList, lIcaoCodeStr);
926
927 // Call the underlying OpenTREP service
928 const OPENTREP::ICAOCode_T lIcaoCode (lIcaoCodeStr);
929 OPENTREP::LocationList_T lLocationList;
930 const OPENTREP::NbOfMatches_T nbOfMatches =
931 opentrepService.listByIcaoCode (lIcaoCode, lLocationList);
932
933 //
934 std::cout << nbOfMatches << " (geographical) location(s) have been found "
935 << "matching the ICAO code ('" << lIcaoCodeStr << "')."
936 << std::endl;
937
938 if (nbOfMatches != 0) {
940 for (OPENTREP::LocationList_T::const_iterator itLocation =
941 lLocationList.begin();
942 itLocation != lLocationList.end(); ++itLocation, ++idx) {
943 const OPENTREP::Location& lLocation = *itLocation;
944 std::cout << " [" << idx << "]: " << lLocation << std::endl;
945 }
946
947 } else {
948 std::cout << "List of unmatched words:" << std::endl;
949 std::cout << " [" << 1 << "]: " << lIcaoCodeStr << std::endl;
950 }
951
952 break;
953 }
954
955 // ////////////////////////// List by FAA code ////////////////////////
957 //
958 TokenList_T lTokenList = extractTokenListForFaaCode(lTokenListByReadline);
959
960 // Parse the parameters given by the user, giving default values
961 // in case the user does not specify some (or all) of them
962 std::string lFaaCodeStr ("jfk");
963 parsePlaceKey (lTokenList, lFaaCodeStr);
964
965 // Call the underlying OpenTREP service
966 const OPENTREP::FAACode_T lFaaCode (lFaaCodeStr);
967 OPENTREP::LocationList_T lLocationList;
968 const OPENTREP::NbOfMatches_T nbOfMatches =
969 opentrepService.listByFaaCode (lFaaCode, lLocationList);
970
971 //
972 std::cout << nbOfMatches << " (geographical) location(s) have been found "
973 << "matching the FAA code ('" << lFaaCodeStr << "')."
974 << std::endl;
975
976 if (nbOfMatches != 0) {
978 for (OPENTREP::LocationList_T::const_iterator itLocation =
979 lLocationList.begin();
980 itLocation != lLocationList.end(); ++itLocation, ++idx) {
981 const OPENTREP::Location& lLocation = *itLocation;
982 std::cout << " [" << idx << "]: " << lLocation << std::endl;
983 }
984
985 } else {
986 std::cout << "List of unmatched words:" << std::endl;
987 std::cout << " [" << 1 << "]: " << lFaaCodeStr << std::endl;
988 }
989
990 break;
991 }
992
993 // //////////////////////// List by UN/LOCODE code //////////////////////
995 //
996 TokenList_T lTokenList = extractTokenListForUNLOCode(lTokenListByReadline);
997
998 // Parse the parameters given by the user, giving default values
999 // in case the user does not specify some (or all) of them
1000 std::string lUNLOCodeStr ("deham");
1001 parsePlaceKey (lTokenList, lUNLOCodeStr);
1002
1003 // Call the underlying OpenTREP service
1004 const OPENTREP::UNLOCode_T lUNLOCode (lUNLOCodeStr);
1005 OPENTREP::LocationList_T lLocationList;
1006 const OPENTREP::NbOfMatches_T nbOfMatches =
1007 opentrepService.listByUNLOCode (lUNLOCode, lLocationList);
1008
1009 //
1010 std::cout << nbOfMatches << " (geographical) location(s) have been found "
1011 << "matching the UN/LOCODE code ('" << lUNLOCodeStr << "')."
1012 << std::endl;
1013
1014 if (nbOfMatches != 0) {
1016 for (OPENTREP::LocationList_T::const_iterator itLocation =
1017 lLocationList.begin();
1018 itLocation != lLocationList.end(); ++itLocation, ++idx) {
1019 const OPENTREP::Location& lLocation = *itLocation;
1020 std::cout << " [" << idx << "]: " << lLocation << std::endl;
1021 }
1022
1023 } else {
1024 std::cout << "List of unmatched words:" << std::endl;
1025 std::cout << " [" << 1 << "]: " << lUNLOCodeStr << std::endl;
1026 }
1027
1028 break;
1029 }
1030
1031 // //////////////////////// List by UIC code //////////////////////
1033 //
1034 TokenList_T lTokenList = extractTokenListForUICCode(lTokenListByReadline);
1035
1036 // Parse the parameters given by the user, giving default values
1037 // in case the user does not specify some (or all) of them
1038 std::string lUICCodeStr ("87775007");
1039 parsePlaceKey (lTokenList, lUICCodeStr);
1040
1041 // Convert the string into an integer
1042 OPENTREP::UICCode_T lUICCode;
1043
1044 try {
1045
1046 lUICCode = boost::lexical_cast<OPENTREP::UICCode_T> (lUICCodeStr);
1047
1048 } catch (boost::bad_lexical_cast& eCast) {
1049 lUICCode = 87775007;
1050 std::cerr << "The UIC code ('" << lUICCodeStr
1051 << "') cannot be understood. The default value ("
1052 << lUICCode << ") is kept." << std::endl;
1053 }
1054
1055 // Call the underlying OpenTREP service
1056 OPENTREP::LocationList_T lLocationList;
1057 const OPENTREP::NbOfMatches_T nbOfMatches =
1058 opentrepService.listByUICCode (lUICCode, lLocationList);
1059
1060 //
1061 std::cout << nbOfMatches << " (geographical) location(s) have been found "
1062 << "matching the UIC code ('" << lUICCodeStr << "')."
1063 << std::endl;
1064
1065 if (nbOfMatches != 0) {
1067 for (OPENTREP::LocationList_T::const_iterator itLocation =
1068 lLocationList.begin();
1069 itLocation != lLocationList.end(); ++itLocation, ++idx) {
1070 const OPENTREP::Location& lLocation = *itLocation;
1071 std::cout << " [" << idx << "]: " << lLocation << std::endl;
1072 }
1073
1074 } else {
1075 std::cout << "List of unmatched words:" << std::endl;
1076 std::cout << " [" << 1 << "]: " << lUICCodeStr << std::endl;
1077 }
1078
1079 break;
1080 }
1081
1082 // ////////////////////////// List by Geoname ID ////////////////////////
1084 //
1085 TokenList_T lTokenList =
1086 extractTokenListForGeonameID (lTokenListByReadline);
1087
1088 // Parse the parameters given by the user, giving default values
1089 // in case the user does not specify some (or all) of them
1090 std::string lGeonameIDStr ("6299418");
1091 parsePlaceKey (lTokenList, lGeonameIDStr);
1092
1093 // Convert the string into an integer
1094 OPENTREP::GeonamesID_T lGeonameID;
1095
1096 try {
1097
1098 lGeonameID = boost::lexical_cast<OPENTREP::GeonamesID_T> (lGeonameIDStr);
1099
1100 } catch (boost::bad_lexical_cast& eCast) {
1101 lGeonameID = 6299418;
1102 std::cerr << "The Geoname ID ('" << lGeonameIDStr
1103 << "') cannot be understood. The default value ("
1104 << lGeonameID << ") is kept." << std::endl;
1105 }
1106
1107 // Call the underlying OpenTREP service
1108 OPENTREP::LocationList_T lLocationList;
1109 const OPENTREP::NbOfMatches_T nbOfMatches =
1110 opentrepService.listByGeonameID (lGeonameID, lLocationList);
1111
1112 //
1113 std::cout << nbOfMatches << " (geographical) location(s) have been found "
1114 << "matching the Geoname ID ('" << lGeonameIDStr << "')."
1115 << std::endl;
1116
1117 if (nbOfMatches != 0) {
1119 for (OPENTREP::LocationList_T::const_iterator itLocation =
1120 lLocationList.begin();
1121 itLocation != lLocationList.end(); ++itLocation, ++idx) {
1122 const OPENTREP::Location& lLocation = *itLocation;
1123 std::cout << " [" << idx << "]: " << lLocation << std::endl;
1124 }
1125
1126 } else {
1127 std::cout << "List of unmatched items:" << std::endl;
1128 std::cout << " [" << 1 << "]: " << lGeonameIDStr << std::endl;
1129 }
1130
1131 break;
1132 }
1133
1134 // ///////////////////////// Database Creation /////////////////////////
1136 //
1137 std::cout << "Creating the 'trep' user and 'trep_trep' database"
1138 << std::endl;
1139
1140 // On MySQL/MariaDB, create the 'trep' user and 'trep_trep' database.
1141 // On SQLite, delete the directory hosting the database, and re-create it.
1142 // On other database types, do nothing.
1143 const bool lCreationSuccessful = opentrepService.createSQLDBUser();
1144
1145 // Reporting
1146 if (lCreationSuccessful == true) {
1147 std::cout << "The 'trep' user and 'trep_trep' database have been created"
1148 << std::endl;
1149 }
1150
1151 break;
1152 }
1153
1154 // ///////////////////// Database connection string //////////////////////
1156 // Parse the parameters given by the user, giving default values
1157 // in case the user does not specify some (or all) of them
1158 const std::string lConnectionStringStr = toString (lTokenListByReadline);
1159
1160 //
1161 std::cout << "Reset the connection string" << std::endl;
1162
1163 // Reset the connection string
1165 lConnectionString (lConnectionStringStr);
1166 opentrepService.setSQLDBConnectString (lConnectionString);
1167
1168 //
1169 std::cout << "The connection string has been reset" << std::endl;
1170
1171 break;
1172 }
1173
1174 // /////////////////// Deployment number/version /////////////////////
1176 // Toggle the deployment number/version
1177 lDeploymentNumber = opentrepService.toggleDeploymentNumber();
1178
1179 // Reporting
1180 std::cout << "The new deployment number/version is: " << lDeploymentNumber
1182 << std::endl;
1183
1184 break;
1185 }
1186
1187 // /////////////////// Index or not non-IATA POR /////////////////////
1189 // Toggle the flag
1190 lIncludeNonIATAPOR = opentrepService.toggleShouldIncludeAllPORFlag();
1191
1192 // Reporting
1193 std::cout << "The new flag is: " << lIncludeNonIATAPOR << std::endl;
1194
1195 break;
1196 }
1197
1198 // ///////////////////// Index or not in Xapian ///////////////////////
1200 // Toggle the flag
1201 lShouldIndexPORInXapian =
1202 opentrepService.toggleShouldIndexPORInXapianFlag();
1203
1204 // Reporting
1205 std::cout << "The new flag is: " << lShouldIndexPORInXapian << std::endl;
1206
1207 break;
1208 }
1209
1210 // ///////////////////// Add or not in SQL DB ///////////////////////
1212 // Toggle the flag
1213 lShouldAddPORInSQLDB = opentrepService.toggleShouldAddPORInSQLDBFlag();
1214
1215 // Reporting
1216 std::cout << "The new flag is: " << lShouldAddPORInSQLDB << std::endl;
1217
1218 break;
1219 }
1220
1221 // ///////////////////////// Tables Creation /////////////////////////
1223 //
1224 std::cout << "Creating/resetting the " << lDBType.describe()
1225 << " database tables" << std::endl;
1226
1227 // Create/reset the SQLite3/MySQL tables
1228 opentrepService.createSQLDBTables();
1229
1230 //
1231 std::cout << "The " << lDBType.describe()
1232 << " tables has been created/resetted" << std::endl;
1233
1234 break;
1235 }
1236
1237 // ///////////////////////// Indexes Creation /////////////////////////
1239 //
1240 std::cout << "Creating/resetting the " << lDBType.describe()
1241 << " database indexes" << std::endl;
1242
1243 // Create/reset the SQLite3/MySQL indexes
1244 opentrepService.createSQLDBIndexes();
1245
1246 //
1247 std::cout << "The " << lDBType.describe()
1248 << " indexes has been created/resetted" << std::endl;
1249
1250 break;
1251 }
1252
1253 // ///////////////////////// POR File Indexing /////////////////////////
1255 //
1256 std::cout << "Indexing the POR file and filling in the SQL database may "
1257 << "take a few minutes on some architectures "
1258 << "(and a few seconds on fastest ones)..."
1259 << std::endl;
1260
1261 // Launch the indexation
1262 const OPENTREP::NbOfDBEntries_T lNbOfEntries =
1263 opentrepService.insertIntoDBAndXapian();
1264
1265 //
1266 std::cout << lNbOfEntries << " entries have been processed" << std::endl;
1267
1268 break;
1269 }
1270
1271 // /////////////////////////// Default / No value ///////////////////////
1272 case Command_T::NOP: {
1273 break;
1274 }
1275
1277 default: {
1278 // DEBUG
1279 std::ostringstream oStr;
1280 oStr << "That command is not yet understood: '" << lUserInput
1281 << "' => " << lTokenListByReadline;
1282 OPENTREP_LOG_DEBUG (oStr.str());
1283 std::cout << oStr.str() << std::endl;
1284 }
1285 }
1286 }
1287
1288 // DEBUG
1289 OPENTREP_LOG_DEBUG ("End of the session. Exiting.");
1290 std::cout << "End of the session. Exiting." << std::endl;
1291
1292 // Close the Log outputFile
1293 logOutputFile.close();
1294
1295 return 0;
1296}
#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
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:131
Structure modelling a (geographical) location.
Definition Location.hpp:25
std::string toString() const
Definition Location.cpp:282