2 virtual-methods.hh -- declare macros for our do-it-yourself RTTI
4 source file of the Flower Library
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #ifndef VIRTUAL_METHODS_HH
10 #define VIRTUAL_METHODS_HH
15 #define classname(class_ptr) demangle_classname (typeid (* (class_ptr)))
18 demangle_classname (type_info const &);
20 /* Virtual copy constructor. Make up for C++'s lack of a standard
21 factory or clone () function. Uses a typeof hack. Usage:
25 VIRTUAL_COPY_CONSTRUCTOR (Baseclass, Foo);
28 #define DECLARE_CLASSNAME(name) \
29 virtual const char *class_name () const { \
33 #define VIRTUAL_COPY_CONSTRUCTOR(Base, name) \
34 DECLARE_CLASSNAME(name);\
35 virtual Base *clone () const \
37 return new name (*this); \
40 #endif /* VIRTUAL_METHODS_HH */