Skip to content

Class endstone::Object

ClassList > endstone > Object

Base class providing runtime type identification and safe casting. More...

  • #include <endstone/object.h>

Inherited by the following classes: endstone::ItemMeta, endstone::Permissible

Public Functions

Type Name
T * as ()
Attempts to cast this object to the given type T.
const T * as () const
Attempts to cast this object to the given type T.
virtual const std::type_info & getClassTypeId () const = 0
bool is () const
Checks if this object is an instance of the given type T (or a subclass of T).
virtual bool isInstanceOf (const std::type_info & target) const = 0
virtual ~Object () = default

Detailed Description

All endstone types that support runtime type narrowing (e.g., Permissible, ItemMeta) inherit from Object. Subclasses implement getClassTypeId() and isInstanceOf(), and the type hierarchy is registered with entt::meta at startup.

Public Functions Documentation

function as [½]

Attempts to cast this object to the given type T.

template<typename  T>
inline T * endstone::Object::as () 

Returns nullptr if this object is not an instance of T (or a subclass of T).

Template parameters:

  • T Target type to cast to (must derive from Object)

Returns:

Pointer to this as T, or nullptr if the cast is invalid


function as [2/2]

Attempts to cast this object to the given type T.

template<typename  T>
inline const  T * endstone::Object::as () const

Returns nullptr if this object is not an instance of T (or a subclass of T).

Template parameters:

  • T Target type to cast to (must derive from Object)

Returns:

Pointer to this as T, or nullptr if the cast is invalid


function getClassTypeId

virtual const std::type_info & endstone::Object::getClassTypeId () const = 0

function is

Checks if this object is an instance of the given type T (or a subclass of T).

template<typename  T>
inline bool endstone::Object::is () const

Template parameters:

  • T Type to check against (must derive from Object)

Returns:

True if this object is an instance of T


function isInstanceOf

virtual bool endstone::Object::isInstanceOf (
    const std::type_info & target
) const = 0

function ~Object

virtual endstone::Object::~Object () = default


The documentation for this class was generated from the following file include/endstone/object.h