Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Nz::ParameterList Class Reference

Core class that represents a list of parameters. More...

Public Types

using Destructor = void(*)(void *value)
 

Public Member Functions

 ParameterList (const ParameterList &list)
 Constructs a ParameterList object by copy.
 
 ParameterList (ParameterList &&)=default
 
 ~ParameterList ()
 Destructs the object and clears.
 
void Clear ()
 Clears all the parameters.
 
void ForEach (const std::function< bool(const ParameterList &list, const String &name)> &callback)
 Iterates over every value of the parameter list. More...
 
void ForEach (const std::function< void(const ParameterList &list, const String &name)> &callback) const
 Iterates over every value of the parameter list. More...
 
bool GetBooleanParameter (const String &name, bool *value) const
 Gets a parameter as a boolean. More...
 
bool GetColorParameter (const String &name, Color *value) const
 Gets a parameter as a color. More...
 
bool GetDoubleParameter (const String &name, double *value) const
 Gets a parameter as a double. More...
 
bool GetIntegerParameter (const String &name, long long *value) const
 Gets a parameter as an integer. More...
 
bool GetParameterType (const String &name, ParameterType *type) const
 Gets a parameter type. More...
 
bool GetPointerParameter (const String &name, void **value) const
 Gets a parameter as a pointer. More...
 
bool GetStringParameter (const String &name, String *value) const
 Gets a parameter as a string. More...
 
bool GetUserdataParameter (const String &name, void **value) const
 Gets a parameter as an userdata. More...
 
bool HasParameter (const String &name) const
 Checks whether the parameter list contains a parameter named name More...
 
void RemoveParameter (const String &name)
 Removes the parameter named name More...
 
void SetParameter (const String &name)
 Sets a null parameter named name More...
 
void SetParameter (const String &name, const Color &value)
 Sets a color parameter named name More...
 
void SetParameter (const String &name, const String &value)
 Sets a string parameter named name More...
 
void SetParameter (const String &name, const char *value)
 Sets a string parameter named name More...
 
void SetParameter (const String &name, bool value)
 Sets a boolean parameter named name More...
 
void SetParameter (const String &name, double value)
 Sets a double parameter named name More...
 
void SetParameter (const String &name, long long value)
 Sets an integer parameter named name More...
 
void SetParameter (const String &name, void *value)
 Sets a pointer parameter named name More...
 
void SetParameter (const String &name, void *value, Destructor destructor)
 Sets a userdata parameter named name More...
 
String ToString () const
 Gives a string representation. More...
 
ParameterListoperator= (const ParameterList &list)
 Copies the content of the other parameter list to this. More...
 
ParameterListoperator= (ParameterList &&)=default
 

Detailed Description

Core class that represents a list of parameters.

Member Function Documentation

◆ ForEach() [1/2]

void Nz::ParameterList::ForEach ( const std::function< bool(const ParameterList &list, const String &name)> &  callback)
inline

Iterates over every value of the parameter list.

Parameters
callbackCallback function called with every parameter contained in the list, which can return true to remove the key (or false to keep it)
Remarks
Changing the ParameterList while iterating on it may cause bugs, but querying data is safe.

◆ ForEach() [2/2]

void Nz::ParameterList::ForEach ( const std::function< void(const ParameterList &list, const String &name)> &  callback) const
inline

Iterates over every value of the parameter list.

Parameters
callbackCallback function called with every parameter contained in the list
Remarks
Changing the ParameterList while iterating on it may cause bugs, but querying data is safe.

◆ GetBooleanParameter()

bool Nz::ParameterList::GetBooleanParameter ( const String name,
bool *  value 
) const

Gets a parameter as a boolean.

Returns
true if the parameter could be represented as a boolean
Parameters
nameName of the parameter
valuePointer to a boolean to hold the retrieved value
Remarks
value must be a valid pointer
In case of failure, the variable pointed by value keep its value
If the parameter is not a boolean, a conversion will be performed, compatibles types are: Integer: 0 is interpreted as false, any other value is interpreted as true String: Conversion obeys the rule as described by String::ToBool

◆ GetColorParameter()

bool Nz::ParameterList::GetColorParameter ( const String name,
Color value 
) const

Gets a parameter as a color.

Returns
true if the parameter could be represented as a color
Parameters
nameName of the parameter
valuePointer to a color to hold the retrieved value
Remarks
value must be a valid pointer
In case of failure, the variable pointed by value keep its value
If the parameter is not a color, the function fails

◆ GetDoubleParameter()

bool Nz::ParameterList::GetDoubleParameter ( const String name,
double *  value 
) const

Gets a parameter as a double.

Returns
true if the parameter could be represented as a double
Parameters
nameName of the parameter
valuePointer to a double to hold the retrieved value
Remarks
value must be a valid pointer
In case of failure, the variable pointed by value keep its value
If the parameter is not a double, a conversion will be performed, compatibles types are: Integer: The integer value is converted to its double representation String: Conversion obeys the rule as described by String::ToDouble

◆ GetIntegerParameter()

bool Nz::ParameterList::GetIntegerParameter ( const String name,
long long *  value 
) const

