Documentation for OpenFLUID 2.2.0
openfluid::tools::SettingValue Class Reference

Detailed Description

Stores and manages values for SettingsBackend

#include <tools/SettingsBackend.hpp>

Public Member Functions

 SettingValue ()
 
 SettingValue (bool Val)
 
 SettingValue (int Val)
 
 SettingValue (double Val)
 
 SettingValue (const char *Val)
 
 SettingValue (const std::string &Val)
 
 SettingValue (const std::vector< std::string > &Val)
 
template<typename T >
const T get (const std::optional< T > &DefaultValue=std::nullopt) const
 
const openfluid::thirdparty::json JSONValue () const
 
template<typename T >
bool is () const
 
bool isJSONValue () const
 
bool isNull () const
 

Static Public Member Functions

static SettingValue fromJSON (const openfluid::thirdparty::json &Val)
 

Constructor & Destructor Documentation

◆ SettingValue() [1/7]

openfluid::tools::SettingValue::SettingValue ( )
inline

Constructor of an empty value

See also
isNull()

◆ SettingValue() [2/7]

openfluid::tools::SettingValue::SettingValue ( bool  Val)
inline

Constructor from a boolean value

◆ SettingValue() [3/7]

openfluid::tools::SettingValue::SettingValue ( int  Val)
inline

Constructor from an integer value

◆ SettingValue() [4/7]

openfluid::tools::SettingValue::SettingValue ( double  Val)
inline

Constructor from a double value

◆ SettingValue() [5/7]

openfluid::tools::SettingValue::SettingValue ( const char *  Val)
inline

Constructor from an char* value (mainly for casting to std::string)

◆ SettingValue() [6/7]

openfluid::tools::SettingValue::SettingValue ( const std::string &  Val)
inline

Constructor from a string value

◆ SettingValue() [7/7]

openfluid::tools::SettingValue::SettingValue ( const std::vector< std::string > &  Val)
inline

Constructor from a vector of strings

Member Function Documentation

◆ fromJSON()

static SettingValue openfluid::tools::SettingValue::fromJSON ( const openfluid::thirdparty::json Val)
inlinestatic

Constructor from a native JSON value

◆ get()

template<typename T >
const T openfluid::tools::SettingValue::get ( const std::optional< T > &  DefaultValue = std::nullopt) const
inline

Returns the stored value if it matches the given type. If the stored value dos not match the type, it returns a default value if given, otherwise throws an exception.

Template Parameters
TThe requested type
Parameters
[in]DefaultValueThe value returned by default
Returns
the stored value or the default value

◆ is()

template<typename T >
bool openfluid::tools::SettingValue::is ( ) const
inline

Checks if the stored value matches the given type

Template Parameters
TThe requested type
Returns
true if the type is correct

◆ isJSONValue()

bool openfluid::tools::SettingValue::isJSONValue ( ) const
inline

Returns true if the stored value is a JSON tree

Returns
true if the value is a JSON structure

◆ isNull()

bool openfluid::tools::SettingValue::isNull ( ) const
inline

Check if the value is null (it is neither a stored value nor a JSON tree)

Returns
true if the value is null

◆ JSONValue()

const openfluid::thirdparty::json openfluid::tools::SettingValue::JSONValue ( ) const
inline

Returns if the stored value is a JSON tree, otherwise returns nullptr

Returns
the stored JSON tree

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