CmdLnArgParser.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::CmdLnArgParser
5 
6 \brief Command line argument parser
7 
8 \author Costas Andreopoulos <costas.andreopoulos \at stfc.ac.uk>
9  University of Liverpool & STFC Rutherford Appleton Lab
10 
11 \created July 23, 2010
12 
13 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15  or see $GENIE/LICENSE
16 */
17 //____________________________________________________________________________
18 
19 #ifndef _CMD_LINE_ARG_PARSER_H_
20 #define _CMD_LINE_ARG_PARSER_H_
21 
22 #include <string>
23 #include <vector>
24 
25 using std::string;
26 using std::vector;
27 
28 namespace genie {
29 
31 
32 public:
33  CmdLnArgParser(int argc, char **argv);
35 
36  // Methods to check the existence of single character switches (eg -f, -s)
37  // and retrieve the command-line argument following the switch
38 
39  bool OptionExists (char opt); ///< was option set?
40  char * Arg (char opt); ///< return argument following -`opt'
41 
42  string ArgAsString (char opt);
43  vector<string> ArgAsStringTokens (char opt, string delimeter);
44  double ArgAsDouble (char opt);
45  vector<double> ArgAsDoubleTokens (char opt, string delimeter);
46  int ArgAsInt (char opt);
47  vector<int> ArgAsIntTokens (char opt, string delimeter);
48  long ArgAsLong (char opt);
49  vector<long> ArgAsLongTokens (char opt, string delimeter);
50 
51  // As above, but supporting multi-character switches (eg --with-x-file )
52 
53  bool OptionExists (string opt); ///< was option set?
54  char * Arg (string opt); ///< return argument following --`opt'
55 
56  string ArgAsString (string opt);
57  double ArgAsDouble (string opt);
58  int ArgAsInt (string opt);
59  long ArgAsLong (string opt);
60 
61 private:
62 
63  int fArgc;
64  char **fArgv;
65 
66 };
67 
68 } // genie namespace
69 
70 #endif // _CMD_LINE_ARG_PARSER_H_
long ArgAsLong(char opt)
double ArgAsDouble(char opt)
vector< string > ArgAsStringTokens(char opt, string delimeter)
string ArgAsString(char opt)
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
vector< long > ArgAsLongTokens(char opt, string delimeter)
vector< double > ArgAsDoubleTokens(char opt, string delimeter)
CmdLnArgParser(int argc, char **argv)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Command line argument parser.
bool OptionExists(char opt)
was option set?
vector< int > ArgAsIntTokens(char opt, string delimeter)
char * Arg(char opt)
return argument following -`opt&#39;