Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

typeinfo

Go to the documentation of this file.
00001 // RTTI support for -*- C++ -*-
00002 // Copyright (C) 1994, 1995, 1996, 1997, 1998, 2000, 2001 Free Software Foundation
00003 //
00004 // This file is part of GNU CC.
00005 //
00006 // GNU CC is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 // 
00011 // GNU CC is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // 
00016 // You should have received a copy of the GNU General Public License
00017 // along with GNU CC; see the file COPYING.  If not, write to
00018 // the Free Software Foundation, 59 Temple Place - Suite 330,
00019 // Boston, MA 02111-1307, USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00034 #ifndef __TYPEINFO__
00035 #define __TYPEINFO__
00036 
00037 #include <exception>
00038 
00039 extern "C++" {
00040 
00041 namespace __cxxabiv1
00042 {
00043   class __class_type_info;
00044 } // namespace __cxxabiv1
00045 
00046 #if !__GXX_WEAK__
00047   // If weak symbols are not supported, typeinfo names are not merged.
00048   #define __GXX_MERGED_TYPEINFO_NAMES 0
00049 #else
00050   // On platforms that support weak symbols, typeinfo names are merged.
00051   #define __GXX_MERGED_TYPEINFO_NAMES 1
00052 #endif
00053 
00054 namespace std 
00055 {
00059   class type_info 
00060   {
00061   public:
00066     virtual ~type_info();
00067 
00068   private:
00070     type_info& operator=(const type_info&);
00071     type_info(const type_info&);
00072     
00073   protected:
00074     const char *__name;
00075     
00076   protected:
00077     explicit type_info(const char *__n): __name(__n) { }
00078     
00079   public:
00080     // the public interface
00083     const char* name() const
00084     { return __name; }
00085 
00086 #if !__GXX_MERGED_TYPEINFO_NAMES
00087     bool before(const type_info& arg) const;
00088     // In old abi, or when weak symbols are not supported, there can
00089     // be multiple instances of a type_info object for one
00090     // type. Uniqueness must use the _name value, not object address.
00091     bool operator==(const type_info& __arg) const;
00092 #else
00093 
00095     // In new abi we can rely on type_info's NTBS being unique,
00096     // and therefore address comparisons are sufficient.
00097     bool before(const type_info& __arg) const
00098     { return __name < __arg.__name; }
00099     bool operator==(const type_info& __arg) const
00100     { return __name == __arg.__name; }
00101 #endif
00102     bool operator!=(const type_info& __arg) const
00103     { return !operator==(__arg); }
00104     
00105     // the internal interface
00106   public:
00107     // return true if this is a pointer type of some kind
00108     virtual bool __is_pointer_p() const;
00109     // return true if this is a function type
00110     virtual bool __is_function_p() const;
00111 
00112     // Try and catch a thrown type. Store an adjusted pointer to the
00113     // caught type in THR_OBJ. If THR_TYPE is not a pointer type, then
00114     // THR_OBJ points to the thrown object. If THR_TYPE is a pointer
00115     // type, then THR_OBJ is the pointer itself. OUTER indicates the
00116     // number of outer pointers, and whether they were const
00117     // qualified.
00118     virtual bool __do_catch(const type_info *__thr_type, void **__thr_obj,
00119                 unsigned __outer) const;
00120 
00121     // internally used during catch matching
00122     virtual bool __do_upcast(const __cxxabiv1::__class_type_info *__target,
00123                  void **__obj_ptr) const;
00124   };
00125 
00128   class bad_cast : public exception 
00129   {
00130   public:
00131     bad_cast() throw() { }
00132     virtual ~bad_cast() throw();
00133   };
00134   
00136   class bad_typeid : public exception 
00137   {
00138   public:
00139     bad_typeid () throw() { }
00140     virtual ~bad_typeid () throw();
00141   };
00142 } // namespace std
00143 
00144 } // extern "C++"
00145 #endif

Generated on Sat Apr 19 07:14:34 2003 for libstdc++-v3 Source by doxygen1.2.15