args  6.2.0
A simple single-header C++11 STL-only argument parser library
Public Member Functions | List of all members
args::Matcher Class Reference

A class of "matchers", specifying short and flags that can possibly be matched. More...

#include <args.hxx>

Public Member Functions

template<typename ShortIt , typename LongIt >
 Matcher (ShortIt shortFlagsStart, ShortIt shortFlagsEnd, LongIt longFlagsStart, LongIt longFlagsEnd)
 Specify short and long flags separately as iterators. More...
 
template<typename Short , typename Long >
 Matcher (Short &&shortIn, Long &&longIn)
 Specify short and long flags separately as iterables. More...
 
 Matcher (std::initializer_list< EitherFlag > in)
 Specify a mixed single initializer-list of both short and long flags. More...
 
 Matcher (Matcher &&other)
 
bool Match (const char flag) const
 (INTERNAL) Check if there is a match of a short flag
 
bool Match (const std::string &flag) const
 (INTERNAL) Check if there is a match of a long flag
 
bool Match (const EitherFlag &flag) const
 (INTERNAL) Check if there is a match of a flag
 
std::vector< EitherFlagGetFlagStrings () const
 (INTERNAL) Get all flag strings as a vector, with the prefixes embedded
 
EitherFlag GetLongOrAny () const
 (INTERNAL) Get long flag if it exists or any short flag
 
EitherFlag GetShortOrAny () const
 (INTERNAL) Get short flag if it exists or any long flag
 

Detailed Description

A class of "matchers", specifying short and flags that can possibly be matched.

This is supposed to be constructed and then passed in, not used directly from user code.

Constructor & Destructor Documentation

◆ Matcher() [1/3]

template<typename ShortIt , typename LongIt >
args::Matcher::Matcher ( ShortIt  shortFlagsStart,
ShortIt  shortFlagsEnd,
LongIt  longFlagsStart,
LongIt  longFlagsEnd 
)
inline

Specify short and long flags separately as iterators.

ex: args::Matcher(shortFlags.begin(), shortFlags.end(), longFlags.begin(), longFlags.end())

◆ Matcher() [2/3]

template<typename Short , typename Long >
args::Matcher::Matcher ( Short &&  shortIn,
Long &&  longIn 
)
inline

Specify short and long flags separately as iterables.

ex: args::Matcher(shortFlags, longFlags)

◆ Matcher() [3/3]

args::Matcher::Matcher ( std::initializer_list< EitherFlag in)
inline

Specify a mixed single initializer-list of both short and long flags.

This is the fancy one. It takes a single initializer list of any number of any mixed kinds of flags. Chars are automatically interpreted as short flags, and strings are automatically interpreted as long flags:

args::Matcher{'a'}
args::Matcher{"foo"}
args::Matcher{'h', "help"}
args::Matcher{"foo", 'f', 'F', "FoO"}

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