BNM 2.4.0
 
Loading...
Searching...
No Matches
BNM::Field< T > Struct Template Reference

Typed class for working with il2cpp fields. More...

#include <Field.hpp>

Public Member Functions

constexpr Field () noexcept=default
 Create empty field.
 
template<typename OtherType>
 Field (const Field< OtherType > &other)
 Copy field.
 
 Field (IL2CPP::FieldInfo *info)
 Create field from il2cpp field.
 
 Field (const FieldBase &other)
 Convert base field to typed field.
 
T * GetPointer () const
 Typed wrapper of GetFieldPointer.
 
Get () const
 Get field value.
 
 operator T () const
 Operator to get field value.
 
operator() () const
 Operator to get field value.
 
void Set (T value) const
 Set field value.
 
Field< T > & operator= (T value)
 Operator to set field value.
 
Field< T > & operator[] (void *instance)
 Operator for setting instance.
 
Field< T > & operator[] (IL2CPP::Il2CppObject *instance)
 Operator for setting instance.
 
Field< T > & operator[] (UnityEngine::Object *instance)
 Operator for setting instance.
 
Field< T > & operator= (const FieldBase &other)
 Convert base field to typed.
 
- Public Member Functions inherited from BNM::FieldBase
constexpr FieldBase ()=default
 Create empty field base.
 
 FieldBase (const FieldBase &other)=default
 Copy field.
 
 FieldBase (IL2CPP::FieldInfo *info)
 Create event from il2cpp field.
 
FieldBaseSetInstance (IL2CPP::Il2CppObject *val)
 Set field instance if it's non-static.
 
IL2CPP::FieldInfo * GetInfo () const
 Get FieldInfo.
 
BNM_PTR GetOffset () const
 Get field offset.
 
void * GetFieldPointer () const
 Get field pointer.
 
FieldBaseoperator[] (void *instance)
 Operator for setting instance.
 
FieldBaseoperator[] (IL2CPP::Il2CppObject *instance)
 Operator for setting instance.
 
FieldBaseoperator[] (UnityEngine::Object *instance)
 Operator for setting instance.
 
bool IsValid () const noexcept
 Check if field is valid.
 
std::string str () const
 Get full field name.
 
template<typename NewType>
Field< NewType > & cast () const
 Cast field to be able to get and set it with specified type.
 

Additional Inherited Members

- Public Attributes inherited from BNM::FieldBase
BNM::IL2CPP::FieldInfo * _data {}
 
BNM::IL2CPP::Il2CppObject * _instance {}
 
uint8_t _isStatic: 1 = false
 
uint8_t _isThreadStatic: 1 = false
 
uint8_t _isInStruct: 1 = false
 

Detailed Description

template<typename T>
struct BNM::Field< T >

Typed class for working with il2cpp fields.

This class provides API for getting and setting fields.

Template Parameters
TType of field

Constructor & Destructor Documentation

◆ Field() [1/3]

template<typename T>
template<typename OtherType>
BNM::Field< T >::Field ( const Field< OtherType > & other)
inline

Copy field.

Parameters
otherOther field
Template Parameters
OtherTypeType of other field

◆ Field() [2/3]

template<typename T>
BNM::Field< T >::Field ( IL2CPP::FieldInfo * info)
inline

Create field from il2cpp field.

Parameters
infoIl2cpp field

◆ Field() [3/3]

template<typename T>
BNM::Field< T >::Field ( const FieldBase & other)
inline

Convert base field to typed field.

Parameters
otherBase field

Member Function Documentation

◆ Get()

template<typename T>
T BNM::Field< T >::Get ( ) const
inline

Get field value.

Returns
Field value if it's valid, otherwise default value.

◆ operator=()

template<typename T>
Field< T > & BNM::Field< T >::operator= ( const FieldBase & other)
inline

Convert base field to typed.

Parameters
otherBase field

◆ operator[]() [1/3]

template<typename T>
Field< T > & BNM::Field< T >::operator[] ( IL2CPP::Il2CppObject * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Field

◆ operator[]() [2/3]

template<typename T>
Field< T > & BNM::Field< T >::operator[] ( UnityEngine::Object * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Field

◆ operator[]() [3/3]

template<typename T>
Field< T > & BNM::Field< T >::operator[] ( void * instance)
inline

Operator for setting instance.

Parameters
instanceInstance
Returns
Reference to current Field

◆ Set()

template<typename T>
void BNM::Field< T >::Set ( T value) const
inline

Set field value.

Parameters
valueNew field value