ZFFramework
 
Loading...
Searching...
No Matches
ZFCallerInfo.h
Go to the documentation of this file.
1
5#ifndef _ZFI_ZFCallerInfo_h_
6#define _ZFI_ZFCallerInfo_h_
7
8#include "ZFCoreTypeDef.h"
9
11
12extern ZFLIB_ZFCore void _ZFP_ZF_CALLER_FILE_TO_NAME(
14 , ZF_IN const zfchar *filePath
15 );
16extern ZFLIB_ZFCore zfstring _ZFP_ZF_CALLER_FILE_TO_NAME(ZF_IN const zfchar *filePath);
17
26#define ZF_CALLER_FILE_TO_NAME(path) (_ZFP_ZF_CALLER_FILE_TO_NAME(path).cString())
30#define ZF_CALLER_FILE_TO_NAME_REF(ret, path) _ZFP_ZF_CALLER_FILE_TO_NAME(ret, path)
39#define ZF_CALLER_FILE_NAME ZF_CALLER_FILE_TO_NAME(__FILE__)
40
46#define ZF_CALLER_FILE __FILE__
52#define ZF_CALLER_FUNCTION __FUNCTION__
56#define ZF_CALLER_LINE __LINE__
57
58// ============================================================
59// ZFCallerInfo
64public:
74 , ZF_IN const zfchar *callerFunc
76 );
79 ~ZFCallerInfo(void);
80 ZFCallerInfo &operator = (ZF_IN const ZFCallerInfo &ref);
81 zfbool operator == (ZF_IN const ZFCallerInfo &ref) const;
82 inline zfbool operator != (ZF_IN const ZFCallerInfo &ref) const {return !this->operator == (ref);}
83 inline operator zfbool (void) const {return this->valid();}
85
86public:
88 inline const zfchar *callerFile(void) const {return _callerFile;}
90 inline const zfchar *callerFunc(void) const {return _callerFunc;}
92 inline zfuint callerLine(void) const {return _callerLine;}
93
95 inline zfbool valid(void) const {return this->callerFile() != zfnull;}
96
97public:
102 ZF_IN const zfchar *callerFile
103 , ZF_IN const zfchar *callerFunc
105 );
109 inline zfstring callerInfo(void) const {
110 zfstring ret;
111 this->callerInfoT(ret);
112 return ret;
113 }
114public:
116 inline void objectInfoT(ZF_IN_OUT zfstring &ret) const {
117 this->callerInfoT(ret);
118 }
119
120 inline zfstring objectInfo(void) const {
121 zfstring ret;
122 this->objectInfoT(ret);
123 return ret;
124 }
125
126private:
127 zfchar *_callerFileH;
128 zfchar *_callerFuncH;
129 const zfchar *_callerFile;
130 const zfchar *_callerFunc;
131 zfuint _callerLine;
132public:
133 ZFCallerInfo &_ZFP_callerInfo(
134 ZF_IN const zfchar *callerFile
135 , ZF_IN const zfchar *callerFunc
136 , ZF_IN zfuint callerLine
137 ) {
138 this->_callerFile = callerFile;
139 this->_callerFunc = callerFunc;
140 this->_callerLine = callerLine;
141 return *this;
142 }
143};
145
146
149#define ZFCallerInfoCreate() \
150 ZFCallerInfo()._ZFP_callerInfo(ZF_CALLER_FILE, ZF_CALLER_FUNCTION, ZF_CALLER_LINE)
151
152extern ZFLIB_ZFCore const ZFCallerInfo &_ZFP_ZFCallerInfoEmpty(void);
156#define ZFCallerInfoEmpty() _ZFP_ZFCallerInfoEmpty()
157
159#endif // #ifndef _ZFI_ZFCallerInfo_h_
160
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
types for ZFFramework
_ZFT_t_zfchar zfchar
char wrapper
Definition ZFCoreTypeDef_CharType.h:17
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
_ZFT_t_zfuint zfuint
same as unsigned int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:169
#define ZFOUTPUT_TYPE(T_Type, outputAction)
declare your custom type conversion to string, convenient for debug
Definition ZFCoreTypeDef_OtherType.h:221
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
util class to hold caller info
Definition ZFCallerInfo.h:63
ZFCallerInfo(void)
main constructor
void objectInfoT(zfstring &ret) const
see objectInfo
Definition ZFCallerInfo.h:116
zfbool callerInfoT(zfstring &ret) const
return caller info looks like "[File function (line)]"
zfuint callerLine(void) const
see ZF_CALLER_LINE
Definition ZFCallerInfo.h:92
ZFCallerInfo(const zfchar *callerFile, const zfchar *callerFunc, zfuint callerLine)
main constructor
void callerInfo(const zfchar *callerFile, const zfchar *callerFunc, zfuint callerLine)
set the caller info
zfbool valid(void) const
whether valid
Definition ZFCallerInfo.h:95
const zfchar * callerFunc(void) const
see ZF_CALLER_FUNCTION
Definition ZFCallerInfo.h:90
zfstring callerInfo(void) const
return caller info looks like "[File function (line)]"
Definition ZFCallerInfo.h:109
const zfchar * callerFile(void) const
see ZF_CALLER_FILE
Definition ZFCallerInfo.h:88
zfstring objectInfo(void) const
return object info
Definition ZFCallerInfo.h:120