📄 functionaddr.h
字号:
// FunctionAddr.h: interface for the FunctionAddr class.
/*
* Copyright (c) 2006 - 2007 All Rights Reserved
*
* 程序作者:
* 张鲁夺(zhangluduo) : 为所有爱我的人和我爱的人努力!
*
* 联系方式:
* zhangluduo@msn.com
* QQ群:34064264
*
* 更新时间:
* 2007-10-24
*
* 功能描述:
* 这个类用来描述一个C++类成员函数地址
*
* 授权声明:
* 许可任何单位,个人随意使用,拷贝,修改,散布及出售这份代码,及其相关的
* 开发文档,但是必须保留此版权信息,以慰藉作者辛勤的劳动,及表明此代码
* 的来源,如若此份代码有任何BUG或者您有更好的修改建议, 请通知作者,以
* 便弥补作者由于水平所限而导致的一些错误和不足,谢谢!
*/
#ifndef _FUNCTIONADDR_H
#define _FUNCTIONADDR_H
#ifndef _UNION_CAST
#define _UNION_CAST
template <class ToType, class FromType>
ToType union_cast (FromType f)
{
union
{
FromType _f;
ToType _t;
} ut;
ut._f = f;
return ut._t;
}
#endif
class FunctionAddr
{
private:
void* m_pThis;
unsigned long m_FuncAddr;
public:
FunctionAddr() : m_pThis(0), m_FuncAddr(0) { }
~FunctionAddr() {};
FunctionAddr(int n /* = 0*/)
{
if(n != 0)
return ;
m_pThis = 0;
m_FuncAddr = 0;
}
bool IsNull()
{
return m_pThis == 0 && m_FuncAddr == 0 ? true : false;
}
void* GetThisPtr()
{
return m_pThis;
}
unsigned long GetAddr()
{
return m_FuncAddr;
}
template<typename T> void SetAddr(void* pThis, T FunctionNmae)
{
m_pThis = pThis;
m_FuncAddr = union_cast<unsigned long>(FunctionNmae);
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -