Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
clara::detail::Arg Class Reference

#include <clara.hpp>

Inheritance diagram for clara::detail::Arg:
Collaboration diagram for clara::detail::Arg:

Public Member Functions

auto parse (std::string const &, TokenStream const &tokens) const -> InternalParseResult override
 
 ParserRefImpl (std::shared_ptr< BoundRef > const &ref)
 
template<typename T >
 ParserRefImpl (T &ref, std::string const &hint)
 
template<typename LambdaT >
 ParserRefImpl (LambdaT const &ref, std::string const &hint)
 
- Public Member Functions inherited from clara::detail::ParserRefImpl< Arg >
 ParserRefImpl (T &ref, std::string const &hint)
 
 ParserRefImpl (LambdaT const &ref, std::string const &hint)
 
auto operator() (std::string const &description) -> Arg &
 
auto optional () -> Arg &
 
auto required () -> Arg &
 
auto isOptional () const -> bool
 
auto cardinality () const -> size_t override
 
auto hint () const -> std::string
 
- Public Member Functions inherited from clara::detail::ComposableParserImpl< Arg >
auto operator| (T const &other) const -> Parser
 
auto operator+ (T const &other) const -> Parser
 
- Public Member Functions inherited from clara::detail::ParserBase
virtual ~ParserBase ()=default
 
virtual auto validate () const -> Result
 
auto parse (Args const &args) const -> InternalParseResult
 

Additional Inherited Members

- Protected Member Functions inherited from clara::detail::ParserRefImpl< Arg >
 ParserRefImpl (std::shared_ptr< BoundRef > const &ref)
 
- Protected Attributes inherited from clara::detail::ParserRefImpl< Arg >
Optionality m_optionality
 
std::shared_ptr< BoundRefm_ref
 
std::string m_hint
 
std::string m_description
 

Detailed Description

Definition at line 926 of file clara.hpp.

Member Function Documentation

◆ parse()

auto clara::detail::Arg::parse ( std::string const & ,
TokenStream const & tokens ) const -> InternalParseResult
inlineoverridevirtual

Implements clara::detail::ParserBase.

Definition at line 930 of file clara.hpp.

930 {
931 auto validationResult = validate();
932 if( !validationResult )
933 return InternalParseResult( validationResult );
934
935 auto remainingTokens = tokens;
936 auto const &token = *remainingTokens;
937 if( token.type != TokenType::Argument )
938 return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );
939
940 assert( !m_ref->isFlag() );
941 auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );
942
943 auto result = valueRef->setValue( remainingTokens->token );
944 if( !result )
945 return InternalParseResult( result );
946 else
947 return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );
948 }
static auto ok() -> BasicResult
Definition clara.hpp:593
virtual auto validate() const -> Result
Definition clara.hpp:812
std::shared_ptr< BoundRef > m_ref
Definition clara.hpp:836
BasicResult< ParseState > InternalParseResult
Definition clara.hpp:647
Here is the call graph for this function:

◆ ParserRefImpl() [1/3]

template<typename LambdaT >
clara::detail::ParserRefImpl< DerivedT >::ParserRefImpl ( LambdaT const & ref,
std::string const & hint )
inline

Definition at line 850 of file clara.hpp.

851 : m_ref( std::make_shared<BoundLambda<LambdaT>>( ref ) ),
852 m_hint(hint)
853 {}
auto hint() const -> std::string
Definition clara.hpp:881

◆ ParserRefImpl() [2/3]

clara::detail::ParserRefImpl< DerivedT >::ParserRefImpl ( std::shared_ptr< BoundRef > const & ref)
inlineexplicit

Definition at line 840 of file clara.hpp.

840: m_ref( ref ) {}

◆ ParserRefImpl() [3/3]

template<typename T >
clara::detail::ParserRefImpl< DerivedT >::ParserRefImpl ( T & ref,
std::string const & hint )
inline

Definition at line 844 of file clara.hpp.

845 : m_ref( std::make_shared<BoundValueRef<T>>( ref ) ),
846 m_hint( hint )
847 {}

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