Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
clara::detail::BasicResult< T > Class Template Reference

#include <clara.hpp>

Inheritance diagram for clara::detail::BasicResult< T >:
Collaboration diagram for clara::detail::BasicResult< T >:

Public Member Functions

template<typename U >
 BasicResult (BasicResult< U > const &other)
 
 operator bool () const
 
auto type () const -> ResultBase::Type
 
auto errorMessage () const -> std::string
 

Static Public Member Functions

template<typename U >
static auto ok (U const &value) -> BasicResult
 
static auto ok () -> BasicResult
 
static auto logicError (std::string const &message) -> BasicResult
 
static auto runtimeError (std::string const &message) -> BasicResult
 

Protected Member Functions

void enforceOk () const override
 
 BasicResult (ResultBase::Type type, std::string const &message)
 
- Protected Member Functions inherited from clara::detail::ResultValueBase< void >
 ResultBase (Type type)
 
- Protected Member Functions inherited from clara::detail::ResultBase
 ResultBase (Type type)
 
virtual ~ResultBase ()=default
 

Protected Attributes

std::string m_errorMessage
 
Type m_type
 
- Protected Attributes inherited from clara::detail::ResultBase
Type m_type
 

Additional Inherited Members

- Public Types inherited from clara::detail::ResultBase
enum  Type { Ok , LogicError , RuntimeError }
 

Detailed Description

template<typename T = void>
class clara::detail::BasicResult< T >

Definition at line 581 of file clara.hpp.

Constructor & Destructor Documentation

◆ BasicResult() [1/2]

template<typename T = void>
template<typename U >
clara::detail::BasicResult< T >::BasicResult ( BasicResult< U > const & other)
inlineexplicit

Definition at line 584 of file clara.hpp.

585 : ResultValueBase<T>( other.type() ),
586 m_errorMessage( other.errorMessage() )
587 {
588 assert( type() != ResultBase::Ok );
589 }
std::string m_errorMessage
Definition clara.hpp:612
auto type() const -> ResultBase::Type
Definition clara.hpp:598
Here is the call graph for this function:

◆ BasicResult() [2/2]

template<typename T = void>
clara::detail::BasicResult< T >::BasicResult ( ResultBase::Type type,
std::string const & message )
inlineprotected

Definition at line 614 of file clara.hpp.

615 : ResultValueBase<T>(type),
616 m_errorMessage(message)
617 {
618 assert( m_type != ResultBase::Ok );
619 }

Member Function Documentation

◆ enforceOk()

template<typename T = void>
void clara::detail::BasicResult< T >::enforceOk ( ) const
inlineoverrideprotectedvirtual

Implements clara::detail::ResultBase.

Definition at line 602 of file clara.hpp.

602 {
603
604 // Errors shouldn't reach this point, but if they do
605 // the actual error message will be in m_errorMessage
606 assert( m_type != ResultBase::LogicError );
607 assert( m_type != ResultBase::RuntimeError );
608 if( m_type != ResultBase::Ok )
609 std::abort();
610 }

◆ errorMessage()

template<typename T = void>
auto clara::detail::BasicResult< T >::errorMessage ( ) const -> std::string
inline

Definition at line 599 of file clara.hpp.

599{ return m_errorMessage; }

◆ logicError()

template<typename T = void>
static auto clara::detail::BasicResult< T >::logicError ( std::string const & message) -> BasicResult
inlinestatic

Definition at line 594 of file clara.hpp.

594{ return { ResultBase::LogicError, message }; }
Here is the caller graph for this function:

◆ ok() [1/2]

template<typename T = void>
static auto clara::detail::BasicResult< T >::ok ( ) -> BasicResult
inlinestatic

Definition at line 593 of file clara.hpp.

593{ return { ResultBase::Ok }; }
Here is the caller graph for this function:

◆ ok() [2/2]

template<typename T = void>
template<typename U >
static auto clara::detail::BasicResult< T >::ok ( U const & value) -> BasicResult
inlinestatic

Definition at line 592 of file clara.hpp.

592{ return { ResultBase::Ok, value }; }
#define value
Definition pkcs11.h:157

◆ operator bool()

template<typename T = void>
clara::detail::BasicResult< T >::operator bool ( ) const
inlineexplicit

Definition at line 597 of file clara.hpp.

597{ return m_type == ResultBase::Ok; }

◆ runtimeError()

template<typename T = void>
static auto clara::detail::BasicResult< T >::runtimeError ( std::string const & message) -> BasicResult
inlinestatic

Definition at line 595 of file clara.hpp.

595{ return { ResultBase::RuntimeError, message }; }
Here is the caller graph for this function:

◆ type()

template<typename T = void>
auto clara::detail::BasicResult< T >::type ( ) const -> ResultBase::Type
inline

Definition at line 598 of file clara.hpp.

598{ return m_type; }
Here is the caller graph for this function:

Member Data Documentation

◆ m_errorMessage

template<typename T = void>
std::string clara::detail::BasicResult< T >::m_errorMessage
protected

Definition at line 612 of file clara.hpp.

◆ m_type

template<typename T = void>
Type clara::detail::ResultBase::m_type
protected

Definition at line 532 of file clara.hpp.


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