Update ooo320-m1
[ooovba.git] / autodoc / inc / ary / getncast.hxx
blob59bb0d57d6aced10e0924ae98efdde27388e80dd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: getncast.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef ARY_GETNCAST_HXX
32 #define ARY_GETNCAST_HXX
35 // USED SERVICES
36 #include <ary/object.hxx>
41 namespace ary
45 template <class DEST>
46 inline bool
47 is_type(const ary::Object & i_obj)
49 return i_obj.AryClass() == DEST::class_id;
53 template <class DEST>
54 inline const DEST &
55 ary_cast( const Object & ce)
57 csv_assert( is_type<DEST>(ce) );
58 return static_cast< const DEST& >(ce);
61 template <class DEST>
62 inline DEST &
63 ary_cast( Object & ce)
65 csv_assert( is_type<DEST>(ce) );
66 return static_cast< DEST& >(ce);
69 template <class DEST>
70 inline const DEST *
71 ary_cast( const Object * ce)
73 if ( ce ? is_type<DEST>(*ce) : false )
74 return static_cast< const DEST* >(ce);
75 return 0;
78 template <class DEST>
79 inline DEST *
80 ary_cast( Object * ce)
82 if ( ce ? is_type<DEST>(*ce) : false )
83 return static_cast< DEST* >(ce);
84 return 0;
90 } // namespace ary
91 #endif