Switchboard SDK
Loading...
Searching...
No Matches
switchboard::SBAny Class Referencefinal

A versatile container class that can hold values of various types. More...

#include <SBAny.hpp>

Public Member Functions

 SBAny (std::monostate)
 SBAny (bool)
 SBAny (int32_t)
 SBAny (int64_t)
 SBAny (uint32_t)
 SBAny (uint64_t)
template<bool Enable = int_is_distinct, typename std::enable_if< Enable, int >::type = 0>
 SBAny (int value)
template<bool Enable = uint_is_distinct, typename std::enable_if< Enable, int >::type = 0>
 SBAny (unsigned int value)
 SBAny (float)
 SBAny (double)
 SBAny (const char *utf8)
 SBAny (const std::string &str)
 SBAny (std::initializer_list< std::pair< std::string, SBAny > > init)
 SBAny (const SBAnyMap &init)
 SBAny (const SBAnyVector &init)
 SBAny (std::initializer_list< SBAny > init)
 SBAny (std::function< Result< SBAny >()> init)
 SBAny (std::function< SBAny()> init)
 SBAny (std::function< Result< void >(const SBAny &)> init)
 SBAny (std::function< void(const SBAny &)> init)
 SBAny (std::function< Result< SBAny >(const SBAnyMap &)> init)
 SBAny (float *init)
 SBAny (const SBAny &)
SBAny & operator= (const SBAny &)
SBAnyType type () const noexcept
std::any toAny () const
void * toPtr () const

Static Public Member Functions

template<typename T>
static T convert (const SBAny &value)

Static Public Attributes

static constexpr bool int_is_distinct
static constexpr bool uint_is_distinct

Detailed Description

A versatile container class that can hold values of various types.

SBAny can store and manage different data types, including primitive types, strings, maps, vectors, functions, and pointers. It provides constructors for each supported type and methods to retrieve the stored value in a type-safe manner.

Member Function Documentation

◆ convert()

template<typename T>
T switchboard::SBAny::convert ( const SBAny & value)
static

Converts an any value to a specific type.

Template Parameters
TThe type to convert to.
Parameters
valueThe value.
Returns
The converted value.

◆ toAny()

std::any switchboard::SBAny::toAny ( ) const

Converts the SBAny value to a std::any.

Returns
The std::any value.

◆ toPtr()

void * switchboard::SBAny::toPtr ( ) const

Converts an any value to a pointer.

Returns
The pointer.

◆ type()

SBAnyType switchboard::SBAny::type ( ) const
noexcept

Gets the type of the SBAny value.

Returns
The SBAnyType.

Member Data Documentation

◆ int_is_distinct

bool switchboard::SBAny::int_is_distinct
staticconstexpr
Initial value:
=
!std::is_same<int, int32_t>::value &&
!std::is_same<int, int64_t>::value

◆ uint_is_distinct

bool switchboard::SBAny::uint_is_distinct
staticconstexpr
Initial value:
=
!std::is_same<unsigned int, uint32_t>::value &&
!std::is_same<unsigned int, uint64_t>::value

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