CommandLineParser.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 /**
33  @file CommandLineParser.hpp
34 
35  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
36 */
37 
38 
39 #ifndef __OPENFLUID_UTILS_COMMANDLINEPARSER_HPP__
40 #define __OPENFLUID_UTILS_COMMANDLINEPARSER_HPP__
41 
42 
43 #include <map>
44 #include <string>
45 #include <ostream>
46 
47 
48 namespace openfluid { namespace utils {
49 
50 
52 {
53  private:
54 
55  std::string m_LongName;
56 
57  std::string m_ShortName;
58 
59  bool m_ValueRequired;
60 
61  std::string m_Value;
62 
63  std::string m_HelpText;
64 
65  bool m_Active;
66 
67 
68  public:
69 
71  m_ValueRequired(false),m_Active(false)
72  { }
73 
74 
75  // =====================================================================
76  // =====================================================================
77 
78 
79  /**
80  Instanciates an option with the given parameters
81  @param[in] LongName The long name of the option
82  @param[in] ShortName The short name of the option
83  @param[in] HelpText The help text associated to the option
84  @param[in] ValueRequired Set to true to require a value with this option (default is false)
85  */
86  CommandLineOption(const std::string& LongName, const std::string& ShortName,
87  const std::string& HelpText, bool ValueRequired = false):
88  m_LongName(LongName),m_ShortName(ShortName), m_ValueRequired(ValueRequired), m_HelpText(HelpText),
89  m_Active(false)
90  { }
91 
92 
93  // =====================================================================
94  // =====================================================================
95 
96 
97  /**
98  Returns the help text of the option
99  @return The help text
100  */
101  std::string getHelpText() const
102  {
103  return m_HelpText;
104  }
105 
106 
107  // =====================================================================
108  // =====================================================================
109 
110 
111  /**
112  Returns the long name of the option (e.g. 'output-dir')
113  @return The long name
114  */
115  std::string getLongName() const
116  {
117  return m_LongName;
118  }
119 
120 
121  // =====================================================================
122  // =====================================================================
123 
124 
125  /**
126  Returns the short name of the option (e.g. 'o')
127  @return The short name
128  */
129  std::string getShortName() const
130  {
131  return m_ShortName;
132  }
133 
134 
135  // =====================================================================
136  // =====================================================================
137 
138 
139  /**
140  Returns the value of the option
141  @return The value
142  */
143  std::string getValue() const
144  {
145  return m_Value;
146  }
147 
148 
149  // =====================================================================
150  // =====================================================================
151 
152 
153  /**
154  Tests if the option is active
155  @return true if the option is active
156  */
157  bool isActive() const
158  {
159  return m_Active;
160  }
161 
162 
163  // =====================================================================
164  // =====================================================================
165 
166 
167  /**
168  Tests if the option requires a value
169  @return true if the option requires a value
170  */
171  bool isValueRequired() const
172  {
173  return m_ValueRequired;
174  }
175 
176 
177  // =====================================================================
178  // =====================================================================
179 
180 
181  /**
182  Activates the option with the given value
183  @param[in] Value The value for activation (default is empty)
184  */
185  void activate(const std::string& Value = "")
186  {
187  m_Value = Value;
188 
189  if ((!m_ValueRequired) || (m_ValueRequired && !m_Value.empty()))
190  m_Active = true;
191  else
192  m_Active = false;
193  }
194 
195 
196  // =====================================================================
197  // =====================================================================
198 
199 
200  /**
201  Resets the option to default (inactive with empty value)
202  */
203  void reset()
204  {
205  m_Active = false;
206  m_Value = "";
207  }
208 
209 };
210 
211 
212 // =====================================================================
213 // =====================================================================
214 
215 
217 {
218  private:
219 
220  std::string m_Name;
221 
222  std::string m_HelpText;
223 
224  std::map<std::string,CommandLineOption> m_Options;
225 
226  std::map<std::string,CommandLineOption*> m_ShortOptions;
227 
228 
229  public:
230 
232  { }
233 
234 
235  // =====================================================================
236  // =====================================================================
237 
238 
239  /**
240  Instanciates a command with the given parameters
241  @param[in] Name The long name of the command
242  @param[in] HelpText The help text associated to the command
243  */
244  CommandLineCommand(const std::string& Name, const std::string& HelpText):
245  m_Name(Name), m_HelpText(HelpText)
246  { }
247 
248 
249  // =====================================================================
250  // =====================================================================
251 
252 
253  /**
254  Returns the help text of the command
255  @return The help text
256  */
257  std::string getHelpText() const
258  {
259  return m_HelpText;
260  }
261 
262 
263  // =====================================================================
264  // =====================================================================
265 
266 
267  /**
268  Returns the name of the command
269  @return The name (e.g. "search")
270  */
271  std::string getName() const
272  {
273  return m_Name;
274  }
275 
276 
277  // =====================================================================
278  // =====================================================================
279 
280 
281  /**
282  Returns the options registered for the command
283  @return The options
284  */
285  const std::map<std::string,CommandLineOption>& options()
286  {
287  return m_Options;
288  }
289 
290 
291  // =====================================================================
292  // =====================================================================
293 
294 
295  /**
296  Adds an option to the command
297  @param[in] Option The option to add
298  */
299  void addOption(const CommandLineOption& Option)
300  {
301  m_Options[Option.getLongName()] = Option;
302 
303  if (!Option.getShortName().empty())
304  {
305  m_ShortOptions[Option.getShortName()] = &m_Options[Option.getLongName()];
306  }
307  }
308 
309 
310  // =====================================================================
311  // =====================================================================
312 
313 
314  /**
315  Activates the given option with the given value
316  @param[in] LongName The long name of the option
317  @param[in] Value The value for activation (default is empty)
318  */
319  bool activateOption(const std::string& LongName, const std::string& Value = "")
320  {
321  auto it = m_Options.find(LongName);
322 
323  if (it == m_Options.end())
324  {
325  return false;
326  }
327 
328  (*it).second.activate(Value);
329  return (*it).second.isActive();
330  }
331 
332 
333  // =====================================================================
334  // =====================================================================
335 
336 
337  /**
338  Returns the long name of an option from its short name
339  @param[in] ShortName The requested short name for the option
340  @return The long name
341  */
342  std::string getOptionNameFromShortName(const std::string& ShortName) const
343  {
344  auto it = m_ShortOptions.find(ShortName);
345 
346  if (it == m_ShortOptions.end())
347  {
348  return "";
349  }
350 
351  return (*it).second->getLongName();
352  }
353 
354 
355  // =====================================================================
356  // =====================================================================
357 
358 
359  /**
360  Tests if an option exists for the command
361  @param[in] LongName The long name for the searched option
362  @return true if the option exists
363  */
364  bool isOptionExists(const std::string& LongName) const
365  {
366  return (m_Options.find(LongName) != m_Options.end());
367  }
368 
369 
370  // =====================================================================
371  // =====================================================================
372 
373 
374  /**
375  Tests if an option requires a value
376  @param[in] LongName The long name for the searched option
377  @return true if the option requires a value
378  */
379  bool isOptionRequiresValue(const std::string& LongName) const
380  {
381  auto it = m_Options.find(LongName);
382 
383  if (it == m_Options.end())
384  {
385  return false;
386  }
387 
388  return (*it).second.isValueRequired();
389  }
390 
391 
392  // =====================================================================
393  // =====================================================================
394 
395 
396  /**
397  Tests if an option is active
398  @param[in] LongName The long name for the searched option
399  @return true if the option is active
400  */
401  bool isOptionActive(const std::string& LongName) const
402  {
403  auto it = m_Options.find(LongName);
404 
405  return (it != m_Options.end() && (*it).second.isActive());
406  }
407 
408 
409  // =====================================================================
410  // =====================================================================
411 
412 
413  /**
414  Returns the value given for an option
415  @param[in] LongName The long name for the option
416  @return the value for the option
417  */
418  std::string getOptionValue(const std::string& LongName) const
419  {
420  auto it = m_Options.find(LongName);
421 
422  if (it == m_Options.end())
423  {
424  return "";
425  }
426 
427  return ((*it).second.getValue());
428  }
429 
430 
431  // =====================================================================
432  // =====================================================================
433 
434 
435  /**
436  Resets all options to default (inactive with empty value)
437  */
438  void reset()
439  {
440  for (auto& Opt : m_Options)
441  {
442  Opt.second.reset();
443  }
444  }
445 
446 };
447 
448 
449 // =====================================================================
450 // =====================================================================
451 
452 
453 // OpenFLUID:stylecheck:!incs
454 
455 /**
456  @brief Class for management of command line arguments.
457 
458  This class allows to manage the command line arguments as commands, options and extra arguments.
459 
460  The example below is for a command line program with two commands ('run' and 'search') and associated options
461  @code
462  #include <openfluid/utils/CommandLineParser.hpp>
463 
464  int main(int argc, char** argv)
465  {
466  // ------- Definition of the parser for "myprogram"
467 
468  openfluid::utils::CommandLineParser Parser("myprogram","this is my program");
469 
470  // add of the "run" command with associated options
471  openfluid::utils::CommandLineCommand RunCmd("run","run the process");
472  RunCmd.addOption(openfluid::utils::CommandLineOption("input-path","i","input path",true));
473  RunCmd.addOption(openfluid::utils::CommandLineOption("output-path","o","output path",true));
474  RunCmd.addOption(openfluid::utils::CommandLineOption("verbose","","verbose mode"));
475  Parser.addCommand(RunCmd);
476 
477  // add of the "search" command with associated options
478  openfluid::utils::CommandLineCommand SearchCmd("search","search for data");
479  SearchCmd.addOption(openfluid::utils::CommandLineOption("path","p","path to search",true));
480  SearchCmd.addOption(openfluid::utils::CommandLineOption("extended","e","enable extended search"));
481  Parser.addCommand(SearchCmd);
482 
483 
484  // ------- Parsing of the given arguments
485 
486  Parser.parse(argc,argv);
487 
488 
489  // ------- Processing of commands and options
490 
491  std::string ActiveCommand = Parser.getActiveCommand();
492 
493  if (ActiveCommand.empty())
494  {
495  // .. code here when no command
496  }
497  else if (ActiveCommand == "run")
498  {
499  // .. code here for "run" command
500 
501  if (Parser.command(ActiveCommand).isOptionActive("input-path"))
502  {
503  // .. code here for "input-path" option
504  }
505  if (Parser.command(ActiveCommand).isOptionActive("output-path"))
506  {
507  // .. code here for "output-path" option
508  }
509 
510  // ...
511  }
512  else if (ActiveCommand == "search")
513  {
514  // .. code here for "search" command
515  }
516  }
517  @endcode
518 */
520 {
521  private:
522 
523  std::string m_ProgramName;
524 
525  std::string m_HelpText;
526 
527  std::map<std::string,CommandLineCommand> m_Commands;
528 
529  std::string m_ActiveCommand;
530 
531  std::vector<std::string> m_ExtraArgs;
532 
533  std::string m_ParsingMessage;
534 
535  bool m_HelpAsked;
536 
537 
538  public:
539 
541  m_HelpAsked(false)
542  {
543  addCommand(CommandLineCommand("",""));
544  }
545 
546 
547  // =====================================================================
548  // =====================================================================
549 
550 
551  /**
552  Instanciates a command line parser with the given parameters
553  @param[in] ProgramName The name of the programn
554  @param[in] HelpText The help text associated to the option
555  */
556  CommandLineParser(const std::string& ProgramName, const std::string& HelpText) :
557  m_ProgramName(ProgramName), m_HelpText(HelpText), m_HelpAsked(false)
558  {
559  addCommand(CommandLineCommand("",""));
560  }
561 
562 
563  // =====================================================================
564  // =====================================================================
565 
566 
567  /**
568  Returns the extra arguments given to the command
569  @return a vector of arguments
570  */
571  const std::vector<std::string>& extraArgs() const
572  {
573  return m_ExtraArgs;
574  }
575 
576 
577  // =====================================================================
578  // =====================================================================
579 
580 
581  /**
582  Returns the help text of the parser
583  @return The help text
584  */
585  std::string getHelpText() const
586  {
587  return m_HelpText;
588  }
589 
590 
591  // =====================================================================
592  // =====================================================================
593 
594 
595  /**
596  Returns the program name
597  @return The program name
598  */
599  std::string getProgramName() const
600  {
601  return m_ProgramName;
602  }
603 
604 
605  // =====================================================================
606  // =====================================================================
607 
608 
609  /**
610  Returns the message given by the parsing process in case of error(s)
611  @return The message
612  */
613  std::string getParsingMessage() const
614  {
615  return m_ParsingMessage;
616  }
617 
618 
619  // =====================================================================
620  // =====================================================================
621 
622 
623  /**
624  Returns the active command name
625  @return The active command name
626  */
627  std::string getActiveCommand() const
628  {
629  return m_ActiveCommand;
630  }
631 
632 
633  // =====================================================================
634  // =====================================================================
635 
636 
637  /**
638  Returns the command corresponding to the given name
639  @param[in] Name the name of the command
640  @return The command object
641  */
642  const CommandLineCommand& command(const std::string& Name) const
643  {
644  return m_Commands.at(Name);
645  }
646 
647 
648  // =====================================================================
649  // =====================================================================
650 
651 
652  /**
653  Adds a command to the parser
654  @param[in] Command The command to add
655  */
656  void addCommand(const CommandLineCommand& Command)
657  {
658  m_Commands[Command.getName()] = Command;
659  }
660 
661 
662  // =====================================================================
663  // =====================================================================
664 
665 
666  /**
667  Adds a global option to the parser
668  @param[in] Option The option to add
669  */
670  void addOption(const CommandLineOption& Option)
671  {
672  m_Commands[""].addOption(Option);
673  }
674 
675 
676  // =====================================================================
677  // =====================================================================
678 
679 
680  /**
681  Parses a list of string arguments
682  @param[in] ArgValues The lists of arguments to parse
683  @return true if the parsing is succesful, false otherwise
684  */
685  bool parse(std::list<std::string> ArgValues)
686  {
687  reset();
688 
689  while (!ArgValues.empty())
690  {
691  std::string Arg = ArgValues.front();
692  ArgValues.pop_front();
693 
694  if (Arg[0] != '-')
695  {
696  // arg not an option
697  if (m_ActiveCommand.empty())
698  m_ActiveCommand = Arg;
699  else
700  m_ExtraArgs.push_back(Arg);
701  }
702  else
703  {
704  // arg is an option
705 
706  // check if the command exists
707  auto it = m_Commands.find(m_ActiveCommand);
708  if (it == m_Commands.end())
709  {
710  m_ParsingMessage = "unknown \""+ m_ActiveCommand + "\" command";
711  return false;
712  }
713 
714  if (Arg == "-h" || Arg == "--help")
715  {
716  m_HelpAsked = true;
717  }
718  else if (Arg.size() < 2)
719  {
720  m_ParsingMessage = "wrong format for option \"" + Arg + "\"";
721  return false;
722  }
723  else
724  {
725  std::string LongOptName;
726  std::string OptValue;
727  bool IsFromShort = false;
728 
729  if (Arg[1] != '-')
730  {
731  if (Arg.size() != 2)
732  {
733  m_ParsingMessage = "wrong format for short option \"" + Arg + "\"";
734  return false;
735  }
736 
737  // short option
738  LongOptName = m_Commands[m_ActiveCommand].getOptionNameFromShortName(Arg.substr(1,1));
739  IsFromShort = true;
740  }
741  else
742  {
743  // long option
744  std::string TmpName = Arg.substr(2,Arg.size()-2);
745 
746  std::string::size_type EqualPos = TmpName.find("=");
747 
748  if (EqualPos != std::string::npos)
749  {
750  LongOptName = TmpName.substr(0,EqualPos);
751  OptValue = TmpName.substr(EqualPos+1,TmpName.size()-EqualPos-1);
752  }
753  else
754  {
755  LongOptName = TmpName;
756  }
757  }
758 
759  if (!m_Commands[m_ActiveCommand].isOptionExists(LongOptName))
760  {
761  // unknown option
762  m_ParsingMessage = "unknown option \"" + Arg + "\"";
763  if (!m_ActiveCommand.empty())
764  {
765  m_ParsingMessage += " for command \"" + m_ActiveCommand + "\"";
766  }
767  return false;
768  }
769 
770  if (m_Commands[m_ActiveCommand].isOptionRequiresValue(LongOptName))
771  {
772  if (IsFromShort && !ArgValues.empty())
773  {
774  OptValue = ArgValues.front();
775  ArgValues.pop_front();
776  }
777 
778  if (OptValue.empty())
779  {
780  m_ParsingMessage = "missing value for option \"" + Arg + "\"";
781  return false;
782  }
783  }
784 
785  if (!m_Commands[m_ActiveCommand].activateOption(LongOptName,OptValue))
786  {
787  // wrong option format
788  m_ParsingMessage = "unknown error for option \"" + Arg + "\"";
789  return false;
790  }
791  }
792  }
793  }
794  return true;
795  }
796 
797 
798  // =====================================================================
799  // =====================================================================
800 
801 
802  /**
803  Parses arguments from the standard parameters `(int argc,char** argv)` given through the main function
804  @param[in] ArgC The number of arguments
805  @param[in] ArgV The array of arguments
806  @return true if the parsing is succesful, false otherwise
807  */
808  bool parse(int ArgC, char **ArgV)
809  {
810  std::list<std::string> ArgValues;
811 
812  for (int i=1; i< ArgC; i++)
813  {
814  ArgValues.push_back(std::string(ArgV[i]));
815  }
816 
817  return parse(ArgValues);
818  }
819 
820 
821  // =====================================================================
822  // =====================================================================
823 
824 
825  /**
826  Resets the parser to default (no active command, no extra arguments, no option activated)
827  */
828  void reset()
829  {
830  m_ActiveCommand.clear();
831  m_ParsingMessage.clear();
832  m_ExtraArgs.clear();
833 
834  for (auto& Cmd : m_Commands)
835  {
836  Cmd.second.reset();
837  }
838  }
839 
840 
841  // =====================================================================
842  // =====================================================================
843 
844 
845  /**
846  Tests if the help is asked
847  @return true if the help is asked
848  */
849  bool isHelpAsked()
850  {
851  return m_HelpAsked;
852  }
853 
854 
855  // =====================================================================
856  // =====================================================================
857 
858 
859  /**
860  Prints the help text
861  @param[in] OutStm The stream where the help text is printed (e.g. std::cout)
862  */
863  void printHelp(std::ostream& OutStm)
864  {
865  std::string m_CmdName = m_ActiveCommand;
866 
867  if (m_CmdName.empty())
868  {
869  m_CmdName = "[<command>]";
870  }
871 
872  OutStm << "Usage : " << m_ProgramName << " " << m_CmdName << " [<options>] [<args>]\n";
873 
874  if (m_ActiveCommand.empty())
875  {
876  OutStm << "\nAvailable commands:\n";
877 
878  for (auto& Cmd : m_Commands)
879  {
880  if (!Cmd.first.empty())
881  {
882  OutStm << " " << Cmd.first << " : " << Cmd.second.getHelpText() << "\n";
883  }
884  }
885  }
886 
887  if (!m_Commands[m_ActiveCommand].getHelpText().empty())
888  {
889  OutStm << "\n" << m_Commands[m_ActiveCommand].getHelpText() << "\n";
890  }
891 
892  OutStm << "\nAvailable options:\n";
893  OutStm << " --help,-h : display this help message\n";
894 
895  for (auto& Opt : m_Commands[m_ActiveCommand].options())
896  {
897  OutStm << " --" << Opt.second.getLongName();
898  if (Opt.second.isValueRequired())
899  {
900  OutStm << "=<arg>";
901  }
902 
903  if (!Opt.second.getShortName().empty())
904  {
905  OutStm << ", -" << Opt.second.getShortName();
906  if (Opt.second.isValueRequired())
907  {
908  OutStm << " <arg>";
909  }
910  }
911 
912  OutStm << " : " << Opt.second.getHelpText() << "\n";
913  }
914  }
915 
916 
917  // =====================================================================
918  // =====================================================================
919 
920 
921  /**
922  Prints the state of the parser
923  @param[in] OutStm The stream where the help text is printed (e.g. std::cout)
924  */
925  void printState(std::ostream& OutStm)
926  {
927  for (auto& Cmd : m_Commands)
928  {
929  if (!Cmd.first.empty())
930  {
931  if (Cmd.first == m_ActiveCommand)
932  {
933  OutStm << "+";
934  }
935  else
936  {
937  OutStm << "-";
938  }
939 
940  OutStm << " " << Cmd.first << " : " << Cmd.second.getHelpText() << "\n";
941 
942  for (auto& Opt : Cmd.second.options())
943  {
944  OutStm << " ";
945 
946  if (Opt.second.isActive())
947  {
948  OutStm << "+";
949  }
950  else
951  {
952  OutStm << "-";
953  }
954  OutStm << " " << Opt.first;
955 
956  if (!Opt.second.getShortName().empty())
957  {
958  OutStm << "," << Opt.second.getShortName();
959  }
960 
961  if (Opt.second.isValueRequired())
962  {
963  OutStm << "[" << Opt.second.getValue() << "]";
964  }
965 
966  OutStm << " : " << Opt.second.getHelpText() << "\n";
967  }
968  }
969  }
970 
971 
972  if (!m_ExtraArgs.empty())
973  {
974  OutStm << "Extra arguments :";
975 
976  for (auto& Arg : m_ExtraArgs)
977  {
978  OutStm << " " << Arg;
979  }
980 
981  OutStm << "\n";
982  }
983 
984  }
985 
986 };
987 
988 
989 } }
990 
991 
992 #endif /* __OPENFLUID_UTILS_COMMANDLINEPARSER_HPP__ */
std::string getOptionValue(const std::string &LongName) const
Definition: CommandLineParser.hpp:418
Definition: CommandLineParser.hpp:51
std::string getActiveCommand() const
Definition: CommandLineParser.hpp:627
const CommandLineCommand & command(const std::string &Name) const
Definition: CommandLineParser.hpp:642
std::string getOptionNameFromShortName(const std::string &ShortName) const
Definition: CommandLineParser.hpp:342
void addOption(const CommandLineOption &Option)
Definition: CommandLineParser.hpp:670
std::string getProgramName() const
Definition: CommandLineParser.hpp:599
bool parse(std::list< std::string > ArgValues)
Definition: CommandLineParser.hpp:685
bool isOptionExists(const std::string &LongName) const
Definition: CommandLineParser.hpp:364
bool isHelpAsked()
Definition: CommandLineParser.hpp:849
bool activateOption(const std::string &LongName, const std::string &Value="")
Definition: CommandLineParser.hpp:319
std::string getParsingMessage() const
Definition: CommandLineParser.hpp:613
bool isValueRequired() const
Definition: CommandLineParser.hpp:171
bool isOptionRequiresValue(const std::string &LongName) const
Definition: CommandLineParser.hpp:379
std::string getValue() const
Definition: CommandLineParser.hpp:143
void reset()
Definition: CommandLineParser.hpp:203
Class for management of command line arguments.
Definition: CommandLineParser.hpp:519
CommandLineCommand()
Definition: CommandLineParser.hpp:231
CommandLineCommand(const std::string &Name, const std::string &HelpText)
Definition: CommandLineParser.hpp:244
void printHelp(std::ostream &OutStm)
Definition: CommandLineParser.hpp:863
std::string getHelpText() const
Definition: CommandLineParser.hpp:257
CommandLineParser(const std::string &ProgramName, const std::string &HelpText)
Definition: CommandLineParser.hpp:556
void addOption(const CommandLineOption &Option)
Definition: CommandLineParser.hpp:299
void addCommand(const CommandLineCommand &Command)
Definition: CommandLineParser.hpp:656
Definition: CommandLineParser.hpp:216
const std::vector< std::string > & extraArgs() const
Definition: CommandLineParser.hpp:571
std::string getHelpText() const
Definition: CommandLineParser.hpp:585
bool parse(int ArgC, char **ArgV)
Definition: CommandLineParser.hpp:808
std::string getShortName() const
Definition: CommandLineParser.hpp:129
bool isActive() const
Definition: CommandLineParser.hpp:157
Definition: ApplicationException.hpp:47
bool isOptionActive(const std::string &LongName) const
Definition: CommandLineParser.hpp:401
const std::map< std::string, CommandLineOption > & options()
Definition: CommandLineParser.hpp:285
std::string getLongName() const
Definition: CommandLineParser.hpp:115
CommandLineOption()
Definition: CommandLineParser.hpp:70
CommandLineOption(const std::string &LongName, const std::string &ShortName, const std::string &HelpText, bool ValueRequired=false)
Definition: CommandLineParser.hpp:86
void activate(const std::string &Value="")
Definition: CommandLineParser.hpp:185
std::string getName() const
Definition: CommandLineParser.hpp:271
std::string getHelpText() const
Definition: CommandLineParser.hpp:101
void reset()
Definition: CommandLineParser.hpp:828
void reset()
Definition: CommandLineParser.hpp:438
void printState(std::ostream &OutStm)
Definition: CommandLineParser.hpp:925
CommandLineParser()
Definition: CommandLineParser.hpp:540