LibreOffice
LibreOffice 4.3 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 #include <com/sun/star/uno/Type.h>
25 #include <sal/types.h>
26 #include <typelib/typeclass.h>
28 
29 namespace com { namespace sun { namespace star { namespace uno {
30  class Any;
31  class Exception;
32  template< typename > class Reference;
33  template< typename > class Sequence;
34  class XInterface;
35 } } } }
36 namespace rtl { class OUString; }
37 
38 namespace cppu {
39 
40 template< typename > class UnoType;
41 
50 struct UnoVoidType;
51 
63 struct UnoUnsignedShortType;
64 
76 struct UnoCharType;
77 
90 template< typename > struct UnoSequenceType;
91 
92 namespace detail {
93 
94 inline ::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(
95  ::typelib_TypeDescriptionReference * const * tdr)
96 {
97  return *reinterpret_cast< ::com::sun::star::uno::Type const * >(tdr);
98 }
99 
100 inline ::com::sun::star::uno::Type const &
104 }
105 
106 }
107 
108 }
109 
110 namespace cppu { namespace detail {
111 
112 inline ::com::sun::star::uno::Type const &
113 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
115 }
116 
117 inline ::com::sun::star::uno::Type 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 &
133 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
135 }
136 
137 inline ::com::sun::star::uno::Type const &
139  SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
140 {
143 }
144 
145 inline ::com::sun::star::uno::Type const &
146 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
148 }
149 
150 inline ::com::sun::star::uno::Type const &
151 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
154 }
155 
156 inline ::com::sun::star::uno::Type const &
157 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
159 }
160 
161 inline ::com::sun::star::uno::Type const &
162 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
165 }
166 
167 inline ::com::sun::star::uno::Type const &
170 }
171 
172 inline ::com::sun::star::uno::Type const &
175 }
176 
177 inline ::com::sun::star::uno::Type const &
178 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
180 }
181 
182 inline ::com::sun::star::uno::Type const &
183 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
185 }
186 
187 inline ::com::sun::star::uno::Type const &
188 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
189 {
191 }
192 
193 inline ::com::sun::star::uno::Type const &
194 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
195 {
197 }
198 
199 template< typename T > inline ::com::sun::star::uno::Type const &
201  SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
202 {
203  //TODO: depending on memory model, the following might not work reliably
204  static typelib_TypeDescriptionReference * p = 0;
205  if (p == 0) {
207  &p, ::cppu::UnoType< T >::get().getTypeLibType());
208  }
210 }
211 
212 template< typename T > inline ::com::sun::star::uno::Type const &
214  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
215 {
216  return cppu_detail_getUnoType(
217  static_cast< ::cppu::UnoSequenceType< T > * >(0));
218 }
219 
220 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
221  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Exception const *)
222 {
224 }
225 
226 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
227  SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
228 {
230 }
231 
232 template< typename T > inline ::com::sun::star::uno::Type const &
234  SAL_UNUSED_PARAMETER ::com::sun::star::uno::Reference< T > const *)
235 {
236  return ::cppu::UnoType< T >::get();
237 }
238 
239 } }
240 
241 namespace cppu {
242 
263 template< typename T > class UnoType {
264 public:
265  static inline ::com::sun::star::uno::Type const & get() {
266  using namespace ::cppu::detail;
267  return cppu_detail_getUnoType(static_cast< T * >(0));
268  }
269 
270 private:
271  UnoType(UnoType &); // not defined
272  ~UnoType(); // not defined
273  void operator =(UnoType &); // not defined
274 };
275 
286 template< typename T > inline ::com::sun::star::uno::Type const &
288  return ::cppu::UnoType< T >::get();
289 }
290 
301 inline ::com::sun::star::uno::Type const &
302 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
303  return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
304 }
305 
316 template< typename T > inline ::com::sun::star::uno::Type const &
318  // defined in com/sun/star/uno/Sequence.hxx
319 
321 
333 template< typename T > inline ::com::sun::star::uno::Type const &
335  return ::cppu::UnoType< T >::get();
336 }
337 
349 inline ::com::sun::star::uno::Type const &
351  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
352 }
353 
365 template< typename T > inline ::com::sun::star::uno::Type const &
367  // defined in com/sun/star/uno/Sequence.hxx
368 
370 
371 }
372 
373 #endif
374 
375 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
type class of short
Definition: typeclass.h:37
type class of long
Definition: typeclass.h:41
unsigned char sal_Bool
Definition: types.h:46
C++ class representing an IDL meta type.
Definition: Type.h:55
type class of unsigned hyper
Definition: typeclass.h:47
Definition: bootstrap.hxx:24
inline::com::sun::star::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER::cppu::UnoVoidType const *)
Definition: unotype.hxx:113
type class of exception
Definition: typeclass.h:70
type class of unsigned long
Definition: typeclass.h:43
type class of any
Definition: typeclass.h:57
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 void
Definition: typeclass.h:29
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:33
::com::sun::star::uno::Type const & getTypeFavourChar(SAL_UNUSED_PARAMETER::com::sun::star::uno::Sequence< T > const *)
Definition: Sequence.hxx:217
type class of double
Definition: typeclass.h:51
type class of boolean
Definition: typeclass.h:33
type class of float
Definition: typeclass.h:49
Holds a weak reference to a type description.
Definition: typedescription.h:40
type class of interface
Definition: typeclass.h:79
::com::sun::star::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:287
signed char sal_Int8
Definition: types.h:51
CPPU_DLLPUBLIC void typelib_static_sequence_type_init(typelib_TypeDescriptionReference **ppRef, typelib_TypeDescriptionReference *pElementType) SAL_THROW_EXTERN_C()
Inits static sequence type reference.
Definition: Enterable.hxx:26
Get the com::sun::star::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:40
type class of type
Definition: typeclass.h:55
Definition: unotype.hxx:92
inline::com::sun::star::uno::Type const & getTypeFromTypeClass(::typelib_TypeClass tc)
Definition: unotype.hxx:101
type class of hyper
Definition: typeclass.h:45
inline::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(::typelib_TypeDescriptionReference *const *tdr)
Definition: unotype.hxx:94
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:582
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32
type class of byte
Definition: typeclass.h:35
::com::sun::star::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER::com::sun::star::uno::Reference< T > const *)
Definition: unotype.hxx:233
sal_uInt16 sal_Unicode
Definition: types.h:150
type class of unsigned short
Definition: typeclass.h:39
type class of string
Definition: typeclass.h:53
A unique C++ type template representing the UNO sequence types in cppu::UnoType.
Definition: unotype.hxx:90
type class of char
Definition: typeclass.h:31
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
Definition: types.h:391