Sparkle 0.0.1
Loading...
Searching...
No Matches
spk::Expected< TType, TReportStatusType > Class Template Reference

Carries a value alongside a task report status. More...

#include <spk_expected.hpp>

Collaboration diagram for spk::Expected< TType, TReportStatusType >:
Collaboration graph

Public Types

using ReportStatus = TaskResult<TReportStatusType>
 Report status container type.

Public Member Functions

 Expected ()=default
 Builds a default-initialized expected value.
 Expected (const TType &p_value, const TReportStatusType &p_reportStatusID, const std::wstring &p_reportStatusMessage)
 Builds an expected value with a report status.
 Expected (TType &&p_value, const TReportStatusType &p_reportStatusID, const std::wstring &p_reportStatusMessage)
 Builds an expected value by moving the payload and adding a report status.
TType & value ()
 Returns a mutable reference to the stored value.
const TType & value () const
 Returns a const reference to the stored value.
ReportStatusreportStatus ()
 Returns a mutable reference to the report status.
const ReportStatusreportStatus () const
 Returns a const reference to the report status.

Static Public Member Functions

static Expected generateReport (const TReportStatusType &p_reportStatusID, const std::wstring &p_reportStatusMessage)
 Creates an expected value with a default-initialized payload and report status.

Detailed Description

template<typename TType, typename TReportStatusType = size_t>
class spk::Expected< TType, TReportStatusType >

Carries a value alongside a task report status.

Template Parameters
TTypeValue type stored in the expected result.
TReportStatusTypeStatus identifier type for the report.
See also
TaskResult
spk::Expected<int> result(10, 0, L"Ok");
auto &value = result.value();
Carries a value alongside a task report status.
Definition spk_expected.hpp:24
TType & value()
Returns a mutable reference to the stored value.
Definition spk_expected.hpp:78

Constructor & Destructor Documentation

◆ Expected() [1/2]

template<typename TType, typename TReportStatusType = size_t>
spk::Expected< TType, TReportStatusType >::Expected ( const TType & p_value,
const TReportStatusType & p_reportStatusID,
const std::wstring & p_reportStatusMessage )
inlineexplicit

Builds an expected value with a report status.

Parameters
p_valueValue to store.
p_reportStatusIDStatus identifier.
p_reportStatusMessageStatus message.

◆ Expected() [2/2]

template<typename TType, typename TReportStatusType = size_t>
spk::Expected< TType, TReportStatusType >::Expected ( TType && p_value,
const TReportStatusType & p_reportStatusID,
const std::wstring & p_reportStatusMessage )
inlineexplicit

Builds an expected value by moving the payload and adding a report status.

Parameters
p_valueValue to move into the expected instance.
p_reportStatusIDStatus identifier.
p_reportStatusMessageStatus message.

Member Function Documentation

◆ generateReport()

template<typename TType, typename TReportStatusType = size_t>
Expected spk::Expected< TType, TReportStatusType >::generateReport ( const TReportStatusType & p_reportStatusID,
const std::wstring & p_reportStatusMessage )
inlinestatic

Creates an expected value with a default-initialized payload and report status.

Parameters
p_reportStatusIDStatus identifier.
p_reportStatusMessageStatus message.
Returns
Expected value with the report status filled.

◆ reportStatus() [1/2]

template<typename TType, typename TReportStatusType = size_t>
ReportStatus & spk::Expected< TType, TReportStatusType >::reportStatus ( )
inline

Returns a mutable reference to the report status.

Returns
Mutable report status reference.

◆ reportStatus() [2/2]

template<typename TType, typename TReportStatusType = size_t>
const ReportStatus & spk::Expected< TType, TReportStatusType >::reportStatus ( ) const
inline

Returns a const reference to the report status.

Returns
Const report status reference.

◆ value() [1/2]

template<typename TType, typename TReportStatusType = size_t>
TType & spk::Expected< TType, TReportStatusType >::value ( )
inline

Returns a mutable reference to the stored value.

Returns
Mutable value reference.

◆ value() [2/2]

template<typename TType, typename TReportStatusType = size_t>
const TType & spk::Expected< TType, TReportStatusType >::value ( ) const
inline

Returns a const reference to the stored value.

Returns
Const value reference.

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