ArkScript
A small, fast, functional and scripting language for video games
|
A class to be use C++ objects in ArkScript. More...
#include <UserType.hpp>
Classes | |
struct | ControlFuncs |
A structure holding a bunch of pointers to different useful functions related to this usertype. More... | |
Public Member Functions | |
template<typename T > | |
UserType (T *data=nullptr, ControlFuncs *block=nullptr) noexcept | |
Construct a new User Type object. | |
void | del () |
Free memory through the control functions block. | |
void * | data () const noexcept |
Get the pointer to the object. | |
template<typename T > | |
bool | is () const noexcept |
Check if the object held is of a given type. | |
template<typename T > | |
T & | as () noexcept |
Return the underlying object as a given type. | |
template<typename T > | |
const T & | as () const noexcept |
Private Attributes | |
uint16_t | m_type_id |
void * | m_data |
ControlFuncs * | m_funcs |
Friends | |
ARK_API bool | operator== (const UserType &A, const UserType &B) noexcept |
ARK_API bool | operator< (const UserType &A, const UserType &B) noexcept |
ARK_API std::ostream & | operator<< (std::ostream &os, const UserType &A) noexcept |
A class to be use C++ objects in ArkScript.
A pointer to the value you want to store must be sent, thus the value must not be destroyed while the UserType lives, otherwise it would result in an UB when trying to use the object
Definition at line 49 of file UserType.hpp.
|
inlineexplicitnoexcept |
Construct a new User Type object.
T | the type of the pointer |
data | a pointer to the data to store in the object |
Definition at line 69 of file UserType.hpp.
|
inlinenoexcept |
Definition at line 126 of file UserType.hpp.
References m_data.
|
inlinenoexcept |
Return the underlying object as a given type.
T | the type in which the underlying data pointer should be converted to |
Definition at line 120 of file UserType.hpp.
References m_data.
|
inlinenoexcept |
Get the pointer to the object.
Definition at line 86 of file UserType.hpp.
References m_data.
void Ark::UserType::del | ( | ) |
Free memory through the control functions block.
Definition at line 5 of file UserType.cpp.
References Ark::UserType::ControlFuncs::deleter, m_data, and m_funcs.
|
inlinenoexcept |
Check if the object held is of a given type.
Usage example:
T | the type to use for the test |
Definition at line 108 of file UserType.hpp.
References m_type_id.
Definition at line 16 of file UserType.cpp.
Definition at line 21 of file UserType.cpp.
Definition at line 11 of file UserType.cpp.
|
private |
Definition at line 137 of file UserType.hpp.
|
private |
Definition at line 138 of file UserType.hpp.
Referenced by del().
|
private |
Definition at line 136 of file UserType.hpp.
Referenced by is().