ZFFramework
 
Loading...
Searching...
No Matches
ZFDynamicInvoker.h File Reference

dynamic invoker util for advanced dynamic impl More...

#include "ZFObjectCore.h"
#include "ZFObjectRetain.h"

Go to the source code of this file.

Classes

class  ZFDI_WrapperBase
 wrapper for unknown types for ZFDI_invoke More...
 
class  ZFDI_Wrapper
 see ZFDI_WrapperBase More...
 
class  ZFDI_WrapperRaw
 see ZFDI_WrapperBase More...
 

Functions

const zfcharZFDI_toString (ZFObject *obj)
 util method to convert to string
 
zfbool ZFDI_toNumberT (zfdouble &ret, ZFObject *obj)
 util method to convert to string
 
zfdouble ZFDI_toNumber (ZFObject *obj)
 see ZFDI_toNumberT, return -1 if fail
 
void ZFDI_paramInfoT (zfstring &ret, const ZFArgs &zfargs)
 util to print param info
 
zfstring ZFDI_paramInfo (const ZFArgs &zfargs)
 see ZFDI_paramInfoT
 
zfindex ZFDI_paramCount (const ZFArgs &zfargs)
 util method to calc param count
 
void ZFDI_invoke (const ZFArgs &zfargs, const zfstring &name, zfbool convStr=_ZFT_t_zffalse)
 perform advanced dynamic invoke
 
void ZFDI_alloc (const ZFArgs &zfargs, const ZFClass *cls, zfbool convStr=_ZFT_t_zffalse)
 perform advanced dynamic class alloc
 
zfbool ZFDI_objectFromString (zfauto &ret, const zfstring &typeId, const zfchar *src, zfindex srcLen=((zfindex) -1), zfstring *errorHint=zft_zfnull)
 util to convert object from string
 
zfbool ZFDI_implicitConvertT (zfauto &ret, const zfstring &desiredTypeId, ZFObject *value, zfstring *errorHint=zft_zfnull)
 try implicit convert if possible
 
zfauto ZFDI_implicitConvert (const zfstring &desiredTypeId, ZFObject *value, zfstring *errorHint=zft_zfnull)
 see ZFDI_implicitConvertT
 
zfauto ZFInvoke (const zfstring &name)
 util to ZFDI_invoke/ZFDI_alloc for static method or object allocation
 
zfauto ZFInvoke (const zfstring &name, ZFObject *param0, ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF))
 see ZFInvoke
 
zfbool ZFInvokeT (zfauto &ret, zfstring *errorHint, const zfstring &name, ZFObject *param0=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param1=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param2=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param3=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param4=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param5=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param6=((ZFObject *const &) _ZFP_ZFMP_DEF), ZFObject *param7=((ZFObject *const &) _ZFP_ZFMP_DEF))
 see ZFInvoke
 
zfauto ZFInvokeDetail (const zfstring &name, const ZFCoreArray< zfauto > &params, zfbool *success=zft_zfnull, zfstring *errorHint=zft_zfnull)
 see ZFInvoke
 
ZFCoreArray< ZFOutput > & ZFDI_errorCallbacks (void)
 callbacks when any dynamic invoker fails
 

Detailed Description

dynamic invoker util for advanced dynamic impl

Function Documentation

◆ ZFDI_toString()

const zfchar * ZFDI_toString ( ZFObject * obj)
extern

util method to convert to string

support these types:

◆ ZFDI_toNumberT()

zfbool ZFDI_toNumberT ( zfdouble & ret,
ZFObject * obj )
extern

util method to convert to string

support these types:

note, for all unsigned type (zfuint for example), ensured converted as -1 for max unsigned value for compatibility

◆ ZFDI_paramInfoT()

void ZFDI_paramInfoT ( zfstring & ret,
const ZFArgs & zfargs )
extern

util to print param info

output format: (Class0)param0, (Class1)param1, ...

◆ ZFDI_invoke()

void ZFDI_invoke ( const ZFArgs & zfargs,
const zfstring & name,
zfbool convStr = _ZFT_t_zffalse )
extern

perform advanced dynamic invoke

note: when mentioned string, we means any type that can be converted by ZFDI_toString

name can be:

  1. "methodName" : only when obj is not null, call class member method
  2. "NS.methodName" : call static method
  3. "NS.ClassName.methodName" : call class static member method
  4. "NS.v_ClassName.methodName" : call class static member method
  5. "NS.ClassName" : use ZFDI_alloc to alloc object
  6. "NS.v_ClassName" : use ZFDI_alloc to alloc object

params can be:

note: null param is also a valid param, you must fill ZFMP_DEF to indicate param end

note: only public methods are allowed to be called by this method, non-public method would result to fail, but you can still explicitly find the method by ZFMethodForName and invoke it by ZFMethod::methodInvoke

◆ ZFDI_alloc()

void ZFDI_alloc ( const ZFArgs & zfargs,
const ZFClass * cls,
zfbool convStr = _ZFT_t_zffalse )
extern

perform advanced dynamic class alloc

use ZFClass::classForName to find class, for the params, see ZFDI_invoke for more info

◆ ZFDI_implicitConvertT()

zfbool ZFDI_implicitConvertT ( zfauto & ret,
const zfstring & desiredTypeId,
ZFObject * value,
zfstring * errorHint = zft_zfnull )
extern

try implicit convert if possible

return original object if value is type of desiredTypeId, or try to construct new object from value

◆ ZFInvoke()

zfauto ZFInvoke ( const zfstring & name)
extern

util to ZFDI_invoke/ZFDI_alloc for static method or object allocation

cases:

NS.ClassName(...) // object allcation
NS.ClassName.MethodName(...) // static member method
NS.MethodName(...) // static method
// type wrapper specials
NS.v_zfstring(...) // type wrapper allcation
NS.zfstring(...) // type wrapper allcation
NS.v_zfstring.MethodName(...) // static member method of type wrapper
NS.zfstring.MethodName(...) // static member method of type wrapper

◆ ZFDI_errorCallbacks()

ZFCoreArray< ZFOutput > & ZFDI_errorCallbacks ( void )
extern

callbacks when any dynamic invoker fails

note: adding anything to this would cause great performance issue, use only if necessary