Merge pull request #25959 from neo1973/TagLib_deprecation_warnings
[xbmc.git] / lib / libUPnP / Neptune / Source / Core / NptDynamicCast.h
blob0acab88121c66e331e8151e9724d34bf229a138d
1 /*****************************************************************
3 | Neptune - Dynamic Cast Support
5 | Copyright (c) 2002-2008, Axiomatic Systems, LLC.
6 | All rights reserved.
8 | Redistribution and use in source and binary forms, with or without
9 | modification, are permitted provided that the following conditions are met:
10 | * Redistributions of source code must retain the above copyright
11 | notice, this list of conditions and the following disclaimer.
12 | * Redistributions in binary form must reproduce the above copyright
13 | notice, this list of conditions and the following disclaimer in the
14 | documentation and/or other materials provided with the distribution.
15 | * Neither the name of Axiomatic Systems nor the
16 | names of its contributors may be used to endorse or promote products
17 | derived from this software without specific prior written permission.
19 | THIS SOFTWARE IS PROVIDED BY AXIOMATIC SYSTEMS ''AS IS'' AND ANY
20 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL AXIOMATIC SYSTEMS BE LIABLE FOR ANY
23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 ****************************************************************/
32 #ifndef _NPT_DYNAMIC_CAST_H_
33 #define _NPT_DYNAMIC_CAST_H_
35 /*----------------------------------------------------------------------
36 | includes
37 +---------------------------------------------------------------------*/
38 #include "NptTypes.h"
39 #include "NptCommon.h"
40 #include "NptResults.h"
41 #include "NptConfig.h"
43 /*----------------------------------------------------------------------
44 | macros
45 +---------------------------------------------------------------------*/
46 #if defined(NPT_CONFIG_NO_RTTI)
47 #define NPT_DYNAMIC_CAST(_class,_object) \
48 ( ((_object)==0) ? 0 : reinterpret_cast<_class*>((_object)->DynamicCast(&_class::_class_##_class)) )
49 #define NPT_IMPLEMENT_DYNAMIC_CAST(_class) \
50 static int _class_##_class; \
51 virtual void* DynamicCast(const void* class_anchor) { \
52 if (class_anchor == &_class::_class_##_class) { \
53 return static_cast<_class*>(this); \
54 } \
55 return NULL; \
57 #define NPT_IMPLEMENT_DYNAMIC_CAST_D(_class,_superclass)\
58 static int _class_##_class; \
59 virtual void* DynamicCast(const void* class_anchor) { \
60 if (class_anchor == &_class::_class_##_class) { \
61 return static_cast<_class*>(this); \
62 } else { \
63 return _superclass::DynamicCast(class_anchor); \
64 } \
66 #define NPT_IMPLEMENT_DYNAMIC_CAST_D2(_class,_superclass,_mixin)\
67 static int _class_##_class; \
68 virtual void* DynamicCast(const void* class_anchor) { \
69 if (class_anchor == &_class::_class_##_class) { \
70 return static_cast<_class*>(this); \
71 } else { \
72 void* sup = _superclass::DynamicCast(class_anchor); \
73 if (sup) return sup; \
74 return _mixin::DynamicCast(class_anchor); \
75 } \
77 #define NPT_DEFINE_DYNAMIC_CAST_ANCHOR(_class) int _class::_class_##_class = 0;
79 #else
81 #define NPT_DYNAMIC_CAST(_class,_object) dynamic_cast<_class*>(_object)
82 #define NPT_IMPLEMENT_DYNAMIC_CAST(_class)
83 #define NPT_IMPLEMENT_DYNAMIC_CAST_D(_class,_superclass)
84 #define NPT_IMPLEMENT_DYNAMIC_CAST_D2(_class,_superclass,_mixin)
85 #define NPT_DEFINE_DYNAMIC_CAST_ANCHOR(_class)
87 #endif
89 #endif // _NPT_DYNAMIC_CAST_H_