Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TFieldPtrAccessor< T > Class Template Reference

#include <FieldAccessor.h>

+ Collaboration diagram for TFieldPtrAccessor< T >:

Public Member Functions

 TFieldPtrAccessor (TFunction< T *()> InGet, TFunction< void(T *)> InSet)
 
 TFieldPtrAccessor (T *InValue=nullptr)
 
 TFieldPtrAccessor (const TFieldPtrAccessor &Other)
 
TFieldPtrAccessoroperator= (const TFieldPtrAccessor &Other)=delete
 
TFieldPtrAccessoroperator= (TFieldPtrAccessor &&)=delete
 
Toperator-> () const
 
 operator bool () const
 
 operator T* () const
 
template<typename OtherT >
 operator OtherT * () const
 
bool operator! () const
 
bool operator== (const T *OtherPtr) const
 
bool operator!= (const T *OtherPtr) const
 
TFieldPtrAccessoroperator= (T *OtherPtr)
 

Private Attributes

TCapturedValue = nullptr
 
TFunction< T *()> Get
 
TFunction< void(T *) Set )
 

Detailed Description

template<typename T>
class TFieldPtrAccessor< T >

Helper to provide backward compatibility when converting a raw pointer into accessors.

The helper is trying hard to mimic's a raw pointer field functionality without breaking compatibility for existing code.

The helper's getter are all const and return a non-const pointer. This is because accessing a pointer field inside a const struct will not make that pointer const like we typically do for accessors. Since we want to mimic the behavior of a public field as much as possible, we offer that same functionality.

The helper supports being captured in a lamba as seen below and will become a const copy of the value at the capture's moment. ex: [CapturedValue = Object.OnceARawFieldBecomingAnAccessor]() { // ExtractedValue contains a copy that will not change even if the original Object.OnceARawFieldBecomingAnAccessor changes. const Class* ExtractedValue = CapturedValue; });

This helper also supports taking a nullptr in its constructor so it properly supports conditional like such ex: ExtractedValue* Val = (Condition) ? Object.OnceARawFieldBecomingAnAccessor : nullptr;

A comforming compiler is supposed to try both conversions (nullptr -> TFieldPtrAccessor and TFieldPtrAccessor -> nullptr) but MSVC without the /permissive- flag will only try to cast nullptr into a TFieldPtrAccessor, which has to succeed to avoid breaking compabitility with existing code.

For more info, please refer to https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=vs-2019#ambiguous-conditional-operator-arguments

Definition at line 39 of file FieldAccessor.h.

Constructor & Destructor Documentation

◆ TFieldPtrAccessor() [1/3]

template<typename T >
TFieldPtrAccessor< T >::TFieldPtrAccessor ( TFunction< T *()> InGet,
TFunction< void(T *)> InSet )
inline

Definition at line 43 of file FieldAccessor.h.

◆ TFieldPtrAccessor() [2/3]

template<typename T >
TFieldPtrAccessor< T >::TFieldPtrAccessor ( T * InValue = nullptr)
inline

Definition at line 50 of file FieldAccessor.h.

◆ TFieldPtrAccessor() [3/3]

Definition at line 58 of file FieldAccessor.h.

Member Function Documentation

◆ operator bool()

template<typename T >
TFieldPtrAccessor< T >::operator bool ( ) const
inline

Definition at line 73 of file FieldAccessor.h.

◆ operator OtherT *()

template<typename T >
template<typename OtherT >
TFieldPtrAccessor< T >::operator OtherT * ( ) const
inlineexplicit

Definition at line 84 of file FieldAccessor.h.

◆ operator T*()

template<typename T >
TFieldPtrAccessor< T >::operator T* ( ) const
inline

Definition at line 78 of file FieldAccessor.h.

◆ operator!()

template<typename T >
bool TFieldPtrAccessor< T >::operator! ( ) const
inline

Definition at line 89 of file FieldAccessor.h.

◆ operator!=()

template<typename T >
bool TFieldPtrAccessor< T >::operator!= ( const T * OtherPtr) const
inline

Definition at line 99 of file FieldAccessor.h.

◆ operator->()

template<typename T >
T * TFieldPtrAccessor< T >::operator-> ( ) const
inline

Definition at line 68 of file FieldAccessor.h.

◆ operator=() [1/3]

◆ operator=() [2/3]

template<typename T >
TFieldPtrAccessor & TFieldPtrAccessor< T >::operator= ( T * OtherPtr)
inline

Definition at line 104 of file FieldAccessor.h.

◆ operator=() [3/3]

◆ operator==()

template<typename T >
bool TFieldPtrAccessor< T >::operator== ( const T * OtherPtr) const
inline

Definition at line 94 of file FieldAccessor.h.

Member Data Documentation

◆ CapturedValue

template<typename T >
T* TFieldPtrAccessor< T >::CapturedValue = nullptr
private

Definition at line 112 of file FieldAccessor.h.

◆ Get

template<typename T >
TFunction< T* ()> TFieldPtrAccessor< T >::Get
private

Definition at line 113 of file FieldAccessor.h.

◆ Set

template<typename T >
TFunction<void(T*) TFieldPtrAccessor< T >::Set)
private

Definition at line 114 of file FieldAccessor.h.


The documentation for this class was generated from the following file: