LibreOffice
LibreOffice 5.0 SDK 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  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_CPPU_UNOTYPE_HXX
21 #define INCLUDED_CPPU_UNOTYPE_HXX
22 
23 #include <sal/config.h>
24 
25 #if defined LIBO_INTERNAL_ONLY
26 #include <type_traits>
27 #endif
28 
29 #include <sal/types.h>
30 #include <typelib/typeclass.h>
32 
33 namespace com { namespace sun { namespace star { namespace uno {
34  class Type;
35  class Any;
36  class Exception;
37  template< typename > class Reference;
38  template< typename > class Sequence;
39  class XInterface;
40 } } } }
41 namespace rtl { class OUString; }
42 
43 namespace cppu {
44 
45 template< typename > class UnoType;
46 
55 struct UnoVoidType;
56 
68 struct UnoUnsignedShortType;
69 
81 struct UnoCharType;
82 
95 template< typename > struct UnoSequenceType;
96 
97 namespace detail {
98 
99 inline ::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(
100  ::typelib_TypeDescriptionReference * const * tdr)
101 {
102  return *reinterpret_cast< ::com::sun::star::uno::Type const * >(tdr);
103 }
104 
105 inline ::com::sun::star::uno::Type const &
109 }
110 
111 }
112 
113 }
114 
115 namespace cppu { namespace detail {
116 
117 inline ::com::sun::star::uno::Type const &
118 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
120 }
121 
122 inline ::com::sun::star::uno::Type const &
125 }
126 
127 inline ::com::sun::star::uno::Type const &
130 }
131 
132 inline ::com::sun::star::uno::Type const &
135 }
136 
137 inline ::com::sun::star::uno::Type const &
138 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
140 }
141 
142 inline ::com::sun::star::uno::Type const &
144  SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
145 {
148 }
149 
150 inline ::com::sun::star::uno::Type const &
151 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
153 }
154 
155 inline ::com::sun::star::uno::Type const &
156 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
159 }
160 
161 inline ::com::sun::star::uno::Type const &
162 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
164 }
165 
166 inline ::com::sun::star::uno::Type const &
167 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
170 }
171 
172 inline ::com::sun::star::uno::Type const &
175 }
176 
177 inline ::com::sun::star::uno::Type const &
180 }
181 
182 inline ::com::sun::star::uno::Type const &
183 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
185 }
186 
187 inline ::com::sun::star::uno::Type const &
188 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
190 }
191 
192 inline ::com::sun::star::uno::Type const &
193 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
194 {
196 }
197 
198 inline ::com::sun::star::uno::Type const &
199 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
200 {
202 }
203 
204 template< typename T > inline ::com::sun::star::uno::Type const &
206  SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
207 {
208  //TODO: depending on memory model, the following might not work reliably
209  static typelib_TypeDescriptionReference * p = 0;
210  if (p == 0) {
212  &p, ::cppu::UnoType< T >::get().getTypeLibType());
213  }
215 }
216 
217 template< typename T > inline ::com::sun::star::uno::Type const &
219  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
220 {
221  return cppu_detail_getUnoType(
222  static_cast< ::cppu::UnoSequenceType< T > * >(0));
223 }
224 
225 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
226  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Exception const *)
227 {
229 }
230 
231 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
232  SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
233 {
235 }
236 
237 template< typename T > inline ::com::sun::star::uno::Type const &
239  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Reference< T > const *)
240 {
241  return ::cppu::UnoType< T >::get();
242 }
243 
244 } }
245 
246 namespace cppu {
247 
268 template< typename T > class UnoType {
269 public:
270  static inline ::com::sun::star::uno::Type const & get() {
271  using namespace ::cppu::detail;
272 #if defined LIBO_INTERNAL_ONLY
273  typedef typename std::remove_reference<T>::type T1;
274  // for certain uses of UnoType<decltype(x)>
275 #else
276  typedef T T1;
277 #endif
278  return cppu_detail_getUnoType(static_cast< T1 * >(0));
279  }
280 
281 private:
283  ~UnoType() SAL_DELETED_FUNCTION;
284  void operator =(UnoType &) SAL_DELETED_FUNCTION;
285 };
286 
287 template<> css::uno::Type inline const & UnoType<void>::get() {
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: */