Gets a parameter as an integer.

Returns
true if the parameter could be represented as an integer
Parameters
nameName of the parameter
valuePointer to an integer to hold the retrieved value
Remarks
value must be a valid pointer
In case of failure, the variable pointed by value keep its value
If the parameter is not an integer, a conversion will be performed, compatibles types are: Boolean: The boolean is represented as 1 if true and 0 if false Double: The floating-point value is truncated and converted to a integer String: Conversion obeys the rule as described by String::ToInteger

◆ GetParameterType()

bool Nz::ParameterList::GetParameterType ( const String name,
ParameterType *  type 
) const

Gets a parameter type.

Returns
true if the parameter is present, its type being written to type
Parameters
nameName of the variable
typePointer to a variable to hold the result
Remarks
type must be a valid pointer to a ParameterType variable

◆ GetPointerParameter()

bool Nz::ParameterList::GetPointerParameter ( const String name,
void **  value 
) const

Gets a parameter as a pointer.

Returns
true if the parameter could be represented as a pointer
Parameters
nameName of the parameter
valuePointer to a pointer to hold the retrieved value
Remarks
value must be a valid pointer
In case of failure, the variable pointed by value keep its value
If the parameter is not a pointer, a conversion will be performed, compatibles types are: Userdata: The pointer part of the userdata is returned

◆ GetStringParameter()

bool Nz::ParameterList::GetStringParameter ( const String name,
String value 
) const

Gets a parameter as a string.

Returns
true if the parameter could be represented as a string
Parameters
nameName of the parameter
valuePointer to a pointer to hold the retrieved value
Remarks
value must be a valid pointer
In case of failure, the variable pointed by value keep its value
If the parameter is not a string, a conversion will be performed, all types are compatibles: Boolean: Conversion obeys the rules of String::Boolean Color: Conversion obeys the rules of Color::ToString Double: Conversion obeys the rules of String::Number Integer: Conversion obeys the rules of String::Number None: An empty string is returned Pointer: Conversion obeys the rules of String::Pointer Userdata: Conversion obeys the rules of String::Pointer

◆ GetUserdataParameter()

bool Nz::ParameterList::GetUserdataParameter ( const String name,
void **  value 
) const

Gets a parameter as an userdata.

Returns
true if the parameter could be represented as a userdata
Parameters
nameName of the parameter
valuePointer to a pointer to hold the retrieved value
Remarks
value must be a valid pointer
In case of failure, the variable pointed by value keep its value
If the parameter is not an userdata, the function fails
See also
GetPointerParameter

◆ HasParameter()

bool Nz::ParameterList::HasParameter ( const String name) const

Checks whether the parameter list contains a parameter named name

Returns
true if found
Parameters
nameName of the parameter

◆ operator=()

ParameterList & Nz::ParameterList::operator= ( const ParameterList list)

Copies the content of the other parameter list to this.

Returns
A reference to this
Parameters
listList to assign

◆ RemoveParameter()

void Nz::ParameterList::RemoveParameter ( const String name)

Removes the parameter named name

Search for a parameter named name and remove it from the parameter list, freeing up its memory Nothing is done if the parameter is not present in the parameter list

Parameters
nameName of the parameter

◆ SetParameter() [1/9]

void Nz::ParameterList::SetParameter ( const String name)

Sets a null parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter

◆ SetParameter() [2/9]

void Nz::ParameterList::SetParameter ( const String name,
const Color value 
)

Sets a color parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe color value

◆ SetParameter() [3/9]

void Nz::ParameterList::SetParameter ( const String name,
const String value 
)

Sets a string parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe string value

◆ SetParameter() [4/9]

void Nz::ParameterList::SetParameter ( const String name,
const char *  value 
)

Sets a string parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe string value

◆ SetParameter() [5/9]

void Nz::ParameterList::SetParameter ( const String name,
bool  value 
)

Sets a boolean parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe boolean value

◆ SetParameter() [6/9]

void Nz::ParameterList::SetParameter ( const String name,
double  value 
)

Sets a double parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe double value

◆ SetParameter() [7/9]

void Nz::ParameterList::SetParameter ( const String name,
long long  value 
)

Sets an integer parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe integer value

◆ SetParameter() [8/9]

void Nz::ParameterList::SetParameter ( const String name,
void *  value 
)

Sets a pointer parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe pointer value
Remarks
This sets a raw pointer, this class takes no responsibility toward it, if you wish to destroy the pointed variable along with the parameter list, you should set a userdata

◆ SetParameter() [9/9]

void Nz::ParameterList::SetParameter ( const String name,
void *  value,
Destructor  destructor 
)

Sets a userdata parameter named name

If a parameter already exists with that name, it is destroyed and replaced by this call

Parameters
nameName of the parameter
valueThe pointer value
destructorThe destructor function to be called upon parameter suppression
Remarks
The destructor is called once when all copies of the userdata are destroyed, which means you can safely copy the parameter list around.

◆ ToString()

String Nz::ParameterList::ToString ( ) const

Gives a string representation.

Returns
A string representation of the object: "ParameterList(Name: Type(value), ...)"

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