Library of Assembled Shared Sources
lass::io::ArgParser Class Reference

the parser itself More...

#include <arg_parser.h>

Public Member Functions

 ArgParser ()
 Construct a quiet parser.
 
 ArgParser (const std::string &iProgramName, const std::string &iVersion="", const std::string &iPositionalArguments="")
 Construct a not so quiet parser.
 
bool parse (const std::string &iArguments, TArguments *oPositionals=0)
 parse arguments that come by a string.
 
bool parse (const TArguments &iArguments, TArguments *oPositionals=0)
 parse arguments
 
bool parse (int iArgc, char *iArgv[], TArguments *oPositionals=0)
 parse arguments from commandline
 

Detailed Description

the parser itself

Definition at line 98 of file arg_parser.h.

Constructor & Destructor Documentation

◆ ArgParser() [1/2]

lass::io::ArgParser::ArgParser ( )

Construct a quiet parser.

A quiet parser won't write anything to the output (it will still log though), and it will throw as few exceptions as possible

Definition at line 59 of file arg_parser.cpp.

◆ ArgParser() [2/2]

lass::io::ArgParser::ArgParser ( const std::string & iProgramName,
const std::string & iProgramVersion = "",
const std::string & iPositionalArguments = "" )

Construct a not so quiet parser.

On wrong input, it will write info to the standard input and will throw some more exceptions.

Definition at line 72 of file arg_parser.cpp.

Member Function Documentation

◆ parse() [1/3]

bool lass::io::ArgParser::parse ( const std::string & iArguments,
TArguments * oPositionals = 0 )

parse arguments that come by a string.

break string based on whitespace unless it's surrounded by quotes.

Note
You shouldn't start the string with the program name like argc/argv do. The string will be parsed from the beginning, so the program name would be seen as the first positional if you did.

Definition at line 162 of file arg_parser.cpp.

References parse().

Referenced by parse(), and parse().

◆ parse() [2/3]

bool lass::io::ArgParser::parse ( const TArguments & iArguments,
TArguments * oPositionals = 0 )

parse arguments

Note
in contrary like argc/argv , you shouldn't store the program name as the first argument, since the parser will start with iArguments[0] . Hence, the parser would see the program name as the first positional if you did so.

Definition at line 89 of file arg_parser.cpp.

◆ parse() [3/3]

bool lass::io::ArgParser::parse ( int iArgc,
char * iArgv[],
TArguments * oPositionals = 0 )

parse arguments from commandline

Note
we suppose iArgv[0] is the program name and will skipped by the parser. the parser will only take care of iArgv[1] and the following!

Definition at line 146 of file arg_parser.cpp.

References parse().


The documentation for this class was generated from the following files: