Rumba C++ SDK
maquina::Dict Class Reference

A dictionnary to associate strings to values. More...

#include <Dict.h>

Inheritance diagram for maquina::Dict:
maquina::Value

Classes

class  Values
 A value accessor. More...
 

Public Member Functions

 Dict ()
 
 Dict (const Value &v)
 Cast a Value object in Dict. More...
 
bool has_key (const char *key) const
 Check if a dict entry exists. More...
 
const Value read (const char *key) const
 Get a readable accessor on a dict entry. More...
 
bool as_bool (const char *key) const
 Returns a value as a bool. More...
 
bool as_bool (const char *key, bool default_value) const
 
int as_int (const char *key) const
 Returns the n-th dependency value as an integer. More...
 
int as_int (const char *key, int default_value) const
 
float as_float (const char *key) const
 Returns the n-th dependency value as a float. More...
 
float as_float (const char *key, float default_value) const
 
double as_double (const char *key) const
 Returns the n-th dependency value as a double. More...
 
double as_double (const char *key, double default_value) const
 
const std::string & as_string (const char *key) const
 Returns the n-th dependency value as a string. More...
 
Imath::V2f as_V2f (const char *key) const
 Returns the n-th dependency value as a V2f. More...
 
Imath::V3f as_V3f (const char *key) const
 Returns the n-th dependency value as a V3f. More...
 
Imath::V3f as_V3f (const char *key, const Imath::V3f &default_value) const
 
Imath::V4f as_V4f (const char *key) const
 Returns the n-th dependency value as a V4f. More...
 
const Imath::V2das_V2d (const char *key) const
 Returns the n-th dependency value as a V2d. More...
 
const Imath::V3das_V3d (const char *key) const
 Returns the n-th dependency value as a V3d. More...
 
const Imath::V3das_V3d (const char *key, const Imath::V3d &default_value) const
 
const Imath::V4das_V4d (const char *key) const
 Returns the n-th dependency value as a V4d. More...
 
Imath::M44f as_M44f (const char *key) const
 Returns the n-th dependency value as a M44f. More...
 
const Imath::M44das_M44d (const char *key) const
 Returns the n-th dependency value as a M44d. More...
 
const Imath::Box3fas_Box3f (const char *key) const
 Returns the n-th dependency value as a Box3f. More...
 
Imath::Quatf as_Quatf (const char *key) const
 Returns the n-th dependency value as a Quatf. More...
 
const Imath::Quatdas_Quatd (const char *key) const
 Returns the n-th dependency value as a Quatd. More...
 
Values values () const
 
void insert (const char *key, const Value &value)
 
- Public Member Functions inherited from maquina::Value
 Value ()
 
 Value (Value &&other)=default
 
 Value (const Value &other)=default
 
Valueoperator= (Value &&other)=default
 
Valueoperator= (const Value &other)=default
 
virtual ~Value ()=default
 
Value duplicate () const
 Duplicate the value. More...
 
bool as_bool () const
 Returns the value as a bool. More...
 
int as_int () const
 Returns the value as an integer. More...
 
float as_float () const
 Returns the value as a float. More...
 
double as_double () const
 Returns the value as a double. More...
 
const std::string & as_string () const
 Returns the value as a string. More...
 
std::wstring as_wstring () const
 Returns the value as a wstring. More...
 
Imath::V2f as_V2f () const
 Returns the value as a V2f. More...
 
Imath::V3f as_V3f () const
 Returns the value as a V3f. More...
 
Imath::V4f as_V4f () const
 Returns the value as a V4f. More...
 
const Imath::V2das_V2d () const
 Returns the value as a V2d. More...
 
const Imath::V3das_V3d () const
 Returns the value as a V3d. More...
 
const Imath::V4das_V4d () const
 Returns the value as a V4d. More...
 
const Imath::V2ias_V2i () const
 Returns the value as a V2i. More...
 
const Imath::V3ias_V3i () const
 Returns the value as a V3i. More...
 
const Imath::V4ias_V4i () const
 Returns the value as a V4i. More...
 
Imath::M44f as_M44f () const
 Returns the value as a M44f. More...
 
const Imath::M44das_M44d () const
 Returns the value as a M44d. More...
 
const Imath::Box3fas_Box3f () const
 Returns the value as a Box3f. More...
 
const Imath::Color4fas_Color4f () const
 Returns the value as a Color4f. More...
 
Imath::Quatf as_Quatf () const
 Returns the value as a Quatf. More...
 
const Imath::Quatdas_Quatd () const
 Returns the value as a Quatd. More...
 
std::shared_ptr< const UserDataas_user_data () const
 Returns the value as a user data. More...
 
StringView type_name () const
 Return the type name of the Value. More...
 
