![]() |
MAGE
v0.171.0
Matthias Advanced Game Engine
|
#include <variable_script.hpp>
Public Member Functions | |
| VariableScript (std::wstring fname, bool import=true) | |
| VariableScript (const VariableScript &variable_script)=delete | |
| VariableScript (VariableScript &&variable_script) noexcept | |
| virtual | ~VariableScript () |
| VariableScript & | operator= (const VariableScript &variable_script)=delete |
| VariableScript & | operator= (VariableScript &&variable_script) noexcept |
| void | ImportScript () |
| void | ImportScript (const std::filesystem::path &path) |
| void | ExportScript () const |
| void | ExportScript (const std::filesystem::path &path) const |
| bool | empty () const noexcept |
| std::size_t | size () const noexcept |
| template<typename T = void> | |
| bool | Contains (std::string_view name) const noexcept |
| template<typename T > | |
| void | Add (std::string name, T value) |
| void | Remove (std::string_view name) |
| void | RemoveAll () noexcept |
| template<typename T > | |
| const T * | GetValue (std::string_view name) const |
| template<typename T > | |
| void | SetValue (std::string_view name, T value) |
Public Member Functions inherited from mage::Resource< VariableScript > | |
| Resource (std::wstring guid) noexcept | |
| Resource (const Resource &resource)=delete | |
| Resource (Resource &&resource) noexcept | |
| virtual | ~Resource () |
| Resource & | operator= (const Resource &resource)=delete |
| Resource & | operator= (Resource &&resource) noexcept |
| const std::wstring_view | GetGuid () const noexcept |
| bool | IsFileResource () const |
| const std::filesystem::path | GetPath () const |
Private Attributes | |
| ValueMap | m_variables |
A class of variable scripts.
|
explicit |
Constructs a variable script.
| [in] | fname | The filename (the globally unique identifier). |
| [in] | import | Flag indicating whether the variables of the variable script need to be imported. |
| Exception | Failed to import the variable script from file (only possible if import is equal to true). |
|
delete |
Constructs a variable script from the given variable script.
| [in] | variable_script | A reference to the variable script to copy. |
|
noexcept |
Constructs a variable script by moving the given variable script.
| [in] | variable_script | A reference to the variable script to move. |
|
virtualdefault |
Destruct this variable script.
| void mage::VariableScript::Add | ( | std::string | name, |
| T | value | ||
| ) |
Adds the given variable to this variable script.
| T | The type of the variable. |
| [in] | name | The name of the variable. |
| [in] | value | The value of the variable. |
|
noexcept |
Checks whether this variable script contains a variable with the given name and type (if specified).
| T | The type of the variable. |
| [in] | name | The name of the variable. |
true if this variable script has a variable with the given name. false otherwise.
|
noexcept |
Checks whether this variable script is empty.
true if this variable script is empty. false otherwise. | void mage::VariableScript::ExportScript | ( | ) | const |
Exports this variable script to the file of this variable script.
| Exception | Failed to export the variable script to file. |
| void mage::VariableScript::ExportScript | ( | const std::filesystem::path & | path | ) | const |
Exports this variable script to the file associated with the given path.
| [in] | path | A reference to the path. |
| Exception | Failed to export the variable script to file. |
| const T* mage::VariableScript::GetValue | ( | std::string_view | name | ) | const |
Returns the value of the given variable of this variable script.
| T | The type of the variable. |
| [in] | name | The name of the variable. |
nullptr if this variable script does not contain a variable corresponding to the given name. | std::bad_variant_access | The variable corresponding to the given name has a different type. |
| void mage::VariableScript::ImportScript | ( | ) |
Imports this variable script from the file of this variable script.
| Exception | Failed to import the variable script from file. |
| void mage::VariableScript::ImportScript | ( | const std::filesystem::path & | path | ) |
Imports this variable script from the file associated with the given path.
| [in] | path | A reference to the path. |
| Exception | Failed to import the variable script from file. |
|
delete |
Copies the given variable script to this variable script.
| [in] | variable_script | A reference to the variable script to copy. |
|
noexcept |
Moves the given variable script to this variable script.
| [in] | variable_script | A reference to the variable script to move. |
| void mage::VariableScript::Remove | ( | std::string_view | name | ) |
Removes the given variable from this variable script.
| [in] | name | The name of the variable. |
|
noexcept |
Removes all variables from this variable script.
| void mage::VariableScript::SetValue | ( | std::string_view | name, |
| T | value | ||
| ) |
Sets the value of the given variable in this variable script.
| T | The type of the variable. |
| [in] | name | The name of the variable. |
| [in] | value | The value of the variable. |
|
noexcept |
Returns the number of variables in this variable script.
|
private |
A map containing the variables of this variable script.