CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends
optutl::CommandLineParser Class Reference

#include <CommandLineParser.h>

Inheritance diagram for optutl::CommandLineParser:
optutl::VariableMapCont

Public Types

enum  { kEventContOpt = 1 << 0 }
 
- Public Types inherited from optutl::VariableMapCont
typedef std::vector< double > DVec
 
typedef DVec::const_iterator DVecConstIter
 
typedef DVec::iterator DVecIter
 
typedef std::vector< int > IVec
 
typedef IVec::const_iterator IVecConstIter
 
typedef IVec::iterator IVecIter
 
enum  OptionType {
  kNone = 0, kInteger, kDouble, kString,
  kBool, kIntegerVector, kDoubleVector, kStringVector,
  kNumOptionTypes
}
 
typedef std::map< std::string,
bool > 
SBMap
 
typedef SBMap::const_iterator SBMapConstIter
 
typedef SBMap::iterator SBMapIter
 
typedef std::map< std::string,
double > 
SDMap
 
typedef SDMap::const_iterator SDMapConstIter
 
typedef SDMap::iterator SDMapIter
 
typedef std::map< std::string,
DVec
SDVecMap
 
typedef SDVecMap::const_iterator SDVecMapConstIter
 
typedef SDVecMap::iterator SDVecMapIter
 
typedef std::map< std::string,
int > 
SIMap
 
typedef SIMap::const_iterator SIMapConstIter
 
typedef SIMap::iterator SIMapIter
 
typedef std::map< std::string,
IVec
SIVecMap
 
typedef SIVecMap::const_iterator SIVecMapConstIter
 
typedef SIVecMap::iterator SIVecMapIter
 
typedef std::map< std::string,
std::string > 
SSMap
 
typedef SSMap::const_iterator SSMapConstIter
 
typedef SSMap::iterator SSMapIter
 
typedef std::map< std::string,
SVec
SSVecMap
 
typedef SSVecMap::const_iterator SSVecMapConstIter
 
typedef SSVecMap::iterator SSVecMapIter
 
typedef std::vector< std::string > SVec
 
typedef SVec::const_iterator SVecConstIter
 
typedef SVec::iterator SVecIter
 

Public Member Functions

void _finishDefaultOptions (std::string tag="")
 
const SVec argVec () const
 
 CommandLineParser (const std::string &usage, unsigned int optionsType=kEventContOpt)
 
void help ()
 
void parseArguments (int argc, char **argv, bool allowArgs=false)
 
void printOptionValues ()
 
void setPrintOptoins (bool print)
 
- Public Member Functions inherited from optutl::VariableMapCont
void _checkKey (std::string &key, const std::string &description="")
 
void addOption (std::string key, OptionType type, const std::string &description="")
 
void addOption (std::string key, OptionType type, const std::string &description, int defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, double defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, const std::string &defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, const char *defaultValue)
 
void addOption (std::string key, OptionType type, const std::string &description, bool defaultValue)
 
void addVariable (std::string key, OptionType type)
 
void addVariable (std::string key, OptionType type, int defaultValue)
 
void addVariable (std::string key, OptionType type, double defaultValue)
 
void addVariable (std::string key, OptionType type, const std::string &defaultValue)
 
void addVariable (std::string key, OptionType type, const char *defaultValue)
 
void addVariable (std::string key, OptionType type, bool defaultValue)
 
bool & boolValue (std::string key)
 
double & doubleValue (std::string key)
 
DVecdoubleVector (std::string key)
 
OptionType hasOption (std::string key)
 
OptionType hasVariable (std::string key)
 
void help ()
 
int & integerValue (std::string key)
 
IVecintegerVector (std::string key)
 
std::string & stringValue (std::string key)
 
SVecstringVector (std::string key)
 
 VariableMapCont ()
 

Static Public Member Functions

static void findCommand (const std::string &line, std::string &command, std::string &rest)
 
static void removeComment (std::string &line)
 
static std::string removeEnding (const std::string &input, const std::string &ending)
 
static void removeLeadingAndTrailingSpaces (std::string &line)
 
static void split (SVec &retval, std::string line, std::string match=" \t", bool ignoreComments=true)
 
- Static Public Member Functions inherited from optutl::VariableMapCont
static void lowercaseString (std::string &arg)
 
static char toLower (char &ch)
 

Static Public Attributes

static const std::string kSpaces = " \t"
 
- Static Public Attributes inherited from optutl::VariableMapCont
static const bool kDefaultBool = false
 
static const double kDefaultDouble = 0.
 
static const int kDefaultInteger = 0
 
static const std::string kDefaultString = ""
 
static const DVec kEmptyDVec
 
static const IVec kEmptyIVec
 
static const SVec kEmptySVec
 

Private Member Functions

void _getSectionFiles (const SVec &inputList, SVec &outputList, int section, int totalSection)
 