virtual bool has_node_delegate () const
 Check if this value can produces a NodeDelegate. More...
 
virtual std::shared_ptr< NodeDelegatenode_delegate (const std::shared_ptr< NodeDelegate > &parent, const StringView &name) const
 
bool operator== (const Value &o) const
 Compare the two values. More...
 
bool operator!= (const Value &o) const
 
bool is_instance (const char *value_type_name) const
 Check if this type derives from another value type. More...
 
 operator bool () const
 
 Value (bool)
 Create a boolean value. More...
 
 Value (int)
 Create an integer value. More...
 
 Value (float)
 Create a float value. More...
 
 Value (double)
 Create a double value (stored in a float right now) More...
 
 Value (const char *string)
 Create a string value. More...
 
 Value (const wchar_t *string)
 Create a string value. More...
 
 Value (const std::string &string)
 Create a string value. More...
 
 Value (const std::wstring &string)
 Create a wide string value. More...
 
 Value (const Imath::V2f &)
 Create a Imath::V2f value. More...
 
 Value (const Imath::V3f &)
 Create a Imath::V3f value. More...
 
 Value (const Imath::V4f &)
 Create a Imath::V4f value. More...
 
 Value (const Imath::V2d &)
 Create a Imath::V2d value. More...
 
 Value (const Imath::V3d &)
 Create a Imath::V3d value. More...
 
 Value (const Imath::V4d &)
 Create a Imath::V4d value. More...
 
 Value (const Imath::V2i &)
 Create a Imath::V2i value. More...
 
 Value (const Imath::V3i &)
 Create a Imath::V3i value. More...
 
 Value (const Imath::V4i &)
 Create a Imath::V4i value. More...
 
 Value (const Imath::Color4f &)
 Create a Imath::Color4f value. More...
 
 Value (const Imath::M44f &)
 Create a Imath::M44f value. More...
 
 Value (const Imath::M44d &)
 Create a Imath::M44d value. More...
 
 Value (const Imath::Box3f &)
 Create a Imath::Box3f value. More...
 
 Value (const Imath::Quatf &)
 Create a Imath::Quatf value. More...
 
 Value (const Imath::Quatd &)
 Create a Imath::Quatd value. More...
 
 Value (const std::shared_ptr< const UserData > &user_data)
 Create a user data value. More...
 

Static Public Attributes

static const Dict default_value
 The default value. More...
 
- Static Public Attributes inherited from maquina::Value
static const Value default_value
 The default value. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from maquina::Value
static bool validate_type_name (const char *type_name)
 Return true if the name is a valid type name. More...
 
static Value get_default_value (const char *type_name)
 Return a default value for a given type. More...
 

Detailed Description

A dictionnary to associate strings to values.

Constructor & Destructor Documentation

◆ Dict() [1/2]

maquina::Dict::Dict ( )

◆ Dict() [2/2]

maquina::Dict::Dict ( const Value v)

Cast a Value object in Dict.

If v has not the good type, a default value is constructed.

Member Function Documentation

◆ as_bool() [1/2]

bool maquina::Dict::as_bool ( const char *  key) const

Returns a value as a bool.

You must be sure this value is an integer, a float or a boolean or you get false.

Parameters
[in]keykey of the value to query

◆ as_bool() [2/2]

bool maquina::Dict::as_bool ( const char *  key,
bool  default_value 
) const

Return the value with key key as a boolean. If a value with such key does not exist or if its type is not convertible to a boolean, return default_value instead.

Parameters
keykey string
default_valuedefault boolean to return

◆ as_Box3f()

const Imath::Box3f& maquina::Dict::as_Box3f ( const char *  key) const

Returns the n-th dependency value as a Box3f.

You must be sure this value is a Box3f or you will have an empty box.

Parameters
[in]keykey of the value to query

◆ as_double() [1/2]

double maquina::Dict::as_double ( const char *  key) const

Returns the n-th dependency value as a double.

You must be sure this value is an integer, a float or a boolean or you get 0.f.

Parameters
[in]keykey of the value to query

◆ as_double() [2/2]

double maquina::Dict::as_double ( const char *  key,
double  default_value 
) const

Return the value with key key as a double. If a value with such key does not exist or if its type is not convertible to a double, return default_value instead.

Parameters
keykey string
default_valuedefault double to return

◆ as_float() [1/2]

float maquina::Dict::as_float ( const char *  key) const

Returns the n-th dependency value as a float.

You must be sure this value is an integer, a float or a boolean or you get 0.f.

Parameters
[in]keykey of the value to query

◆ as_float() [2/2]

float maquina::Dict::as_float ( const char *  key,
float  default_value 
) const

