MADNESS 0.10.1
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
madness::commandlineparser Struct Reference

very simple command line parser More...

#include <commandlineparser.h>

Public Member Functions

 commandlineparser ()
 
 commandlineparser (int argc, char **argv)
 
std::string check_for_input_file (std::string line)
 special option: the input file has no hyphens in front and is just a value
 
bool key_exists (std::string key) const
 
void print_map () const
 
void set_defaults ()
 set default values from the command line
 
void set_keyval (const std::string key, const std::string value)
 
std::string value (const std::string key) const
 

Static Public Member Functions

static std::string base_name (std::string const &path, std::string const &delims="/")
 
static std::string remove_blanks (const std::string arg)
 remove all blanks
 
static std::string remove_extension (std::string const &filename)
 
static std::string remove_first_equal (const std::string arg)
 
static std::string remove_front_hyphens (const std::string arg)
 
static std::vector< std::string > split (std::string s, const std::string delimiter)
 split a string s into a vector of strings, using delimiter
 
static std::string tolower (std::string s)
 make lower case
 
static std::string trim_blanks (const std::string arg)
 remove blanks at the beginning and the end only
 

Public Attributes

std::map< std::string, std::string > keyval
 

Detailed Description

very simple command line parser

parser reads out key/value pairs from the command line of the from –key=val or –key currently no error handling, feel free to add.

Constructor & Destructor Documentation

◆ commandlineparser() [1/2]

madness::commandlineparser::commandlineparser ( )
inline

References set_defaults().

◆ commandlineparser() [2/2]

madness::commandlineparser::commandlineparser ( int  argc,
char **  argv 
)
inline

Member Function Documentation

◆ base_name()

static std::string madness::commandlineparser::base_name ( std::string const &  path,
std::string const &  delims = "/" 
)
inlinestatic

◆ check_for_input_file()

std::string madness::commandlineparser::check_for_input_file ( std::string  line)
inline

special option: the input file has no hyphens in front and is just a value

References split().

Referenced by commandlineparser().

◆ key_exists()

bool madness::commandlineparser::key_exists ( std::string  key) const
inline

◆ print_map()

void madness::commandlineparser::print_map ( ) const
inline

References keyval.

Referenced by main(), and main().

◆ remove_blanks()

static std::string madness::commandlineparser::remove_blanks ( const std::string  arg)
inlinestatic

remove all blanks

References madness::arg().

◆ remove_extension()

static std::string madness::commandlineparser::remove_extension ( std::string const &  filename)
inlinestatic

◆ remove_first_equal()

static std::string madness::commandlineparser::remove_first_equal ( const std::string  arg)
inlinestatic

References madness::arg().

Referenced by commandlineparser().

◆ remove_front_hyphens()

static std::string madness::commandlineparser::remove_front_hyphens ( const std::string  arg)
inlinestatic

References madness::arg().

Referenced by commandlineparser().

◆ set_defaults()

void madness::commandlineparser::set_defaults ( )
inline

set default values from the command line

References keyval.

Referenced by commandlineparser(), and commandlineparser().

◆ set_keyval()

void madness::commandlineparser::set_keyval ( const std::string  key,
const std::string  value 
)
inline

◆ split()

static std::vector< std::string > madness::commandlineparser::split ( std::string  s,
const std::string  delimiter 
)
inlinestatic

split a string s into a vector of strings, using delimiter

Parameters
[in]sthe string (pass by value!)

Referenced by check_for_input_file(), and madness::QCParameter::print_line().

◆ tolower()

static std::string madness::commandlineparser::tolower ( std::string  s)
inlinestatic

◆ trim_blanks()

static std::string madness::commandlineparser::trim_blanks ( const std::string  arg)
inlinestatic

remove blanks at the beginning and the end only

References madness::arg().

Referenced by set_keyval().

◆ value()

std::string madness::commandlineparser::value ( const std::string  key) const
inline

Member Data Documentation

◆ keyval

std::map<std::string, std::string> madness::commandlineparser::keyval

The documentation for this struct was generated from the following file: