MaxMatrix
Drive chained 8x8 LED dot matrix modules with MAX7219.
Loading...
Searching...
No Matches
max_matrix::Result< ValueType > Class Template Reference

What a getter of a single value returns: the value, or why there is none. More...

#include <MaxMatrixError.h>

Public Member Functions

 Result (ValueType value)
 Makes a result that holds value.
 Result (Error error)
 Makes a result that holds why there is no value.
MAXMATRIX_NODISCARD ValueType GetValue () const
 Returns the value; 0, or what ValueType() is, after an error.
MAXMATRIX_NODISCARD Error GetError () const
 Returns why there is no value, or Error::kOk.
MAXMATRIX_NODISCARD __FlashStringHelper const * GetErrorText () const
 Returns the error in a few words, in flash, for Serial.print().
MAXMATRIX_NODISCARD bool IsOk () const
 Returns whether there is a value.

Friends

bool operator== (Result const &result, Error error)
 Returns whether there is no value for this reason.
bool operator!= (Result const &result, Error error)
 Returns whether there is a value, or none for another reason.

Detailed Description

template<typename ValueType>
class max_matrix::Result< ValueType >

What a getter of a single value returns: the value, or why there is none.

Instead of the value through a pointer beside a status. After an error the value is 0, or what ValueType() is, never undefined. An array cannot be returned, so GetRow() of the whole panel keeps its parameter and returns a Status.

Template Parameters
ValueTypeThe type of the value.

Constructor & Destructor Documentation

◆ Result() [1/2]

template<typename ValueType>
max_matrix::Result< ValueType >::Result ( ValueType value)
inline

Makes a result that holds value.

Implicit, so that a function returns its value as it is.

Parameters
[in]valueThe value.

◆ Result() [2/2]

template<typename ValueType>
max_matrix::Result< ValueType >::Result ( Error error)
inline

Makes a result that holds why there is no value.

Implicit, so that a function returns its error as it is.

Parameters
[in]errorThe error.

Member Function Documentation

◆ GetErrorText()

template<typename ValueType>
MAXMATRIX_NODISCARD __FlashStringHelper const * max_matrix::Result< ValueType >::GetErrorText ( ) const
inline

Returns the error in a few words, in flash, for Serial.print().

"out of range" for Error::kOutOfRange. Serial.print() reads a __FlashStringHelper from flash, so the text needs no RAM. A sketch that never calls it pays nothing, as the linker drops it with its texts.

Returns
The text; "unknown error" for a byte cast to the enum that is none of its values.

◆ operator!=

template<typename ValueType>
bool operator!= ( Result< ValueType > const & result,
Error error )
friend

Returns whether there is a value, or none for another reason.

Parameters
[in]resultThe result of the call.
[in]errorThe error to compare with.

◆ operator==

template<typename ValueType>
bool operator== ( Result< ValueType > const & result,
Error error )
friend

Returns whether there is no value for this reason.

Parameters
[in]resultThe result of the call.
[in]errorThe error to compare with.

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