bool _runVariableCommandFromString (const std::string &arg)
 
bool _setVariableFromString (const std::string &arg, bool dontOverrideChange=false, int offset=0)
 
bool _setVariablesFromFile (const std::string &filename)
 

Private Attributes

std::string m_argv0
 
SVec m_fullArgVec
 
unsigned int m_optionsType
 
bool m_printOptions
 
std::string m_usageString
 

Friends

std::ostream & operator<< (std::ostream &o_stream, const CommandLineParser &rhs)
 

Additional Inherited Members

- Protected Member Functions inherited from optutl::VariableMapCont
bool _valueHasBeenModified (const std::string &key)
 
- Protected Attributes inherited from optutl::VariableMapCont
SBMap m_boolMap
 
SDMap m_doubleMap
 
SDVecMap m_doubleVecMap
 
SIMap m_integerMap
 
SIVecMap m_integerVecMap
 
SSMap m_stringMap
 
SSVecMap m_stringVecMap
 
SSMap m_variableDescriptionMap
 
SBMap m_variableModifiedMap
 

Detailed Description

Definition at line 11 of file CommandLineParser.h.

Member Enumeration Documentation

anonymous enum
Enumerator
kEventContOpt 

Definition at line 20 of file CommandLineParser.h.

Constructor & Destructor Documentation

CommandLineParser::CommandLineParser ( const std::string &  usage,
unsigned int  optionsType = kEventContOpt 
)

Definition at line 20 of file CommandLineParser.cc.

Member Function Documentation

void CommandLineParser::_finishDefaultOptions ( std::string  tag = "")

Definition at line 753 of file CommandLineParser.cc.

Referenced by fwlite::EventContainer::EventContainer().

void CommandLineParser::_getSectionFiles ( const SVec inputList,
SVec outputList,
int  section,
int  totalSection 
)
private

Definition at line 709 of file CommandLineParser.cc.

bool CommandLineParser::_runVariableCommandFromString ( const std::string &  arg)
private

Definition at line 606 of file CommandLineParser.cc.

bool CommandLineParser::_setVariableFromString ( const std::string &  arg,
bool  dontOverrideChange = false,
int  offset = 0 
)
private

Definition at line 423 of file CommandLineParser.cc.

bool CommandLineParser::_setVariablesFromFile ( const std::string &  filename)
private

Definition at line 545 of file CommandLineParser.cc.

const SVec optutl::CommandLineParser::argVec ( ) const
inline

Definition at line 53 of file CommandLineParser.h.

References m_fullArgVec.

Referenced by fwlite::EventContainer::~EventContainer().

void CommandLineParser::findCommand ( const std::string &  line,
std::string &  command,
std::string &  rest 
)
static

Definition at line 246 of file CommandLineParser.cc.

void CommandLineParser::help ( )

Definition at line 143 of file CommandLineParser.cc.

Referenced by main().

void CommandLineParser::parseArguments ( int  argc,
char **  argv,
bool  allowArgs = false 
)

Definition at line 71 of file CommandLineParser.cc.

Referenced by main().

void CommandLineParser::printOptionValues ( )

Definition at line 271 of file CommandLineParser.cc.

void CommandLineParser::removeComment ( std::string &  line)
static

Definition at line 200 of file CommandLineParser.cc.

string CommandLineParser::removeEnding ( const std::string &  input,
const std::string &  ending 
)
static

Definition at line 233 of file CommandLineParser.cc.

void CommandLineParser::removeLeadingAndTrailingSpaces ( std::string &  line)
static

Definition at line 211 of file CommandLineParser.cc.

void optutl::CommandLineParser::setPrintOptoins ( bool  print)
inline

Definition at line 50 of file CommandLineParser.h.

References m_printOptions, and reco::print().

50 { m_printOptions = print; }
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
Definition: print.cc:10
void CommandLineParser::split ( SVec retval,
std::string  line,
std::string  match = " \t",
bool  ignoreComments = true 
)
static

Definition at line 158 of file CommandLineParser.cc.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o_stream,
const CommandLineParser rhs 
)
friend

Member Data Documentation

const std::string CommandLineParser::kSpaces = " \t"
static

Definition at line 18 of file CommandLineParser.h.

std::string optutl::CommandLineParser::m_argv0
private

Definition at line 132 of file CommandLineParser.h.

SVec optutl::CommandLineParser::m_fullArgVec
private

Definition at line 131 of file CommandLineParser.h.

Referenced by argVec().

unsigned int optutl::CommandLineParser::m_optionsType
private

Definition at line 135 of file CommandLineParser.h.

bool optutl::CommandLineParser::m_printOptions
private

Definition at line 134 of file CommandLineParser.h.

Referenced by setPrintOptoins().

std::string optutl::CommandLineParser::m_usageString
private

Definition at line 133 of file CommandLineParser.h.