Source: classlib/include/classlib/defs.h
|
|
|
|
/***************************************************************************
defs.h - altre definizioni
-------------------
begin : ven dic 7 17:40:01 CET 2001
copyright : (C) 2001 by Nicola De Nisco
email : nicola@winada.it
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#if !defined( __CLASSLIB_DEFS_H )
#define __CLASSLIB_DEFS_H
#if !defined( ___DEFS_H )
#include "_defs.h"
#endif // __CLASSLIB_RESOURCE_H
#if !defined( __CLASSLIB_RESOURCE_H )
#include "classlib/resource.h"
#endif // __CLASSLIB_RESOURCE_H
/*------------------------------------------------------------------------*/
/* */
/* _RTTI provides a convenient macro for switching on the __rtti */
/* keyword for finer grained control over generation of runtime type */
/* information. */
/* */
/*------------------------------------------------------------------------*/
#if defined(__BORLANDC__) && !defined(BI_NO_RTTI)
#define _RTTI __rtti
#else
#define _RTTI
#endif
/*------------------------------------------------------------------------*/
/* */
/* These CAST macros encapsulate the new cast syntax in the ANSI/ISO */
/* working paper. Note that TYPESAFE_DOWNCAST isn't as general as */
/* dynamic_cast -- it only works on pointers. */
/* */
/* Usage: */
/* */
/* TYPESAFE_DOWNCAST(object,toClass) */
/* Converts the pointer referred to by 'object' into a pointer to */
/* an object of type 'toClass'. Note that the macro parameters to */
/* TYPESAFE_DOWNCAST are in the opposite order from the rest of */
/* the macros here. When using a compiler that supports new style */
/* casts and runtime type information this is done with */
/* dynamic_cast<> and will return 0 if the cast cannot be done. */
/* When using a compiler that does not support new style casts and */
/* runtime type information this is done with fake runtime type */
/* information generated by the IMPLEMENT_CASTABLE macro. */
/* */
/* STATIC_CAST(targetType,object) */
/* Converts the data object referred to by 'object' into the type */
/* referred to by 'targetType'. When using a compiler that supports */
/* new style casts, this is done with static_cast<> and will fail */
/* if the cast cannot be done without runtime type information. */
/* When using a compiler that does not support new style casts, this */
/* is done with an old style dangerous cast. */
/* */
/* CONST_CAST(targetType,object) */
/* Converts the data object referred to by 'object' into the type */
/* referred to by 'targetType'. When using a compiler that supports */
/* new style casts, this is done with const_cast<> and will fail */
/* if the cast changes the type of the object in any way other than */
/* adding or removing const and volatile qualifiers. */
/* When using a compiler that does not support new style casts, this */
/* is done with an old style dangerous cast. */
/* */
/* REINTERPRET_CAST(targetType,object) */
/* Converts the data object referred to by 'object' into the type */
/* referred to by 'targetType'. When using a compiler that supports */
/* new style casts, this is done with reinterpret_cast<>. */
/* When using a compiler that does not support new style casts, this */
/* is done with an old style dangerous cast. */
/* */
/*------------------------------------------------------------------------*/
#if defined( BI_NO_NEW_CASTS )
# define TYPESAFE_DOWNCAST(object,toClass)\
(object ?(toClass *)(object)->FindBase(#toClass) : 0)
# define STATIC_CAST(targetType,object) \
((targetType)(object))
# define CONST_CAST(targetType,object) \
((targetType)(object))
# define REINTERPRET_CAST(targetType,object) \
(*(targetType*)(void *)&(object))
#else
# define TYPESAFE_DOWNCAST(object,toClass)\
dynamic_cast(object)
# define STATIC_CAST(targetType,object) \
static_cast(object)
# define CONST_CAST(targetType,object) \
const_cast(object)
# define REINTERPRET_CAST(targetType,object) \
reinterpret_cast(object)
#endif
#endif // __CLASSLIB_DEFS_H
Generated by: nicola on gulliver.wadahome.it on Sun May 25 13:54:34 2003, using kdoc 2.0a53. |