stl_list.h
来自「这是整套横扫千军3D版游戏的源码」· C头文件 代码 · 共 47 行
H
47 行
#ifndef CR_LIST_TYPE_IMPL_H
#define CR_LIST_TYPE_IMPL_H
#include <list>
namespace creg {
// IType implemention for std::list
template<typename T>
struct ListType : public IType
{
ListType (IType *t) { elemType = t; }
~ListType () { delete elemType; }
void Serialize (ISerializer *s, void *inst) {
T& ct = *(T*)inst;
if (s->IsWriting ()) {
int size = (int)ct.size();
s->Serialize (&size,sizeof(int));
for (typename T::iterator it = ct.begin(); it!=ct.end(); ++it)
elemType->Serialize (s, &*it);
} else {
int size;
s->Serialize (&size, sizeof(int));
ct.resize (size);
for (typename T::iterator it = ct.begin(); it!=ct.end(); ++it)
elemType->Serialize (s, &*it);
}
}
std::string GetName() { return "list<" + elemType->GetName() + ">"; }
IType *elemType;
};
// List type
template<typename T>
struct DeduceType < std::list <T> > {
IType* Get () {
DeduceType<T> elemtype;
return SAFE_NEW ListType < std::list<T> > (elemtype.Get());
}
};
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?