LibreOffice
LibreOffice 6.0 SDK C/C++ API Reference
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 #include <cstddef>
26 
27 #if defined LIBO_INTERNAL_ONLY
28 #include <type_traits>
29 #endif
30 
31 #include <sal/types.h>
32 #include <typelib/typeclass.h>
34 
35 namespace com { namespace sun { namespace star { namespace uno {
36  class Type;
37  class Any;
38  class Exception;
39  template< typename > class Reference;
40  template< typename > class Sequence;
41  class XInterface;
42 } } } }
43 namespace rtl { class OUString; }
44 
45 namespace cppu {
46 
47 template< typename > class UnoType;
48 
57 struct UnoVoidType;
58 
70 struct UnoUnsignedShortType;
71 
83 struct UnoCharType;
84 
97 template< typename > struct UnoSequenceType;
98 
99 namespace detail {
100 
101 inline css::uno::Type const & getTypeFromTypeDescriptionReference(
102  ::typelib_TypeDescriptionReference * const * tdr)
103 {
104  return *reinterpret_cast< css::uno::Type const * >(tdr);
105 }
106 
107 inline css::uno::Type const &
111 }
112 
113 }
114 
115 }
116 
117 namespace cppu { namespace detail {
118 
119 inline css::uno::Type const &
120 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
122 }
123 
124 inline css::uno::Type const &
127 }
128 
129 inline css::uno::Type const &
132 }
133 
134 inline css::uno::Type const &
137 }
138 
139 inline css::uno::Type const &
140 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
142 }
143 
144 inline css::uno::Type const &
146  SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
147 {
150 }
151 
152 #if defined LIBO_INTERNAL_ONLY
153  // cf. sal/types.h sal_Unicode
154 inline css::uno::Type const &
155 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER sal_uInt16 const *) {
157 }
158 #endif
159 
160 inline css::uno::Type const &
161 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
163 }
164 
165 inline css::uno::Type const &
166 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
169 }
170 
171 inline css::uno::Type const &
172 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
174 }
175 
176 inline css::uno::Type const &
177 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
180 }
181 
182 inline css::uno::Type const &
185 }
186 
187 inline css::uno::Type const &
190 }
191 
192 inline css::uno::Type const &
193 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
195 }
196 
197 #if defined LIBO_INTERNAL_ONLY
198  // cf. sal/types.h sal_Unicode
199 inline css::uno::Type const &
202 }
203 #endif
204 
205 inline css::uno::Type const &
206 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
208 }
209 
210 inline css::uno::Type const &
212 {
214 }
215 
216 inline css::uno::Type const &
218 {
220 }
221 
222 template< typename T > inline css::uno::Type const &
224  SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
225 {
226  //TODO: depending on memory model, the following might not work reliably
227  static typelib_TypeDescriptionReference * p = NULL;
228  if (p == NULL) {
230  &p, ::cppu::UnoType< T >::get().getTypeLibType());
231  }
233 }
234 
235 template< typename T > inline css::uno::Type const &
237  SAL_UNUSED_PARAMETER css::uno::Sequence< T > const *)
238 {
239  return cppu_detail_getUnoType(
240  static_cast< ::cppu::UnoSequenceType< T > * >(0));
241 }
242 
243 inline css::uno::Type const & cppu_detail_getUnoType(
244  SAL_UNUSED_PARAMETER css::uno::Exception const *)
245 {
247 }
248 
249 inline css::uno::Type const & cppu_detail_getUnoType(
250  SAL_UNUSED_PARAMETER css::uno::XInterface const *)
251 {
253 }
254 
255 template< typename T > inline css::uno::Type const &
257  SAL_UNUSED_PARAMETER css::uno::Reference< T > const *)
258 {
259  return ::cppu::UnoType< T >::get();
260 }
261 
262 } }
263 
264 namespace cppu {
265 
286 template< typename T > class UnoType {
287 public:
288  static css::uno::Type const & get() {
289  using namespace ::cppu::detail;
290 #if defined LIBO_INTERNAL_ONLY
291  typedef typename std::remove_reference<T>::type T1;
292  // for certain uses of UnoType<decltype(x)>
293 #else
294  typedef T T1;
295 #endif
296  return cppu_detail_getUnoType(static_cast< T1 * >(0));
297  }
298 
299 private:
302  void operator =(UnoType &) SAL_DELETED_FUNCTION;
303 };
304 
305 template<> css::uno::Type inline const & UnoType<void>::get() {
307 }
308 
319 template< typename T > inline css::uno::Type const &
321  return ::cppu::UnoType< T >::get();
322 }
323 
334 inline css::uno::Type const &
335 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
336  return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
337 }
338 
349 template< typename T > inline css::uno::Type const &
350 getTypeFavourUnsigned(css::uno::Sequence< T > const *);
351  // defined in com/sun/star/uno/Sequence.hxx
352 
354 
366 template< typename T > inline css::uno::Type const &
368  return ::cppu::UnoType< T >::get();
369 }
370 
382 inline css::uno::Type const &
384  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
385 }
386 
398 template< typename T > inline css::uno::Type const &
399 getTypeFavourChar(css::uno::Sequence< T > const *);
400  // defined in com/sun/star/uno/Sequence.hxx
401 
403 
404 }
405 
406 #endif
407 
408 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
type class of double
Definition: typeclass.h:51
type class of unsigned long
Definition: typeclass.h:43
type class of short
Definition: typeclass.h:37
type class of unsigned hyper
Definition: typeclass.h:47
type class of any
Definition: typeclass.h:57
type class of unsigned short
Definition: typeclass.h:39
Definition: Enterable.hxx:26
A unique C++ type template representing the UNO sequence types in cppu::UnoType.
Definition: unotype.hxx:97
::com::sun::star::uno::Type const & getTypeFavourChar(SAL_UNUSED_PARAMETER::com::sun::star::uno::Sequence< T > const *)
Definition: Sequence.hxx:228
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:402
Definition: unotype.hxx:99
type class of interface
Definition: typeclass.h:79
type class of hyper
Definition: typeclass.h:45
Definition: types.h:383
type class of long
Definition: typeclass.h:41
type class of string
Definition: typeclass.h:53
unsigned char sal_Bool
Definition: types.h:39
type class of type
Definition: typeclass.h:55
type class of char
Definition: typeclass.h:31
css::uno::Type const & getTypeFavourUnsigned(css::uno::Sequence< T > const *)
A working replacement for getCppuType (see there).
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:587
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:40
signed char sal_Int8
Definition: types.h:44
sal_uInt16 sal_Unicode
Definition: types.h:142
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
CPPU_DLLPUBLIC typelib_TypeDescriptionReference ** typelib_static_type_getByTypeClass(typelib_TypeClass eTypeClass) SAL_THROW_EXTERN_C()
Gets static type reference of standard types by type class.
css::uno::Type const & getTypeFromTypeDescriptionReference(::typelib_TypeDescriptionReference *const *tdr)
Definition: unotype.hxx:101
type class of boolean
Definition: typeclass.h:33
static css::uno::Type const & get()
Definition: unotype.hxx:288
Definition: bootstrap.hxx:29
type class of float
Definition: typeclass.h:49
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:39
CPPU_DLLPUBLIC void typelib_static_sequence_type_init(typelib_TypeDescriptionReference **ppRef, typelib_TypeDescriptionReference *pElementType) SAL_THROW_EXTERN_C()
Inits static sequence type reference.
css::uno::Type const & getTypeFromTypeClass(::typelib_TypeClass tc)
Definition: unotype.hxx:108
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:47
css::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER css::uno::Reference< T > const *)
Definition: unotype.hxx:256
type class of void
Definition: typeclass.h:29
type class of byte
Definition: typeclass.h:35
type class of exception
Definition: typeclass.h:70