![]() |
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 |
Return the underlying object as a given type. | |
Private Attributes | |
uint16_t | m_type_id |
void * | m_data |
ControlFuncs * | m_funcs |
Friends | |
ARK_API bool | operator== (const UserType &A, const UserType &B) |
ARK_API bool | operator< (const UserType &A, const UserType &B) |
ARK_API std::ostream & | operator<< (std::ostream &os, const UserType &A) |
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 47 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 |
block | control function block for the usertype, can be nullptr |
Definition at line 68 of file UserType.hpp.
|
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 131 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 119 of file UserType.hpp.
References m_data.
|
inlinenodiscardnoexcept |
Get the pointer to the object.
Definition at line 85 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.
|
inlinenodiscardnoexcept |
Check if the object held is of a given type.
Usage example:
T | the type to use for the test |
Definition at line 107 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 |
|
private |
Definition at line 143 of file UserType.hpp.
Referenced by del().
|
private |
Definition at line 141 of file UserType.hpp.
Referenced by is().