libpressio 0.93.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
pressio_option Struct Referencefinal

#include <options.h>

Public Member Functions

 pressio_option ()=default
 
template<class T , typename = typename std::enable_if< !std::is_same<T, pressio_conversion_safety>::value && !std::is_same<T, pressio_option>::value && !std::is_same<T, const char*>::value && !std::is_same<T, void*>::value && !std::is_same<T, compat::monostate>::value >::type>
 pressio_option (compat::optional< T > const &value)
 
template<class T , typename = typename std::enable_if< !std::is_same<T, pressio_conversion_safety>::value && !std::is_same<T, pressio_option>::value && !std::is_same<T, const char*>::value && !std::is_same<T, void*>::value && !std::is_same<T, compat::monostate>::value >::type>
 pressio_option (compat::optional< T > &&value)
 
template<class T , typename = typename std::enable_if< !std::is_same<T, pressio_conversion_safety>::value && !std::is_same<T, pressio_option>::value && !std::is_same<T, const char*>::value && !std::is_same<T, compat::monostate>::value >::type>
 pressio_option (T const &value)
 
 pressio_option (void *value)
 
 pressio_option (compat::monostate value)
 
 pressio_option (const char *value)
 
template<class T >
 pressio_option (std::initializer_list< T > ul)
 
pressio_option as (const enum pressio_option_type type, const enum pressio_conversion_safety safety=pressio_conversion_implicit) const
 
enum pressio_option_type type () const
 
template<class T , typename std::enable_if<!(std::is_same< T, compat::monostate >::value||std::is_same< T, void * >::value), int >::type = 0>
bool holds_alternative () const
 
template<class T , typename std::enable_if< std::is_same< T, void * >::value, int >::type = 0>
bool holds_alternative () const
 
template<class T , typename std::enable_if< std::is_same< T, compat::monostate >::value, int >::type = 0>
bool holds_alternative () const
 
template<class T >
compat::optional< T > const & get () const
 
template<class T , typename std::enable_if< std::is_same< T, void * >::value, int >::type = 0>
void * get_value () const
 
template<class T , typename std::enable_if<!std::is_same< T, void * >::value, int >::type = 0>
T const & get_value () const
 
bool has_value () const
 
template<class T , typename std::enable_if<!std::is_same< T, void * >::value, bool >::type = false>
void set (T v)
 
void set (void *v)
 
void set_type (pressio_option_type type)
 
bool operator== (pressio_option const &rhs) const
 
enum pressio_options_key_status cast_set (struct pressio_option const &rhs, enum pressio_conversion_safety safety=pressio_conversion_implicit)
 

Detailed Description

represents a dynamically typed object

Constructor & Destructor Documentation

◆ pressio_option() [1/7]

pressio_option::pressio_option ( )
default

constructs an option without type or value

◆ pressio_option() [2/7]

template<class T , typename = typename std::enable_if< !std::is_same<T, pressio_conversion_safety>::value && !std::is_same<T, pressio_option>::value && !std::is_same<T, const char*>::value && !std::is_same<T, void*>::value && !std::is_same<T, compat::monostate>::value >::type>
pressio_option::pressio_option ( compat::optional< T > const &  value)
inline

constructs an option that holds the specified value

Parameters
[in]valuethe value the option is to hold

◆ pressio_option() [3/7]

template<class T , typename = typename std::enable_if< !std::is_same<T, pressio_conversion_safety>::value && !std::is_same<T, pressio_option>::value && !std::is_same<T, const char*>::value && !std::is_same<T, void*>::value && !std::is_same<T, compat::monostate>::value >::type>
pressio_option::pressio_option ( compat::optional< T > &&  value)
inline

constructs an option that holds the specified value

Parameters
[in]valuethe value the option is to hold

◆ pressio_option() [4/7]

template<class T , typename = typename std::enable_if< !std::is_same<T, pressio_conversion_safety>::value && !std::is_same<T, pressio_option>::value && !std::is_same<T, const char*>::value && !std::is_same<T, compat::monostate>::value >::type>
pressio_option::pressio_option ( T const &  value)
inline

constructs an option that holds the specified value

Parameters
[in]valuethe value the option is to hold

◆ pressio_option() [5/7]

pressio_option::pressio_option ( compat::monostate  value)
inline

specialization for option to reset the type to hold no type or value

Parameters
[in]valuethe monostate singleton

◆ pressio_option() [6/7]

pressio_option::pressio_option ( const char *  value)
inline

specialization for strings to be compatable with c++11

Parameters
[in]valuethe string value to construct

◆ pressio_option() [7/7]

template<class T >
pressio_option::pressio_option ( std::initializer_list< T >  ul)
inline

create an option from a std::initializer_list

Member Function Documentation

◆ as()

pressio_option pressio_option::as ( const enum pressio_option_type  type,
const enum pressio_conversion_safety  safety = pressio_conversion_implicit 
) const

returns a pressio option that has the appropriate type if the conversion is allowed for the specified safety

Parameters
[in]typethe type to convert to
[in]safetythe level of conversion safety to use
See also
pressio_conversion_safety
Returns
a empty option if no conversion is possible or the converted value as an option

◆ cast_set()

enum pressio_options_key_status pressio_option::cast_set ( struct pressio_option const &  rhs,
enum pressio_conversion_safety  safety = pressio_conversion_implicit 
)
inline

converts rhs according the conversion safety specified to the type of the option and stores the result if the cast succeeds

Parameters
[in]rhsthe option to assign to this option
[in]safetythe specified safety to use
See also
pressio_conversion_safety

◆ get()

template<class T >
compat::optional< T > const & pressio_option::get ( ) const
inline
Returns
a std::optional which holds a value if the option has one or an empty optional otherwise

◆ get_value()

template<class T , typename std::enable_if< std::is_same< T, void * >::value, int >::type = 0>
void * pressio_option::get_value ( ) const
inline

This function has unspecified effects if the option contains no value

See also
has_value
Returns
the value contained by the option

◆ has_value()

bool pressio_option::has_value ( ) const
inline
Returns
true if the option holds a value or false otherwise

◆ holds_alternative() [1/3]

template<class T , typename std::enable_if<!(std::is_same< T, compat::monostate >::value||std::is_same< T, void * >::value), int >::type = 0>
bool pressio_option::holds_alternative ( ) const
inline
Returns
returns true if the option holds the current type

◆ holds_alternative() [2/3]

template<class T , typename std::enable_if< std::is_same< T, void * >::value, int >::type = 0>
bool pressio_option::holds_alternative ( ) const
inline

Specialization for the compat::monostate singleton

Returns
true if the option has no specified type or value

◆ holds_alternative() [3/3]

template<class T , typename std::enable_if< std::is_same< T, compat::monostate >::value, int >::type = 0>
bool pressio_option::holds_alternative ( ) const
inline

Specialization for the compat::monostate singleton

Returns
true if the option has no specified type or value

◆ operator==()

bool pressio_option::operator== ( pressio_option const &  rhs) const
inline
Parameters
[in]rhsthe object to compare against
Returns
true if the options are equal

◆ set()

template<class T , typename std::enable_if<!std::is_same< T, void * >::value, bool >::type = false>
void pressio_option::set ( v)
inline

set the option to a new value

Parameters
[in]vthe value to set the option to

◆ set_type()

void pressio_option::set_type ( pressio_option_type  type)
inline

set only the type of the option

Parameters
[in]typethe type to set the option to

◆ type()

enum pressio_option_type pressio_option::type ( ) const
Returns
the type currently held by the option

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