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_T(
14 , ZF_IN const zfchar *filePath
15 );
16extern ZFLIB_ZFCore const zfchar *_ZFP_ZF_CALLER_FILE_TO_NAME(ZF_IN const zfchar *filePath);
17extern ZFLIB_ZFCore const zfchar *_ZFP_ZF_CALLER_FUNC_TRIM(ZF_IN const zfchar *filePath);
18
27#define ZF_CALLER_FILE_TO_NAME(path) _ZFP_ZF_CALLER_FILE_TO_NAME(path)
31#define ZF_CALLER_FILE_TO_NAME_T(ret, path) _ZFP_ZF_CALLER_FILE_TO_NAME_T(ret, path)
40#define ZF_CALLER_FILE_NAME ZF_CALLER_FILE_TO_NAME(__FILE__)
41
45#define ZF_CALLER_FILE __FILE__
49#define ZF_CALLER_FUNC __FUNCTION__
53#define ZF_CALLER_FUNC_TRIM _ZFP_ZF_CALLER_FUNC_TRIM(__FUNCTION__)
57#define ZF_CALLER_LINE __LINE__
58
59// ============================================================
60// ZFCallerInfo
65public:
75 , ZF_IN const zfchar *callerFunc
77 );
80 ~ZFCallerInfo(void);
81 ZFCallerInfo &operator = (ZF_IN const ZFCallerInfo &ref);
82 zfbool operator == (ZF_IN const ZFCallerInfo &ref) const;
83 inline zfbool operator != (ZF_IN const ZFCallerInfo &ref) const {return !(this->operator == (ref));}
84 inline operator zfbool (void) const {return this->valid();}
86
87public:
89 inline const zfchar *callerFile(void) const {return _callerFile;}
91 inline const zfchar *callerFunc(void) const {return _callerFunc;}
93 inline zfuint callerLine(void) const {return _callerLine;}
94
96 inline zfbool valid(void) const {return this->callerFile() != zfnull;}
97
98public:
103 ZF_IN const zfchar *callerFile
104 , ZF_IN const zfchar *callerFunc
106 );
110 inline zfstring callerInfo(void) const {
111 zfstring ret;
112 this->callerInfoT(ret);
113 return ret;
114 }
115public:
117 inline void objectInfoT(ZF_IN_OUT zfstring &ret) const {
118 this->callerInfoT(ret);
119 }
120
121 inline zfstring objectInfo(void) const {
122 zfstring ret;
123 this->objectInfoT(ret);
124 return ret;
125 }
126
127private:
128 const zfchar *_callerFile;
129 const zfchar *_callerFunc;
130 zfuint _callerLine;
131 zfbool _needFree;
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_FUNC_TRIM, 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:198
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:214
_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:64
ZFCallerInfo(void)
main constructor
void objectInfoT(zfstring &ret) const
see objectInfo
Definition ZFCallerInfo.h:117
zfbool callerInfoT(zfstring &ret) const
return caller info looks like "[File function (line)]"
zfuint callerLine(void) const
see ZF_CALLER_LINE
Definition ZFCallerInfo.h:93
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:96
const zfchar * callerFunc(void) const
see ZF_CALLER_FUNC
Definition ZFCallerInfo.h:91
zfstring callerInfo(void) const
return caller info looks like "[File function (line)]"
Definition ZFCallerInfo.h:110
const zfchar * callerFile(void) const
see ZF_CALLER_FILE
Definition ZFCallerInfo.h:89
zfstring objectInfo(void) const
return object info
Definition ZFCallerInfo.h:121