My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
unotype.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 
29 #ifndef INCLUDED_CPPU_UNOTYPE_HXX
30 #define INCLUDED_CPPU_UNOTYPE_HXX
31 
32 #include "sal/config.h"
33 #include "com/sun/star/uno/Type.h"
34 #include "sal/types.h"
35 #include "typelib/typeclass.h"
37 
38 namespace com { namespace sun { namespace star { namespace uno {
39  class Any;
40  class Exception;
41  template< typename > class Reference;
42  template< typename > class Sequence;
43  class XInterface;
44 } } } }
45 namespace rtl { class OUString; }
46 
47 namespace cppu {
48 
49 template< typename > class UnoType;
50 
59 struct UnoVoidType;
60 
72 struct UnoUnsignedShortType;
73 
85 struct UnoCharType;
86 
99 template< typename > struct UnoSequenceType;
100 
101 namespace detail {
102 
103 inline ::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(
104  ::typelib_TypeDescriptionReference * const * tdr)
105 {
106  return *reinterpret_cast< ::com::sun::star::uno::Type const * >(tdr);
107 }
108 
109 inline ::com::sun::star::uno::Type const &
113 }
114 
115 }
116 
117 }
118 
119 // For _MSC_VER 1310, define cppu_detail_getUnoType in the global namespace, to
120 // avoid spurious compiler errors in code that calls cppu_detail_getUnoType:
121 #if !defined _MSC_VER || _MSC_VER > 1310
122 namespace cppu { namespace detail {
123 #endif
124 
125 inline ::com::sun::star::uno::Type const &
126 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
128 }
129 
130 inline ::com::sun::star::uno::Type const &
133 }
134 
135 inline ::com::sun::star::uno::Type const &
138 }
139 
140 inline ::com::sun::star::uno::Type const &
143 }
144 
145 inline ::com::sun::star::uno::Type const &
146 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
148 }
149 
150 inline ::com::sun::star::uno::Type const &
152  SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
153 {
156 }
157 
158 inline ::com::sun::star::uno::Type const &
159 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
161 }
162 
163 inline ::com::sun::star::uno::Type const &
164 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
167 }
168 
169 inline ::com::sun::star::uno::Type const &
170 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
172 }
173 
174 inline ::com::sun::star::uno::Type const &
175 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
178 }
179 
180 inline ::com::sun::star::uno::Type const &
183 }
184 
185 inline ::com::sun::star::uno::Type const &
188 }
189 
190 inline ::com::sun::star::uno::Type const &
191 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
193 }
194 
195 inline ::com::sun::star::uno::Type const &
196 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
198 }
199 
200 inline ::com::sun::star::uno::Type const &
201 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
202 {
204 }
205 
206 inline ::com::sun::star::uno::Type const &
207 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
208 {
210 }
211 
212 template< typename T > inline ::com::sun::star::uno::Type const &
214  SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
215 {
216  //TODO: depending on memory model, the following might not work reliably
217  static typelib_TypeDescriptionReference * p = 0;
218  if (p == 0) {
220  &p, ::cppu::UnoType< T >::get().getTypeLibType());
221  }
223 }
224 
225 template< typename T > inline ::com::sun::star::uno::Type const &
227  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
228 {
229  return cppu_detail_getUnoType(
230  static_cast< ::cppu::UnoSequenceType< T > * >(0));
231 }
232 
233 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
234  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Exception const *)
235 {
237 }
238 
239 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
240  SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
241 {
243 }
244 
245 template< typename T > inline ::com::sun::star::uno::Type const &
247  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Reference< T > const *)
248 {
249  return ::cppu::UnoType< T >::get();
250 }
251 
252 #if !defined _MSC_VER || _MSC_VER > 1310
253 } }
254 #endif
255 
256 namespace cppu {
257 
278 template< typename T > class UnoType {
279 public:
280  static inline ::com::sun::star::uno::Type const & get() {
281  using namespace ::cppu::detail;
282  return cppu_detail_getUnoType(static_cast< T * >(0));
283  }
284 
285 private:
286  UnoType(UnoType &); // not defined
287  ~UnoType(); // not defined
288  void operator =(UnoType &); // not defined
289 };
290 
301 template< typename T > inline ::com::sun::star::uno::Type const &
303  return ::cppu::UnoType< T >::get();
304 }
305 
316 inline ::com::sun::star::uno::Type const &
317 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
318  return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
319 }
320 
331 template< typename T > inline ::com::sun::star::uno::Type const &
333  // defined in com/sun/star/uno/Sequence.hxx
334 
336 
348 template< typename T > inline ::com::sun::star::uno::Type const &
350  return ::cppu::UnoType< T >::get();
351 }
352 
364 inline ::com::sun::star::uno::Type const &
366  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
367 }
368 
380 template< typename T > inline ::com::sun::star::uno::Type const &
382  // defined in com/sun/star/uno/Sequence.hxx
383 
385 
386 }
387 
388 #endif
389 
390 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */