SensESP 3.4.1-alpha
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::Nullable< T > Class Template Reference

Template class that supports a special invalid magic value for a type. More...

#include <sensesp/types/nullable.h>

Public Member Functions

 Nullable ()
 
 Nullable (T value)
 
Nullable< T > & operator= (T &value)
 
Nullable< T > & operator= (const Nullable< T > &other)
 
 operator T () const
 
bool is_valid () const
 
T * ptr ()
 
value () const
 

Static Public Member Functions

static T invalid ()
 

Detailed Description

template<typename T>
class sensesp::Nullable< T >

Template class that supports a special invalid magic value for a type.

Each specialization defines an invalid sentinel (see nullable.cpp; e.g. float -> -1e9, uint8_t -> 0xff), matching the NMEA 2000 "missing data" values. A value is invalid only when it equals that sentinel. A default-constructed Nullable holds T{} (0), so it is valid for types whose sentinel differs from 0; use Nullable<T>::invalid() to obtain the invalid value explicitly.

bool has no spare value to reserve as a sentinel, so Nullable<bool> is an explicit specialization (below) that tracks validity with a separate flag.

Definition at line 21 of file nullable.h.

Constructor & Destructor Documentation

◆ Nullable() [1/2]

template<typename T >
sensesp::Nullable< T >::Nullable ( )
inline

Definition at line 23 of file nullable.h.

◆ Nullable() [2/2]

template<typename T >
sensesp::Nullable< T >::Nullable ( value)
inline

Definition at line 24 of file nullable.h.

Member Function Documentation

◆ invalid()

template<typename T >
static T sensesp::Nullable< T >::invalid ( )
inlinestatic

Definition at line 45 of file nullable.h.

Here is the caller graph for this function:

◆ is_valid()

template<typename T >
bool sensesp::Nullable< T >::is_valid ( ) const
inline

Definition at line 37 of file nullable.h.

Here is the caller graph for this function:

◆ operator T()

template<typename T >
sensesp::Nullable< T >::operator T ( ) const
inline

Definition at line 33 of file nullable.h.

◆ operator=() [1/2]

template<typename T >
Nullable< T > & sensesp::Nullable< T >::operator= ( const Nullable< T > &  other)
inline

Definition at line 29 of file nullable.h.

◆ operator=() [2/2]

template<typename T >
Nullable< T > & sensesp::Nullable< T >::operator= ( T &  value)
inline

Definition at line 25 of file nullable.h.

Here is the call graph for this function:

◆ ptr()

template<typename T >
T * sensesp::Nullable< T >::ptr ( )
inline

Definition at line 41 of file nullable.h.

◆ value()

template<typename T >
T sensesp::Nullable< T >::value ( ) const
inline

Definition at line 49 of file nullable.h.

Here is the caller graph for this function:

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