GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Public Member Functions | List of all members

Class defining a container for gd::Variable. More...

#include <VariablesContainer.h>

Public Member Functions

 VariablesContainer (const VariablesContainer &)
 
VariablesContaineroperator= (const VariablesContainer &rhs)
 
Variables management

Members functions related to variables management.

bool Has (const gd::String &name) const
 Return true if the specified variable is in the container.
 
VariableGet (const gd::String &name)
 Return a reference to the variable called name.
 
const VariableGet (const gd::String &name) const
 Return a reference to the variable called name.
 
VariableGet (std::size_t index)
 Return a reference to the variable at the specified position in the list.
 
const VariableGet (std::size_t index) const
 Return a reference to the variable at the specified position in the list.
 
VariableInsert (const gd::String &name, const Variable &variable, std::size_t position)
 
std::size_t Count () const
 Return the number of variables.
 
const gd::StringGetNameAt (std::size_t index) const
 Return the name of the variable at a position.
 
std::size_t GetPosition (const gd::String &name) const
 return the position of the variable called "name" in the variable list
 
VariableInsertNew (const gd::String &name, std::size_t position=-1)
 Add a new empty variable at the specified position in the container. More...
 
void Remove (const gd::String &name)
 Remove the variable with the specified name from the container. More...
 
void RemoveRecursively (const gd::Variable &variable)
 Remove the specified variable from the container.
 
bool Rename (const gd::String &oldName, const gd::String &newName)
 Rename a variable. More...
 
void Swap (std::size_t firstVariableIndex, std::size_t secondVariableIndex)
 Swap the position of the specified variables.
 
void Move (std::size_t oldIndex, std::size_t newIndex)
 Move the specified variable at a new position in the list.
 
void Clear ()
 Clear all variables of the container.
 
void ForEachVariableMatchingSearch (const gd::String &search, std::function< void(const gd::String &name, const gd::Variable &variable)> fn) const
 Call the callback for each variable with a name matching the specified search.
 
Saving and loading

Members functions related to saving and loading the object.

void SerializeTo (SerializerElement &element) const
 Serialize variable container.
 
void UnserializeFrom (const SerializerElement &element)
 Unserialize the variable container.
 
VariablesContainerResetPersistentUuid ()
 Reset the persistent UUID, used to recognize the same variables between serialization.
 
VariablesContainerClearPersistentUuid ()
 Remove the persistent UUID - when the variables no longer need to be recognized between serializations.
 
const gd::StringGetPersistentUuid () const
 Get the persistent UUID used to recognize the same variables between serialization.
 

Detailed Description

Class defining a container for gd::Variable.

See also
gd::Variable
gd::Project
gd::Layout
gd::Object

Member Function Documentation

◆ Insert()

Variable & gd::VariablesContainer::Insert ( const gd::String name,
const Variable variable,
std::size_t  position 
)

Must add a new variable constructed from the variable passed as parameter.

Note
No pointer or reference must be kept on the variable passed as parameter.
Parameters
variableThe variable that must be copied and inserted into the container
positionInsertion position. If the position is invalid, the variable is inserted at the end of the variable list.
Returns
Reference to the newly added variable

◆ InsertNew()

Variable & gd::VariablesContainer::InsertNew ( const gd::String name,
std::size_t  position = -1 
)

Add a new empty variable at the specified position in the container.

Parameters
nameThe new variable name
positionInsertion position. If the position is invalid, the variable is inserted at the end of the variable list.
Returns
Reference to the newly added variable

◆ Remove()

void gd::VariablesContainer::Remove ( const gd::String name)

Remove the variable with the specified name from the container.

Note
This operation is not recursive on variable children

◆ Rename()

bool gd::VariablesContainer::Rename ( const gd::String oldName,
const gd::String newName 
)

Rename a variable.

Returns
true if the variable was renamed, false otherwise.

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