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: */
type class of string
Definition: typeclass.h:53
type class of long
Definition: typeclass.h:41
type class of char
Definition: typeclass.h:31
type class of unsigned hyper
Definition: typeclass.h:47
type class of exception
Definition: typeclass.h:70
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:404
Get the com::sun::star::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:45
type class of unsigned long
Definition: typeclass.h:43
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
type class of short
Definition: typeclass.h:37
type class of void
Definition: typeclass.h:29
unsigned char sal_Bool
Definition: types.h:48
type class of double
Definition: typeclass.h:51
type class of float
Definition: typeclass.h:49
type class of interface
Definition: typeclass.h:79
C++ class representing an IDL meta type.
Definition: Type.h:54
type class of any
Definition: typeclass.h:57
::com::sun::star::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER::com::sun::star::uno::Reference< T > const *)
Definition: unotype.hxx:238
static inline::com::sun::star::uno::Type const & get()
Definition: unotype.hxx:270
type class of boolean
Definition: typeclass.h:33
inline::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(::typelib_TypeDescriptionReference *const *tdr)
Definition: unotype.hxx:99
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.
type class of hyper
Definition: typeclass.h:45
sal_uInt16 sal_Unicode
Definition: types.h:152
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:587
::com::sun::star::uno::Type const & getTypeFavourChar(SAL_UNUSED_PARAMETER::com::sun::star::uno::Sequence< T > const *)
Definition: Sequence.hxx:228
signed char sal_Int8
Definition: types.h:53
inline::com::sun::star::uno::Type const & getTypeFromTypeClass(::typelib_TypeClass tc)
Definition: unotype.hxx:106
type class of byte
Definition: typeclass.h:35
type class of type
Definition: typeclass.h:55
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:37
inline::com::sun::star::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER::cppu::UnoVoidType const *)
Definition: unotype.hxx:118
CPPU_DLLPUBLIC void typelib_static_sequence_type_init(typelib_TypeDescriptionReference **ppRef, typelib_TypeDescriptionReference *pElementType) SAL_THROW_EXTERN_C()
Inits static sequence type reference.
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:38
A unique C++ type template representing the UNO sequence types in cppu::UnoType.
Definition: unotype.hxx:95
::com::sun::star::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:302
type class of unsigned short
Definition: typeclass.h:39