GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Public Member Functions | List of all members

Defines a variable which can be used by an object, a layout or a project. More...

#include <Variable.h>

Public Member Functions

 Variable ()
 Default constructor creating a variable with 0 as value.
 
 Variable (const Variable &)
 
Variableoperator= (const Variable &rhs)
 
Number or string

Methods and operators used when the variable is considered as a number or a string.

const gd::StringGetString () const
 Return the content of the variable, considered as a string.
 
void SetString (const gd::String &newStr)
 Change the content of the variable, considered as a string.
 
double GetValue () const
 Return the content of the variable, considered as a number. More...
 
void SetValue (double val)
 Change the content of the variable, considered as a number.
 
void operator= (double val)
 
void operator+= (double val)
 
void operator-= (double val)
 
void operator*= (double val)
 
void operator/= (double val)
 
bool operator<= (double val) const
 
bool operator>= (double val) const
 
bool operator< (double val) const
 
bool operator> (double val) const
 
bool operator== (double val) const
 
bool operator!= (double val) const
 
void operator= (const gd::String &val)
 
void operator+= (const gd::String &val)
 
bool operator== (const gd::String &val) const
 
bool operator!= (const gd::String &val) const
 
bool IsNumber () const
 Return true if the variable is a number.
 
Structure

Methods used when the variable is considered as a structure.

bool IsStructure () const
 Return true if the variable is a structure which can have children.
 
bool HasChild (const gd::String &name) const
 Return true if the variable is a structure and has the specified child.
 
VariableGetChild (const gd::String &name)
 Return the child with the specified name. More...
 
const VariableGetChild (const gd::String &name) const
 Return the child with the specified name. More...
 
void RemoveChild (const gd::String &name)
 Remove the child with the specified name. More...
 
bool RenameChild (const gd::String &oldName, const gd::String &newName)
 Rename the specified child. More...
 
void ClearChildren ()
 Remove all the children. More...
 
size_t GetChildrenCount () const
 Get the count of children that the variable has.
 
std::vector< gd::StringGetAllChildrenNames () const
 Get the names of all children.
 
const std::map< gd::String,
std::shared_ptr< Variable > > & 
GetAllChildren () const
 Get the map containing all the children.
 
bool Contains (const gd::Variable &variableToSearch, bool recursive) const
 Search if a variable is part of the children, optionally recursively.
 
void RemoveRecursively (const gd::Variable &variableToRemove)
 Remove the specified variable if it can be found in the children.
 
Serialization

Methods used when to load or save a variable to XML.

void SaveToXml (TiXmlElement *element) const
 
void LoadFromXml (const TiXmlElement *element)
 
void SerializeTo (SerializerElement &element) const
 Serialize variable.
 
void UnserializeFrom (const SerializerElement &element)
 Unserialize the variable.
 

Detailed Description

Defines a variable which can be used by an object, a layout or a project.

See also
gd::VariablesContainer

Member Function Documentation

void gd::Variable::ClearChildren ( )

Remove all the children.

If the variable is not a structure, nothing is done.

Variable & gd::Variable::GetChild ( const gd::String name)

Return the child with the specified name.

If the variable has not the specified child, an empty variable with the specified name is added as child.

If the variable is not a structure or has not the specified child, an empty variable is returned.

const Variable & gd::Variable::GetChild ( const gd::String name) const

Return the child with the specified name.

If the variable has not the specified child, an empty variable with the specified name is added as child.

If the variable is not a structure or has not the specified child, an empty variable is returned.

double gd::Variable::GetValue ( ) const

Return the content of the variable, considered as a number.

Get value as a double

void gd::Variable::LoadFromXml ( const TiXmlElement *  element)

Called to load the variable from a TiXmlElement.

void gd::Variable::RemoveChild ( const gd::String name)

Remove the child with the specified name.

If the variable is not a structure or has not the specified child, nothing is done.

bool gd::Variable::RenameChild ( const gd::String oldName,
const gd::String newName 
)

Rename the specified child.

If the variable is not a structure or has not the specified child, nothing is done.

Returns
true if the child was renamed, false otherwise.
void gd::Variable::SaveToXml ( TiXmlElement *  element) const

Called to save the variable to a TiXmlElement.


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