Templates -- Meow  1.1.2
不能,也不應該先編譯成obj-file的templates
ObjBase.h
Go to the documentation of this file.
1 #ifndef oo_ObjBase_H__
2 #define oo_ObjBase_H__
3 
4 #include <cstdio>
5 
6 #include <typeinfo>
7 #include <string>
8 
9 namespace meow{
10 
16 class ObjBase {
17 protected:
18  ObjBase(){ }
19 public:
20  virtual ~ObjBase(){ }
21  //
22  virtual bool write(FILE* f,bool bin,unsigned int fg) const { return false; }
23  virtual bool read(FILE* f,bool bin,unsigned int fg) { return false; }
24  //
25  virtual ObjBase* create() const { return NULL; }
26  virtual ObjBase* copyFrom(ObjBase const* b) { (*this) = (*b); return this; }
27  //
28  virtual char const* ctype() const{
29  static char const* ptr = typeid(*this).name();
30  return ptr;
31  }
32  virtual std::string type() const{ return std::string(ctype()); }
33  //
34  static char const* ctypeBase(){
35  static char const* ptr = typeid(ObjBase).name();
36  return ptr;
37  }
38  static std::string typeBase(){ return std::string(ctypeBase()); }
39 };
40 
41 }
42 
43 #endif // oo_ObjBase_H__