24#define zfcast(T_To, obj) _ZFP_ObjCast<T_To>::c(obj)
26#define _ZFP_ObjCastInternal(T_To, obj) \
27 static_cast<T_To>(obj)
32template<
typename T_Type,
int isZFObject>
41template<
typename T_Type>
45 return obj ? obj->toObject() :
zfnull;
48template<
typename T_Type>
52 return obj.toObject();
55template<
typename T_Type>
67template<
typename T_ZFObjectTo,
typename T_ZFObjectFrom>
68inline T_ZFObjectTo _ZFP_ObjCastImpl(T_ZFObjectFrom
const &obj) {
75#define _ZFP_ObjCastTypeZFObject 1
76#define _ZFP_ObjCastTypeZFInterface 2
77#define _ZFP_ObjCastTypeUnknown 3
79#define _ZFP_ObjCastType(TrType) \
80 (zftIsZFObject(TrType) \
81 ? (zftIsTypeOf<TrType, ZFObject>::Value \
82 ? _ZFP_ObjCastTypeZFObject \
83 : _ZFP_ObjCastTypeZFInterface \
85 : _ZFP_ObjCastTypeUnknown)
90template<
typename T_To>
93 template<
typename T_From>
94 static inline T_To c(
ZF_IN T_From
const &obj);
96template<
int T_CanCastDirectly,
typename T_To,
typename T_From,
int T_ToType,
int T_FromType>
101template<
typename T_To,
typename T_From,
int T_ToType,
int T_FromType>
102zfclassNotPOD _ZFP_ObjCastH<1, T_To, T_From, T_ToType, T_FromType> {
104 static inline T_To c(
ZF_IN T_From
const &obj) {
105 return static_cast<T_To
>(obj);
109template<
typename T_To,
typename T_From>
110zfclassNotPOD _ZFP_ObjCastH<0, T_To, T_From, _ZFP_ObjCastTypeZFObject, _ZFP_ObjCastTypeZFObject> {
112 static inline T_To c(
ZF_IN T_From
const &obj) {
114 ? _ZFP_ObjCastImpl<T_To>(obj)
119template<
typename T_To,
typename T_From>
120zfclassNotPOD _ZFP_ObjCastH<0, T_To, T_From, _ZFP_ObjCastTypeZFInterface, _ZFP_ObjCastTypeZFObject> {
122 static inline T_To c(
ZF_IN T_From
const &obj) {
124 ?
static_cast<T_To
>(obj->classData()->_ZFP_ZFClass_interfaceCast(
131template<
typename T_To,
typename T_From>
132zfclassNotPOD _ZFP_ObjCastH<0, T_To, T_From, _ZFP_ObjCastTypeZFObject, _ZFP_ObjCastTypeZFInterface> {
134 static inline T_To c(
ZF_IN T_From
const &obj) {
136 ? _ZFP_ObjCastImpl<T_To>(obj->toObject())
141template<
typename T_To,
typename T_From>
142zfclassNotPOD _ZFP_ObjCastH<0, T_To, T_From, _ZFP_ObjCastTypeZFInterface, _ZFP_ObjCastTypeZFInterface> {
144 static inline T_To c(
ZF_IN T_From
const &obj) {
146 ?
static_cast<T_To
>(obj->classData()->_ZFP_ZFClass_interfaceCast(
153template<
typename T_To,
typename T_From,
int T_ToType>
154zfclassNotPOD _ZFP_ObjCastH<0, T_To, T_From, T_ToType, _ZFP_ObjCastTypeUnknown> {
156 static inline T_To c(
ZF_IN T_From
const &obj) {
157 return zfcast(T_To, _ZFP_zfanyCast(obj));
161template<
typename T_To,
typename T_From,
int T_FromType>
162zfclassNotPOD _ZFP_ObjCastH<0, T_To, T_From, _ZFP_ObjCastTypeUnknown, T_FromType> {
164 static inline T_To c(
ZF_IN T_From
const &obj) {
169template<
typename T_To,
typename T_From>
170zfclassNotPOD _ZFP_ObjCastH<0, T_To, T_From, _ZFP_ObjCastTypeUnknown, _ZFP_ObjCastTypeUnknown> {
172 static inline T_To c(
ZF_IN T_From
const &obj) {
173 return T_To(_ZFP_zfanyCast(obj));
178template<
typename T_To>
179template<
typename T_From>
180inline T_To _ZFP_ObjCast<T_To>::c(
ZF_IN T_From
const &obj) {
183 return _ZFP_ObjCastH<
186 _ZFP_ObjCastType(T_ToTmp), _ZFP_ObjCastType(T_FromTmp)
196 template<
typename T_From>
197 static inline const void *c(
ZF_IN T_From
const &obj) {
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:184
#define zfclassNotPOD
shows the class is not a POD type, you should not memset it or declare it in stack or copy value by c...
Definition ZFCoreTypeDef_ClassType.h:48
#define zfnullT
type for zfnull, can be used for function overload
Definition ZFCoreTypeDef_CoreType.h:85
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define zftIsZFObjectType(Type)
true if Type can cast to ZFObject
Definition ZFObjectClassTypeFwd.h:123
#define zftIsZFObject(Type)
true if Type is ZFObject type or ZFInterface type
Definition ZFObjectClassTypeFwd.h:107
base class of all objects
Definition ZFObjectCore.h:205
std::is_base_of wrapper
Definition ZFCoreUtilTemplate.h:461
type traits similar to STL's traits
Definition ZFCoreUtilTemplate.h:100
T_Type TrType
normal type
Definition ZFCoreUtilTemplate.h:107
#define zfcast(T_To, obj)
safely cast ZFObject types, return null if not desired type
Definition zfcast.h:24