home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / typeinfo.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-16  |  2.9 KB  |  74 lines

  1. #ifndef _H_TYPEINFO_
  2. #define _H_TYPEINFO_
  3. /********************************************************************/
  4. /*  <typeinfo.h> header file                                        */
  5. /*                                                                  */
  6. /*  VisualAge for C++ for Windows, Version 3.5                      */
  7. /*    Licensed Material - Property of IBM                           */
  8. /*                                                                  */
  9. /*  5801-ARR and Other Materials                                    */
  10. /*                                                                  */
  11. /*  (c) Copyright IBM Corp 1991, 1996. All rights reserved.         */
  12. /*                                                                  */
  13. /********************************************************************/
  14.  
  15. #include <string.h>
  16.  
  17. class type_info {
  18.   public:
  19.     typedef int         Bool;   // typedef to 'bool' when it is supported.
  20.  
  21.     virtual             ~type_info();
  22.     Bool                operator==(const type_info&) const;
  23.     Bool                operator!=(const type_info&) const;
  24.     Bool                before(const type_info&) const;
  25.     const char*         name() const;
  26.  
  27.   private:
  28.                         type_info(const type_info&);
  29.     type_info&          operator=(const type_info&);
  30.  
  31.   protected:
  32.     char *              typeName;
  33.     char *              mangledName;
  34. };
  35.  
  36. class extended_type_info : public type_info {
  37.   public:
  38.                         ~extended_type_info();
  39.     virtual size_t      size() const=0;
  40.     virtual void*       create(void* at) const=0;
  41.     virtual void*       create(void* at, size_t count) const=0;
  42.     virtual void*       copy(void* to, const void* from) const=0;
  43.     virtual void*       copy(void* to, const void* from, size_t count) const=0;
  44.     virtual void*       destroy(void* at) const=0;
  45.     virtual void*       destroy(void* at, size_t count) const=0;
  46.     virtual void*       allocObject() const=0;
  47.     virtual void*       allocArray(size_t count) const=0;
  48.     virtual void        deallocObject(void* at) const=0;
  49.     virtual void        deallocArray(void* at, size_t count) const=0;
  50.     virtual const void* linkageInfo() const=0;
  51.  
  52.   private:
  53.                         extended_type_info(const extended_type_info&);
  54.     extended_type_info& operator=(const extended_type_info&);
  55. };
  56.  
  57. inline const char * type_info::name() const {
  58.   return typeName;
  59. }
  60.  
  61. inline type_info::Bool type_info::operator==(const type_info&x) const {
  62.   return (&x==this) || (strcmp(x.mangledName,this->mangledName)==0);
  63. }
  64.  
  65. inline type_info::Bool type_info::operator!=(const type_info&x) const {
  66.   return (&x!=this) && (strcmp(x.mangledName,this->mangledName)!=0);
  67. }
  68.  
  69. inline type_info::Bool type_info::before(const type_info&x) const {
  70.   return (&x!=this) && (strcmp(x.mangledName,this->mangledName)>=0);
  71. }
  72.  
  73. #endif /* _H_TYPEINFO_ */
  74.