#include "timemory/utility/argparse.hpp"
|
| ~argument () |
|
argument & | name (const std::string &name) |
|
argument & | names (const std::vector< std::string > &names) |
|
argument & | description (const std::string &description) |
|
argument & | dtype (const std::string &_dtype) |
|
argument & | required (bool req) |
|
argument & | position (int position) |
|
argument & | max_count (int count) |
|
argument & | min_count (int count) |
|
argument & | count (int count) |
|
template<typename T > |
argument & | set_default (const T &val) |
|
template<typename T > |
argument & | set_default (T &val) |
|
template<typename T > |
argument & | choices (const std::initializer_list< T > &_choices) |
|
template<template< typename... > class ContainerT, typename T , typename... ExtraT, typename ContT = ContainerT<T, ExtraT...>, enable_if_t< helpers::is_container< ContT >::value > = 0> |
argument & | choices (const ContainerT< T, ExtraT... > &_choices) |
|
template<typename ActionFuncT > |
argument & | action (ActionFuncT &&_func) |
|
bool | found () const |
|
template<typename T > |
std::enable_if_t< helpers::is_container< T >::value, T > | get () |
|
template<typename T > |
std::enable_if_t< !helpers::is_container< T >::value &&!std::is_same< T, bool >::value, T > | get () |
|
template<typename T > |
std::enable_if_t< std::is_same< T, bool >::value, T > | get () |
|
size_t | size () const |
|
std::string | get_name () const |
|
Definition at line 360 of file argparse.hpp.
◆ callback_t
◆ Count
◆ Position
Enumerator |
---|
LastArgument | |
IgnoreArgument | |
Definition at line 364 of file argparse.hpp.
◆ ~argument()
tim::argparse::argument_parser::argument::~argument |
( |
| ) |
|
|
inline |
◆ action()
argument & tim::argparse::argument_parser::argument::action |
( |
ActionFuncT && |
_func | ) |
|
|
inline |
◆ choices() [1/2]
template<template< typename... > class ContainerT,
typename T , typename... ExtraT,
typename ContT = ContainerT<T, ExtraT...>,
enable_if_t< helpers::is_container< ContT >::value > = 0>
argument & tim::argparse::argument_parser::argument::choices |
( |
const ContainerT< T, ExtraT... > & |
_choices | ) |
|
|
inline |
Definition at line 483 of file argparse.hpp.
485 for(
auto&& itr : _choices)
487 std::stringstream ss;
489 m_choices.insert(ss.str());
◆ choices() [2/2]
argument & tim::argparse::argument_parser::argument::choices |
( |
const std::initializer_list< T > & |
_choices | ) |
|
|
inline |
◆ count()
argument & tim::argparse::argument_parser::argument::count |
( |
int |
count | ) |
|
|
inline |
◆ description()
argument & tim::argparse::argument_parser::argument::description |
( |
const std::string & |
description | ) |
|
|
inline |
◆ dtype()
argument & tim::argparse::argument_parser::argument::dtype |
( |
const std::string & |
_dtype | ) |
|
|
inline |
◆ found()
bool tim::argparse::argument_parser::argument::found |
( |
| ) |
const |
|
inline |
◆ get() [1/3]
std::enable_if_t< helpers::is_container< T >::value, T > tim::argparse::argument_parser::argument::get |
( |
| ) |
|
|
inline |
Definition at line 504 of file argparse.hpp.
507 typename T::value_type vt;
508 for(
auto& s : m_values)
510 std::istringstream in(s);
512 t.insert(t.end(), vt);
514 if(m_values.empty() && m_default &&
515 m_default_tidx == std::type_index{ typeid(T) })
516 t = (*
static_cast<T*
>(m_default));
◆ get() [2/3]
std::enable_if_t< !helpers::is_container< T >::value &&!std::is_same< T, bool >::value, T > tim::argparse::argument_parser::argument::get |
( |
| ) |
|
|
inline |
Definition at line 523 of file argparse.hpp.
525 auto inp = get<std::string>();
526 std::istringstream iss{ inp };
529 if(inp.empty() && m_default && m_default_tidx == std::type_index{ typeid(T) })
530 t = (*
static_cast<T*
>(m_default));
◆ get() [3/3]
std::enable_if_t< std::is_same< T, bool >::value, T > tim::argparse::argument_parser::argument::get |
( |
| ) |
|
|
inline |
Definition at line 535 of file argparse.hpp.
540 auto inp = get<std::string>();
541 if(inp.empty() && m_default && m_default_tidx == std::type_index{ typeid(T) })
542 return (*
static_cast<T*
>(m_default));
bool get_bool(const std::string &strbool, bool _default) noexcept
References found(), and tim::get_bool().
◆ get_name()
std::string tim::argparse::argument_parser::argument::get_name |
( |
| ) |
const |
|
inline |
Definition at line 551 of file argparse.hpp.
553 std::stringstream ss;
554 for(
const auto& itr : m_names)
556 return ss.str().substr(1);
◆ max_count()
argument & tim::argparse::argument_parser::argument::max_count |
( |
int |
count | ) |
|
|
inline |
◆ min_count()
argument & tim::argparse::argument_parser::argument::min_count |
( |
int |
count | ) |
|
|
inline |
◆ name()
argument & tim::argparse::argument_parser::argument::name |
( |
const std::string & |
name | ) |
|
|
inline |
Definition at line 377 of file argparse.hpp.
379 m_names.push_back(
name);
argument & name(const std::string &name)
References name().
Referenced by name().
◆ names()
argument & tim::argparse::argument_parser::argument::names |
( |
const std::vector< std::string > & |
names | ) |
|
|
inline |
◆ position()
argument & tim::argparse::argument_parser::argument::position |
( |
int |
position | ) |
|
|
inline |
◆ required()
argument & tim::argparse::argument_parser::argument::required |
( |
bool |
req | ) |
|
|
inline |
◆ set_default() [1/2]
argument & tim::argparse::argument_parser::argument::set_default |
( |
const T & |
val | ) |
|
|
inline |
Definition at line 442 of file argparse.hpp.
445 m_default_tidx = std::type_index{
typeid(decay_t<T>) };
446 m_callback = [&](
void*& obj) {
449 obj = (
void*)
new T{};
450 (*
static_cast<T*
>(obj)) = val;
452 m_destroy = [](
void*& obj) {
454 delete static_cast<T*
>(obj);
◆ set_default() [2/2]
argument & tim::argparse::argument_parser::argument::set_default |
( |
T & |
val | ) |
|
|
inline |
Definition at line 460 of file argparse.hpp.
463 m_default_tidx = std::type_index{
typeid(decay_t<T>) };
464 m_callback = [&](
void*& obj) { obj = (
void*) &val; };
◆ size()
size_t tim::argparse::argument_parser::argument::size |
( |
| ) |
const |
|
inline |
Definition at line 549 of file argparse.hpp.
549{
return m_values.size(); }
◆ argument_parser
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & |
os, |
|
|
const argument & |
arg |
|
) |
| |
|
friend |
Definition at line 591 of file argparse.hpp.
593 std::stringstream ss;
595 for(
const auto& itr : arg.m_names)
597 ss <<
", index: " << arg.m_index <<
", count: " << arg.m_count
598 <<
", min count: " << arg.m_min_count <<
", max count: " << arg.m_max_count
599 <<
", found: " << std::boolalpha << arg.m_found
600 <<
", required: " << std::boolalpha << arg.m_required
601 <<
", position: " << arg.m_position <<
", values: ";
602 for(
const auto& itr : arg.m_values)
const std::string std::ostream * os
The documentation for this struct was generated from the following file: