GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 <c.andreopoulos \at cern.ch>
9  University of Liverpool
10 
11 \created July 23, 2010
12 
13 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
14  For the full text of the license visit http://copyright.genie-mc.org
15 */
16 //____________________________________________________________________________
17 
18 #ifndef _CMD_LINE_ARG_PARSER_H_
19 #define _CMD_LINE_ARG_PARSER_H_
20 
21 #include <string>
22 #include <vector>
23 
24 using std::string;
25 using std::vector;
26 
27 namespace genie {
28 
30 
31 public:
32  CmdLnArgParser(int argc, char **argv);
34 
35  // Methods to check the existence of single character switches (eg -f, -s)
36  // and retrieve the command-line argument following the switch
37 
38  bool OptionExists (char opt); ///< was option set?
39  char * Arg (char opt); ///< return argument following -`opt'
40 
41  string ArgAsString (char opt);
42  vector<string> ArgAsStringTokens (char opt, string delimeter);
43  double ArgAsDouble (char opt);
44  vector<double> ArgAsDoubleTokens (char opt, string delimeter);
45  int ArgAsInt (char opt);
46  vector<int> ArgAsIntTokens (char opt, string delimeter);
47  long ArgAsLong (char opt);
48  vector<long> ArgAsLongTokens (char opt, string delimeter);
49 
50  // As above, but supporting multi-character switches (eg --with-x-file )
51 
52  bool OptionExists (string opt); ///< was option set?
53  char * Arg (string opt); ///< return argument following --`opt'
54 
55  string ArgAsString (string opt);
56  double ArgAsDouble (string opt);
57  int ArgAsInt (string opt);
58  long ArgAsLong (string opt);
59 
60 private:
61 
62  int fArgc;
63  char **fArgv;
64 
65 };
66 
67 } // genie namespace
68 
69 #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)
vector< long > ArgAsLongTokens(char opt, string delimeter)
vector< double > ArgAsDoubleTokens(char opt, string delimeter)
CmdLnArgParser(int argc, char **argv)
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;