OGLplus  (0.59.0) a C++ wrapper for rendering APIs

Class representing a single main function (command-line) argument. More...

#include <eagine/program_args.hpp>

Public Types

using value_type = string_view
 Alias for the argument value type.
 

Public Member Functions

constexpr program_arg () noexcept=default
 Default constructor.
 
auto is_valid () const noexcept -> bool
 Indicates if the arguments is valid.
 
 operator bool () const noexcept
 Indicates if the arguments is valid. More...
 
auto position () const noexcept
 Returns the index of this argument.
 
auto is_first () const noexcept -> bool
 Indicates if this is the first command-line argument.
 
auto is_last () const noexcept -> bool
 Indicates if this is the last command-line argument.
 
auto get () const noexcept -> value_type
 Returns the value of this argument if valid, an empty string view otherwise.
 
auto block () const noexcept -> memory::const_block
 Returns the value of this argument as a const memory block.
 
auto get_string () const -> std::string
 Returns the value of this argument as a standard string.
 
 operator value_type () const noexcept
 Implicit cast to value_type. More...
 
auto starts_with (string_view str) const noexcept
 Indicates if this argument value starts with the specified string. More...
 
auto ends_with (string_view str) const noexcept
 Indicates if this argument value ends with the specified string. More...
 
auto is_tag (string_view tag) const noexcept
 Indicates if this argument value is equal to the specified string.
 
auto is_tag (string_view short_tag, string_view long_tag) const noexcept
 Indicates if this argument value is one of the two specified strings.
 
auto is_tag_param (const basic_program_parameter &param) const
 Indicates if this argument value is equal to the one declared in param.
 
auto is_help_arg () const noexcept
 Indicates if this argument is a "show help" argument (like "--help").
 
auto next () const noexcept -> program_arg
 Returns the argument following this one. More...
 
auto prev () const noexcept -> program_arg
 Returns the argument preceding this one. More...
 
template<typename T , identifier_t V>
auto parse (T &dest, selector< V > sel, std::ostream &parse_log) const -> bool
 Tries to parse this argument's value into dest. More...
 
template<typename T >
auto parse (T &dest, std::ostream &parse_log) const
 Tries to parse this argument's value into dest. More...
 
template<typename T , identifier_t V>
auto parse_next (T &dest, selector< V > sel, std::ostream &parse_log) const
 Tries to parse the following argument's value into dest. More...
 
template<typename T >
auto parse_next (T &dest, std::ostream &parse_log) const
 Tries to parse the following argument's value into dest. More...
 
template<typename T >
auto consume_next (T &dest, std::ostream &errorlog) -> bool
 Tries to parse the following argument's value into dest. More...
 
template<typename T >
auto parse_param (program_parameter< T > &param, std::ostream &errorlog) -> bool
 Tries to parse the specified parameter starting from this argument. More...
 
template<typename T , typename R >
auto consume_next (T &dest, span< const string_view > symbols, span< const R > translations, std::ostream &errorlog) -> bool
 Tries to parse values into starting from the following argument. More...
 
auto operator== (const value_type &v) const noexcept
 Indicates if this argument's value is equal to the specified string.
 
auto operator!= (const value_type &v) const noexcept
 Indicates if this argument's value is different than the specified string.
 

Detailed Description

Class representing a single main function (command-line) argument.

See also
program_args
Note
Do not construct directly. Use program_arguments.

Member Function Documentation

◆ consume_next() [1/2]

template<typename T , typename R >
auto eagine::program_arg::consume_next ( T &  dest,
span< const string_view symbols,
span< const R >  translations,
std::ostream &  errorlog 
) -> bool
inline

Tries to parse values into starting from the following argument.

Returns
True if the parse is successful, false otherwise.

◆ consume_next() [2/2]

template<typename T >
auto eagine::program_arg::consume_next ( T &  dest,
std::ostream &  errorlog 
) -> bool
inline

Tries to parse the following argument's value into dest.

Returns
True if the parse is successful, false otherwise.

◆ ends_with()

auto eagine::program_arg::ends_with ( string_view  str) const
inlinenoexcept

Indicates if this argument value ends with the specified string.

See also
starts_with

◆ next()

auto eagine::program_arg::next ( ) const -> program_arg
inlinenoexcept

Returns the argument following this one.

See also
prev

Referenced by parse_next(), and eagine::program_args::parse_param().

◆ operator bool()

eagine::program_arg::operator bool ( ) const
inlinenoexcept

Indicates if the arguments is valid.

See also
is_valid

◆ operator value_type()

eagine::program_arg::operator value_type ( ) const
inlinenoexcept

Implicit cast to value_type.

See also
get

◆ parse() [1/2]

template<typename T , identifier_t V>
auto eagine::program_arg::parse ( T &  dest,
selector< V >  sel,
std::ostream &  parse_log 
) const -> bool
inline

Tries to parse this argument's value into dest.

Returns
True if the parse is successful, false otherwise.

Referenced by parse().

◆ parse() [2/2]

template<typename T >
auto eagine::program_arg::parse ( T &  dest,
std::ostream &  parse_log 
) const
inline

Tries to parse this argument's value into dest.

Returns
True if the parse is successful, false otherwise.

◆ parse_next() [1/2]

template<typename T , identifier_t V>
auto eagine::program_arg::parse_next ( T &  dest,
selector< V >  sel,
std::ostream &  parse_log 
) const
inline

Tries to parse the following argument's value into dest.

Returns
True if the parse is successful, false otherwise.

Referenced by parse_next().

◆ parse_next() [2/2]

template<typename T >
auto eagine::program_arg::parse_next ( T &  dest,
std::ostream &  parse_log 
) const
inline

Tries to parse the following argument's value into dest.

Returns
True if the parse is successful, false otherwise.

◆ parse_param()

template<typename T >
auto eagine::program_arg::parse_param ( program_parameter< T > &  param,
std::ostream &  errorlog 
) -> bool
inline

Tries to parse the specified parameter starting from this argument.

Returns
True if the parse is successful, false otherwise.

◆ prev()

auto eagine::program_arg::prev ( ) const -> program_arg
inlinenoexcept

Returns the argument preceding this one.

See also
next

◆ starts_with()

auto eagine::program_arg::starts_with ( string_view  str) const
inlinenoexcept

Indicates if this argument value starts with the specified string.

See also
ends_with

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

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).