Return the value with key key as a float. If a value with such key does not exist or if its type is not convertible to a float, return default_value instead.

Parameters
keykey string
default_valuedefault float to return

◆ as_int() [1/2]

int maquina::Dict::as_int ( const char *  key) const

Returns the n-th dependency value as an integer.

You must be sure this value is an integer, a float or a boolean or you get 0.

Parameters
[in]keykey of the value to query

◆ as_int() [2/2]

int maquina::Dict::as_int ( const char *  key,
int  default_value 
) const

Return the value with key key as an integer. If a value with such key does not exist or if its type is not convertible to a integer, return default_value instead.

Parameters
keykey string
default_valuedefault integer to return

◆ as_M44d()

const Imath::M44d& maquina::Dict::as_M44d ( const char *  key) const

Returns the n-th dependency value as a M44d.

You must be sure this value is a M44d or you will have an identity matrix.

Parameters
[in]keykey of the value to query

◆ as_M44f()

Imath::M44f maquina::Dict::as_M44f ( const char *  key) const

Returns the n-th dependency value as a M44f.

You must be sure this value is a M44f/M44d or you will have an identity matrix.

Parameters
[in]keykey of the value to query

◆ as_Quatd()

const Imath::Quatd& maquina::Dict::as_Quatd ( const char *  key) const

Returns the n-th dependency value as a Quatd.

You must be sure this value is a Quatd or you will have an identity quaternion.

Parameters
[in]keykey of the value to query

◆ as_Quatf()

Imath::Quatf maquina::Dict::as_Quatf ( const char *  key) const

Returns the n-th dependency value as a Quatf.

You must be sure this value is a Quatf/Quatd or you will have an identity quaternion.

Parameters
[in]keykey of the value to query

◆ as_string()

const std::string& maquina::Dict::as_string ( const char *  key) const

Returns the n-th dependency value as a string.

You must be sure this value is a string or you will have an empty string.

Parameters
[in]keykey of the value to query

◆ as_V2d()

const Imath::V2d& maquina::Dict::as_V2d ( const char *  key) const

Returns the n-th dependency value as a V2d.

You must be sure this value is a V2d or you will have {0,0}.

Parameters
[in]keykey of the value to query

◆ as_V2f()

Imath::V2f maquina::Dict::as_V2f ( const char *  key) const

Returns the n-th dependency value as a V2f.

You must be sure this value is a V2f/V2d or you will have {0,0}.

Parameters
[in]keykey of the value to query

◆ as_V3d() [1/2]

const Imath::V3d& maquina::Dict::as_V3d ( const char *  key) const

Returns the n-th dependency value as a V3d.

You must be sure this value is a V3d or you will have {0,0,0}.

Parameters
[in]keykey of the value to query

◆ as_V3d() [2/2]

const Imath::V3d& maquina::Dict::as_V3d ( const char *  key,
const Imath::V3d default_value 
) const

Return the value with key key as a V3d. If a value with such key does not exist or if its type is not convertible to a V3d, return default_value instead.

Parameters
keykey string
default_valuedefault V3d to return

◆ as_V3f() [1/2]

Imath::V3f maquina::Dict::as_V3f ( const char *  key) const

Returns the n-th dependency value as a V3f.

You must be sure this value is a V3f/V3d or you will have {0,0,0}.

Parameters
[in]keykey of the value to query

◆ as_V3f() [2/2]

Imath::V3f maquina::Dict::as_V3f ( const char *  key,
const Imath::V3f default_value 
) const

Return the value with key key as a V3f. If a value with such key does not exist or if its type is not convertible to a V3f, return default_value instead.

Parameters
keykey string
default_valuedefault V3d to return

◆ as_V4d()

const Imath::V4d& maquina::Dict::as_V4d ( const char *  key) const

Returns the n-th dependency value as a V4d.

You must be sure this value is a V4d or you will have {0,0,0,0}.

Parameters
[in]keykey of the value to query

◆ as_V4f()

Imath::V4f maquina::Dict::as_V4f ( const char *  key) const

Returns the n-th dependency value as a V4f.

You must be sure this value is a V4f/V4d or you will have {0,0,0,0}.

Parameters
[in]keykey of the value to query

◆ has_key()

bool maquina::Dict::has_key ( const char *  key) const

Check if a dict entry exists.

◆ insert()

void maquina::Dict::insert ( const char *  key,
const Value value 
)

Insert a value in the dictionnary. If the key already exists, the value is replaced.

◆ read()

const Value maquina::Dict::read ( const char *  key) const

Get a readable accessor on a dict entry.

◆ values()

Values maquina::Dict::values ( ) const

Member Data Documentation

◆ default_value

const Dict maquina::Dict::default_value
static

The default value.


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