Main Page
Namespaces
Classes
Package Documentation
src
PhysicsTools
FWLite
interface
CommandLineParser.h
Go to the documentation of this file.
1
// -*- C++ -*-
2
3
#if !defined(CommandLineParser_H)
4
#define CommandLineParser_H
5
6
#include "
PhysicsTools/FWLite/interface/VariableMapCont.h
"
7
8
namespace
optutl
9
{
10
11
class
CommandLineParser
:
public
VariableMapCont
12
{
13
public
:
15
// Public Constants //
17
18
static
const
std::string
kSpaces
;
19
20
enum
21
{
22
kEventContOpt
= 1 << 0
23
};
24
26
// friends //
28
// tells particle data how to print itself out
29
friend
std::ostream&
operator<<
(std::ostream& o_stream,
30
const
CommandLineParser
&rhs);
31
33
// _ //
34
// |\/| |_ //
35
// | |EMBER | UNCTIONS //
36
// //
38
40
// Constructors and Destructor //
42
CommandLineParser
(
const
std::string
&
usage
,
43
unsigned
int
optionsType =
kEventContOpt
);
44
46
// One Liners //
48
49
// turn on (true) or off (false) printing of options by default
50
void
setPrintOptoins
(
bool
print
) {
m_printOptions
=
print
; }
51
52
// return vector calling arguments
53
const
SVec
argVec
()
const
{
return
m_fullArgVec
; }
54
56
// Regular Member Functions //
58
59
// parse the command line arguments. If 'returnArgs' is true, then
60
// any non-assignments and non-options will be returned.
61
void
parseArguments
(
int
argc
,
char
**
argv
,
bool
allowArgs =
false
);
62
63
// prints out '--help' screen, then exits.
64
void
help
();
65
66
// print out all of the variables hooked up
67
void
printOptionValues
();
68
69
// Not called by users anymore. Finish evaluating default options.
70
// Pass in 'tag' if you want to modify the output name based on
71
// options the user has passed in. 'tag' is not passed by const
72
// reference because it may be modified.
73
void
_finishDefaultOptions
(
std::string
tag
=
""
);
74
76
// Static Member Functions //
78
79
// remove an ending (e.g., '.root') from a string
80
static
std::string
removeEnding
(
const
std::string
&
input
,
81
const
std::string
&ending);
82
83
// splits a line into words
84
static
void
split
(
SVec
&retval,
std::string
line
,
85
std::string
match
=
" \t"
,
86
bool
ignoreComments =
true
);
87
88
// removes '# ....' comment
89
static
void
removeComment
(
std::string
&line);
90
91
// removes leading and trailing spaces
92
static
void
removeLeadingAndTrailingSpaces
(
std::string
&line);
93
94
// given a line, finds first non-space word and rest of line
95
static
void
findCommand
(
const
std::string
&line,
96
std::string
&
command
,
97
std::string
&rest);
98
99
100
private
:
102
// Private Member Functions //
104
105
// Sets a variable 'varname' to a 'value' from a string
106
// 'varname=value'. If 'dontOverrideChange' is set true, then the
107
// function will NOT set a variable that has been already set.
108
// This will allow you to read in a file to set most variables and
109
// still be allowed to make changes from the command line. If you
110
// want to ignore the first 'n' characters, simply set 'offset=n'.
111
bool
_setVariableFromString
(
const
std::string
&
arg
,
112
bool
dontOverrideChange =
false
,
113
int
offset
= 0);
114
115
// sets variable options from file where lines are formatted as
116
// - var=value
117
bool
_setVariablesFromFile
(
const
std::string
&
filename
);
118
119
// runs command embedded in arg
120
bool
_runVariableCommandFromString
(
const
std::string
&arg);
121
122
123
// given a section number (1..N) and totalsection (N), fills output
124
// list with correct files.
125
void
_getSectionFiles
(
const
SVec
&inputList,
SVec
&outputList,
126
int
section
,
int
totalSection);
127
129
// Private Member Data //
131
SVec
m_fullArgVec
;
132
std::string
m_argv0
;
133
std::string
m_usageString
;
134
bool
m_printOptions
;
135
unsigned
int
m_optionsType
;
136
137
};
138
139
}
140
141
#endif // CommandLineParser_H
optutl::CommandLineParser::_runVariableCommandFromString
bool _runVariableCommandFromString(const std::string &arg)
Definition:
CommandLineParser.cc:606
optutl::CommandLineParser::_getSectionFiles
void _getSectionFiles(const SVec &inputList, SVec &outputList, int section, int totalSection)
Definition:
CommandLineParser.cc:709
optutl::CommandLineParser::m_optionsType
unsigned int m_optionsType
Definition:
CommandLineParser.h:135
optutl::CommandLineParser::_finishDefaultOptions
void _finishDefaultOptions(std::string tag="")
Definition:
CommandLineParser.cc:753
optutl::CommandLineParser::_setVariablesFromFile
bool _setVariablesFromFile(const std::string &filename)
Definition:
CommandLineParser.cc:545
optutl::CommandLineParser::removeEnding
static std::string removeEnding(const std::string &input, const std::string &ending)
Definition:
CommandLineParser.cc:233
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition:
GlobalPosition_Frontier_DevDB_cff.py:11
optutl::CommandLineParser::m_usageString
std::string m_usageString
Definition:
CommandLineParser.h:133
optutl::CommandLineParser::help
void help()
Definition:
CommandLineParser.cc:143
optutl::VariableMapCont::SVec
std::vector< std::string > SVec
Definition:
VariableMapCont.h:23
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition:
AlCaHLTBitMon_QueryRunRegistry.py:256
optutl::CommandLineParser::operator<<
friend std::ostream & operator<<(std::ostream &o_stream, const CommandLineParser &rhs)
optutl::CommandLineParser::CommandLineParser
CommandLineParser(const std::string &usage, unsigned int optionsType=kEventContOpt)
Definition:
CommandLineParser.cc:20
optutl::CommandLineParser::parseArguments
void parseArguments(int argc, char **argv, bool allowArgs=false)
Definition:
CommandLineParser.cc:71
optutl::CommandLineParser::removeLeadingAndTrailingSpaces
static void removeLeadingAndTrailingSpaces(std::string &line)
Definition:
CommandLineParser.cc:211
optutl::CommandLineParser::split
static void split(SVec &retval, std::string line, std::string match=" \t", bool ignoreComments=true)
Definition:
CommandLineParser.cc:158
corrVsCorr.filename
filename
Definition:
corrVsCorr.py:123
cmsBatch.argv
argv
Definition:
cmsBatch.py:279
optutl::CommandLineParser
Definition:
CommandLineParser.h:11
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition:
JobReport.cc:66
optutl::CommandLineParser::setPrintOptoins
void setPrintOptoins(bool print)
Definition:
CommandLineParser.h:50
funct::arg
A arg
Definition:
Factorize.h:38
VariableMapCont.h
input
static std::string const input
Definition:
EdmProvDump.cc:48
optutl::CommandLineParser::m_fullArgVec
SVec m_fullArgVec
Definition:
CommandLineParser.h:131
optutl::CommandLineParser::kSpaces
static const std::string kSpaces
Definition:
CommandLineParser.h:18
optutl::CommandLineParser::printOptionValues
void printOptionValues()
Definition:
CommandLineParser.cc:271
mps_splice.line
line
Definition:
mps_splice.py:76
trackingPlots.section
section
Definition:
trackingPlots.py:1368
optutl::CommandLineParser::_setVariableFromString
bool _setVariableFromString(const std::string &arg, bool dontOverrideChange=false, int offset=0)
Definition:
CommandLineParser.cc:423
optutl::VariableMapCont
Definition:
VariableMapCont.h:13
optutl::CommandLineParser::removeComment
static void removeComment(std::string &line)
Definition:
CommandLineParser.cc:200
optutl::CommandLineParser::kEventContOpt
Definition:
CommandLineParser.h:22
optutl::CommandLineParser::argVec
const SVec argVec() const
Definition:
CommandLineParser.h:53
PFRecoTauDiscriminationByIsolation_cfi.offset
offset
Definition:
PFRecoTauDiscriminationByIsolation_cfi.py:62
optutl
Definition:
CommandLineParser.h:8
mps_check.command
list command
Definition:
mps_check.py:25
dir2webdir.argc
argc
Definition:
dir2webdir.py:39
optutl::CommandLineParser::findCommand
static void findCommand(const std::string &line, std::string &command, std::string &rest)
Definition:
CommandLineParser.cc:246
optutl::CommandLineParser::m_argv0
std::string m_argv0
Definition:
CommandLineParser.h:132
usage
void usage()
Definition:
array2xmlEB.cc:14
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition:
Utils.h:10
optutl::CommandLineParser::m_printOptions
bool m_printOptions
Definition:
CommandLineParser.h:134
Generated for CMSSW Reference Manual by
1.8.11