?? header_buf.h
字號(hào):
/*! \mainpage 具有頭部格式的緩沖區(qū)
* \author nodman
* \date 2003-6-11
*/
#ifndef _HEADER_BUF_H
#define _HEADER_BUF_H
/// 處理具有頭部格式的緩沖區(qū)
template<typename T>
class header_buf
{
T* x; ///< buffer with header and followed by data
DWORD s; ///< data size, excluding the header size
public:
header_buf():x(NULL),s(0){}
// size: pure data size, exlcuding the header size
header_buf(T* t, DWORD size):x(NULL), s(0){attach(t,size);}
void attach(T* t, DWORD size)
{
x = t;
s = size;
}
void detach()
{
x = NULL;
s = 0;
}
DWORD data_size() const {return s;}
DWORD header_size() const {return sizeof(T);}
DWORD whole_size() const {return s+header_size();}
operator T*() {return x;}
byte* data() {return ((byte*)x)+header_size();}
T* tail() {return ((byte*)x)+whole_size();}
T* operator->(){return x;}
};
#endif // _HEADER_BUF_H
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -