一个很好用的模板(截取网络数据包)

xiaoxiao2021-02-28  81

template <typename T, int minsize = sizeof(T)> class Analizer { private: const char* m_pccPacket; int m_Size; static const int M_MIN_SIZE = minsize; public: void Bind(const char* pccPacket, int size) { m_pccPacket = pccPacket; m_Size = size; }; bool IsValidate() const { if(m_Size >= M_MIN_SIZE) { return true; } else { return false; } } const T* GetObject() const { if(IsValidate()) { return (T*) m_pccPacket; } else { return NULL; } } };

 

转载请注明原文地址: https://www.6miu.com/read-72756.html

最新回复(0)