Fancy argparser
Single file argument parser for c++
Loading...
Searching...
No Matches
ARGPARSE_NAMESPACE_NAME::ArgumentParsed Class Reference

Class which represent actual parsed argument in case of successfully parsing. More...

#include <argparse.h>

Public Member Functions

bool GetArgumentExists ()
 Does argument exists.
size_t GetArgumentCount ()
 get actual count of argument, in case of various arguments count.
bool GetAsBool () const
 Get result as single bool for bool type arguments.
int GetAsInt () const
 Get result as single int for int type arguments.
long long GetAsLongLong () const
 Get result as single long long for long long type arguments.
double GetAsDouble () const
 Get result as single double for double type arguments.
std::string GetAsString () const
 Get result as single string for string type arguments.
std::vector< bool > GetAsVecBool () const
 Get result as vector bool for bool type arguments.
std::vector< int > GetAsVecInt () const
 Get result as vector int for int type arguments.
std::vector< long long > GetAsVecLongLong () const
 Get result as vector long long for long long type arguments.
std::vector< double > GetAsVecDouble () const
 Get result as vector double for double type arguments.
std::vector< std::string > GetAsVecString () const
 Get result as vector string for string type arguments.

Protected Member Functions

 ArgumentParsed ()

Static Protected Member Functions

static void ThrowIfEmpty (bool empty, const char *getter)
 Guard for the scalar getters.

Protected Attributes

bool m_exists { false }
 flag about is argument exists
ArgTypeCast m_type { ArgTypeCast::e_String }
 type of argument
size_t m_count { 0 }
 count of arguments properties
std::vector< bool > m_bool = {}
 container of parsed bool arguments
std::vector< int > m_int = {}
 container of parse int arguments
std::vector< long long > m_longLong = {}
 container of parsed long long arguments
std::vector< double > m_double = {}
 container of parsed double arguments
std::vector< std::string > m_string = {}
 container of parsed string arguments
friend ArgumentsObject

Detailed Description

Class which represent actual parsed argument in case of successfully parsing.

Definition at line 648 of file argparse.h.

Constructor & Destructor Documentation

◆ ArgumentParsed()

ARGPARSE_NAMESPACE_NAME::ArgumentParsed::ArgumentParsed ( )
inlineprotected

Definition at line 810 of file argparse.h.

Member Function Documentation

◆ GetArgumentCount()

size_t ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetArgumentCount ( )
inline

get actual count of argument, in case of various arguments count.

Returns

Definition at line 660 of file argparse.h.

◆ GetArgumentExists()

bool ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetArgumentExists ( )
inline

Does argument exists.

Needed to check in case when argument is not required

Returns
bool value

Definition at line 653 of file argparse.h.

◆ GetAsBool()

bool ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsBool ( ) const
inline

Get result as single bool for bool type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
bool value of argument
Exceptions
std::out_of_rangeif the argument holds no value

Definition at line 669 of file argparse.h.

◆ GetAsDouble()

double ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsDouble ( ) const
inline

Get result as single double for double type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
double value of argument
Exceptions
std::out_of_rangeif the argument holds no value

Definition at line 700 of file argparse.h.

◆ GetAsInt()

int ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsInt ( ) const
inline

Get result as single int for int type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
int value of argument
Exceptions
std::out_of_rangeif the argument holds no value

Definition at line 679 of file argparse.h.

◆ GetAsLongLong()

long long ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsLongLong ( ) const
inline

Get result as single long long for long long type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
long long value of argument
Exceptions
std::out_of_rangeif the argument holds no value

Definition at line 689 of file argparse.h.

◆ GetAsString()

std::string ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsString ( ) const
inline

Get result as single string for string type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
string value of argument (returned by value so it never dangles)
Exceptions
std::out_of_rangeif the argument holds no value

Definition at line 711 of file argparse.h.

◆ GetAsVecBool()

std::vector< bool > ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsVecBool ( ) const
inline

Get result as vector bool for bool type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
vector bool value of argument (by value: safe to store even when called on a temporary ArgumentParsed returned by GetArg())

Definition at line 721 of file argparse.h.

◆ GetAsVecDouble()

std::vector< double > ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsVecDouble ( ) const
inline

Get result as vector double for double type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
vector double value of argument (by value, see GetAsVecBool)

Definition at line 745 of file argparse.h.

◆ GetAsVecInt()

std::vector< int > ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsVecInt ( ) const
inline

Get result as vector int for int type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
vector int value of argument (by value, see GetAsVecBool)

Definition at line 729 of file argparse.h.

◆ GetAsVecLongLong()

std::vector< long long > ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsVecLongLong ( ) const
inline

Get result as vector long long for long long type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
vector long long value of argument (by value, see GetAsVecBool)

Definition at line 737 of file argparse.h.

◆ GetAsVecString()

std::vector< std::string > ARGPARSE_NAMESPACE_NAME::ArgumentParsed::GetAsVecString ( ) const
inline

Get result as vector string for string type arguments.

Added for c++11 support. Starting from c++17 you can use Get()

Returns
vector string value of argument (by value, see GetAsVecBool)

Definition at line 753 of file argparse.h.

◆ ThrowIfEmpty()

void ARGPARSE_NAMESPACE_NAME::ArgumentParsed::ThrowIfEmpty ( bool empty,
const char * getter )
inlinestaticprotected

Guard for the scalar getters.

Turns an out-of-bounds front() (undefined behavior) into a clear, catchable exception. Call GetArgumentExists()/GetArgumentCount() first to avoid it.

Definition at line 815 of file argparse.h.

Member Data Documentation

◆ ArgumentsObject

friend ARGPARSE_NAMESPACE_NAME::ArgumentParsed::ArgumentsObject
protected

Definition at line 842 of file argparse.h.

◆ m_bool

std::vector<bool> ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_bool = {}
protected

container of parsed bool arguments

Definition at line 832 of file argparse.h.

◆ m_count

size_t ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_count { 0 }
protected

count of arguments properties

Definition at line 829 of file argparse.h.

◆ m_double

std::vector<double> ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_double = {}
protected

container of parsed double arguments

Definition at line 838 of file argparse.h.

◆ m_exists

bool ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_exists { false }
protected

flag about is argument exists

Definition at line 825 of file argparse.h.

◆ m_int

std::vector<int> ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_int = {}
protected

container of parse int arguments

Definition at line 834 of file argparse.h.

◆ m_longLong

std::vector<long long> ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_longLong = {}
protected

container of parsed long long arguments

Definition at line 836 of file argparse.h.

◆ m_string

std::vector<std::string> ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_string = {}
protected

container of parsed string arguments

Definition at line 840 of file argparse.h.

◆ m_type

ArgTypeCast ARGPARSE_NAMESPACE_NAME::ArgumentParsed::m_type { ArgTypeCast::e_String }
protected

type of argument

Definition at line 827 of file argparse.h.


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