Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
audacity::sqlite::Result< T > Class Template Referencefinal

A class representing a result of an operation. More...

#include <Result.h>

Public Member Functions

 Result ()=default
 
 Result (T &&value) noexcept(std::is_nothrow_move_constructible_v< T >)
 
 Result (const Error &error) noexcept(std::is_nothrow_copy_constructible_v< Error >)
 
 Result (Error &&error) noexcept(std::is_nothrow_move_constructible_v< Error >)
 
bool HasValue () const noexcept
 
T & operator* () &
 
const T & operator* () const &
 
T * operator-> ()
 
const T * operator-> () const
 
T && operator* () &&
 
 operator bool () const noexcept
 
Error GetError () const noexcept
 

Private Attributes

std::variant< Error, T > mValue
 

Detailed Description

template<typename T>
class audacity::sqlite::Result< T >

A class representing a result of an operation.

Definition at line 18 of file Result.h.

Constructor & Destructor Documentation

◆ Result() [1/4]

template<typename T >
audacity::sqlite::Result< T >::Result ( )
default

◆ Result() [2/4]

template<typename T >
audacity::sqlite::Result< T >::Result ( T &&  value)
inlinenoexcept

Definition at line 23 of file Result.h.

24 : mValue (std::forward<T>(value))
25 {
26 }
std::variant< Error, T > mValue
Definition: Result.h:87

◆ Result() [3/4]

template<typename T >
audacity::sqlite::Result< T >::Result ( const Error error)
inlinenoexcept

Definition at line 28 of file Result.h.

29 : mValue (error)
30 {
31 }

◆ Result() [4/4]

template<typename T >
audacity::sqlite::Result< T >::Result ( Error &&  error)
inlinenoexcept

Definition at line 33 of file Result.h.

34 : mValue (std::move(error))
35 {
36 }

Member Function Documentation

◆ GetError()

template<typename T >
Error audacity::sqlite::Result< T >::GetError ( ) const
inlinenoexcept

Definition at line 79 of file Result.h.

80 {
81 if (HasValue())
82 return Error();
83
84 return *std::get_if<Error>(&mValue);
85 }
bool HasValue() const noexcept
Definition: Result.h:38

References audacity::sqlite::Result< T >::HasValue(), and audacity::sqlite::Result< T >::mValue.

Here is the call graph for this function:

◆ HasValue()

template<typename T >
bool audacity::sqlite::Result< T >::HasValue ( ) const
inlinenoexcept

Definition at line 38 of file Result.h.

39 {
40 return std::holds_alternative<T>(mValue);
41 }

References audacity::sqlite::Result< T >::mValue.

Referenced by audacity::sqlite::Result< T >::GetError(), audacity::sqlite::Result< T >::operator bool(), and audacity::sqlite::Result< T >::operator*().

Here is the caller graph for this function:

◆ operator bool()

template<typename T >
audacity::sqlite::Result< T >::operator bool ( ) const
inlineexplicitnoexcept

Definition at line 74 of file Result.h.

75 {
76 return HasValue();
77 }

References audacity::sqlite::Result< T >::HasValue().

Here is the call graph for this function:

◆ operator*() [1/3]

template<typename T >
T & audacity::sqlite::Result< T >::operator* ( ) &
inline

Definition at line 43 of file Result.h.

44 {
45 if (!HasValue())
46 std::get_if<Error>(&mValue)->Raise();
47
48 return *std::get_if<T>(&mValue);
49 }

References audacity::sqlite::Result< T >::HasValue(), and audacity::sqlite::Result< T >::mValue.

Referenced by audacity::sqlite::Result< T >::operator->().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*() [2/3]

template<typename T >
T && audacity::sqlite::Result< T >::operator* ( ) &&
inline

Definition at line 66 of file Result.h.

67 {
68 if (!HasValue())
69 std::get_if<Error>(&mValue)->Raise();
70
71 return std::move(*std::get_if<T>(&mValue));
72 }

References audacity::sqlite::Result< T >::HasValue(), and audacity::sqlite::Result< T >::mValue.

Here is the call graph for this function:

◆ operator*() [3/3]

template<typename T >
const T & audacity::sqlite::Result< T >::operator* ( ) const &
inline

Definition at line 51 of file Result.h.

52 {
53 return const_cast<Result*>(this)->operator*();
54 }

◆ operator->() [1/2]

template<typename T >
T * audacity::sqlite::Result< T >::operator-> ( )
inline

Definition at line 56 of file Result.h.

57 {
58 return &operator*();
59 }

References audacity::sqlite::Result< T >::operator*().

Here is the call graph for this function:

◆ operator->() [2/2]

template<typename T >
const T * audacity::sqlite::Result< T >::operator-> ( ) const
inline

Definition at line 61 of file Result.h.

62 {
63 return &operator*();
64 }

References audacity::sqlite::Result< T >::operator*().

Here is the call graph for this function:

Member Data Documentation

◆ mValue

template<typename T >
std::variant<Error, T> audacity::sqlite::Result< T >::mValue
private

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