LibreOffice LibreOffice 4.1 SDK C/C++ API Reference

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

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 #include "com/sun/star/uno/Type.h"
25 #include "sal/types.h"
26 #include "typelib/typeclass.h"
27 #include "typelib/typedescription.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 &
101 getTypeFromTypeClass(::typelib_TypeClass tc) {
102 return getTypeFromTypeDescriptionReference(
103 ::typelib_static_type_getByTypeClass(tc));
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 *) {
114 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_VOID);
115 }
116
117 inline ::com::sun::star::uno::Type const &
118 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER bool const *) {
119 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
120 }
121
122 inline ::com::sun::star::uno::Type const &
123 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Bool const *) {
124 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
125 }
126
127 inline ::com::sun::star::uno::Type const &
128 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int8 const *) {
129 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BYTE);
130 }
131
132 inline ::com::sun::star::uno::Type const &
133 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
134 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_SHORT);
135 }
136
137 inline ::com::sun::star::uno::Type const &
138 cppu_detail_getUnoType(
139 SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
140 {
141 return ::cppu::detail::getTypeFromTypeClass(
142 ::typelib_TypeClass_UNSIGNED_SHORT);
143 }
144
145 inline ::com::sun::star::uno::Type const &
146 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
147 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_LONG);
148 }
149
150 inline ::com::sun::star::uno::Type const &
151 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
152 return ::cppu::detail::getTypeFromTypeClass(
153 ::typelib_TypeClass_UNSIGNED_LONG);
154 }
155
156 inline ::com::sun::star::uno::Type const &
157 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
158 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_HYPER);
159 }
160
161 inline ::com::sun::star::uno::Type const &
162 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
163 return ::cppu::detail::getTypeFromTypeClass(
164 ::typelib_TypeClass_UNSIGNED_HYPER);
165 }
166
167 inline ::com::sun::star::uno::Type const &
168 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER float const *) {
169 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_FLOAT);
170 }
171
172 inline ::com::sun::star::uno::Type const &
173 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER double const *) {
174 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_DOUBLE);
175 }
176
177 inline ::com::sun::star::uno::Type const &
178 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
179 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_CHAR);
180 }
181
182 inline ::com::sun::star::uno::Type const &
183 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
184 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_STRING);
185 }
186
187 inline ::com::sun::star::uno::Type const &
188 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Type const *)
189 {
190 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_TYPE);
191 }
192
193 inline ::com::sun::star::uno::Type const &
194 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Any const *)
195 {
196 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_ANY);
197 }
198
199 template< typename T > inline ::com::sun::star::uno::Type const &
200 cppu_detail_getUnoType(
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) {
206 ::typelib_static_sequence_type_init(
207 &p, ::cppu::UnoType< T >::get().getTypeLibType());
208 }
209 return ::cppu::detail::getTypeFromTypeDescriptionReference(&p);
210 }
211
212 template< typename T > inline ::com::sun::star::uno::Type const &
213 cppu_detail_getUnoType(
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 {
223 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_EXCEPTION);
224 }
225
226 inline ::com::sun::star::uno::Type const & cppu_detail_getUnoType(
227 SAL_UNUSED_PARAMETER ::com::sun::star::uno::XInterface const *)
228 {
229 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_INTERFACE);
230 }
231
232 template< typename T > inline ::com::sun::star::uno::Type const &
233 cppu_detail_getUnoType(
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 &
287 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T 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 &
317 getTypeFavourUnsigned(::com::sun::star::uno::Sequence< T > const *);
318 // defined in com/sun/star/uno/Sequence.hxx
319
321
333 template< typename T > inline ::com::sun::star::uno::Type const &
334 getTypeFavourChar(SAL_UNUSED_PARAMETER T const *) {
335 return ::cppu::UnoType< T >::get();
336 }
337
349 inline ::com::sun::star::uno::Type const &
350 getTypeFavourChar(SAL_UNUSED_PARAMETER ::sal_Unicode const *) {
351 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
352 }
353
365 template< typename T > inline ::com::sun::star::uno::Type const &
366 getTypeFavourChar(::com::sun::star::uno::Sequence< T > 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: */
_typelib_TypeDescriptionReference
Holds a weak reference to a type description.
Definition: typedescription.h:40
SAL_UNUSED_PARAMETER
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:540
typelib_TypeClass_TYPE
type class of type
Definition: typeclass.h:55
com::sun::star::uno::Type
C++ class representing an IDL meta type.
Definition: Type.h:55
typelib_TypeClass
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
cppu::detail::getTypeFromTypeClass
inline::com::sun::star::uno::Type const & getTypeFromTypeClass(::typelib_TypeClass tc)
Definition: unotype.hxx:101
typelib_static_sequence_type_init
CPPU_DLLPUBLIC void typelib_static_sequence_type_init(typelib_TypeDescriptionReference **ppRef, typelib_TypeDescriptionReference *pElementType) SAL_THROW_EXTERN_C()
Inits static sequence type reference.
typelib_static_type_getByTypeClass
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.
cppu::getTypeFavourUnsigned
::com::sun::star::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:287
typelib_TypeClass_BYTE
type class of byte
Definition: typeclass.h:35
cppu::UnoSequenceType
A unique C++ type template representing the UNO sequence types in cppu::UnoType.
Definition: unotype.hxx:90
cppu::detail::cppu_detail_getUnoType
::com::sun::star::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER::com::sun::star::uno::Reference< T > const *)
Definition: unotype.hxx:233
typelib_TypeClass_UNSIGNED_SHORT
type class of unsigned short
Definition: typeclass.h:39
Type.h
typelib_TypeClass_UNSIGNED_HYPER
type class of unsigned hyper
Definition: typeclass.h:47
config.h
cppu::getTypeFavourChar
::com::sun::star::uno::Type const & getTypeFavourChar(SAL_UNUSED_PARAMETER::com::sun::star::uno::Sequence< T > const *)
Definition: Sequence.hxx:235
sal_Unicode
sal_uInt16 sal_Unicode
Definition: types.h:134
typelib_TypeClass_VOID
type class of void
Definition: typeclass.h:29
typedescription.h
com::sun::star::uno::Reference
Template reference class for interface type derived from BaseReference.
Definition: unotype.hxx:32
typelib_TypeClass_DOUBLE
type class of double
Definition: typeclass.h:51
typelib_TypeClass_STRING
type class of string
Definition: typeclass.h:53
typelib_TypeClass_LONG
type class of long
Definition: typeclass.h:41
typelib_TypeClass_CHAR
type class of char
Definition: typeclass.h:31
cppu::detail::cppu_detail_getUnoType
inline::com::sun::star::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER::cppu::UnoVoidType const *)
Definition: unotype.hxx:113
cppu::detail::getTypeFromTypeDescriptionReference
inline::com::sun::star::uno::Type const & getTypeFromTypeDescriptionReference(::typelib_TypeDescriptionReference *const *tdr)
Definition: unotype.hxx:94
typelib_TypeClass_UNSIGNED_LONG
type class of unsigned long
Definition: typeclass.h:43
typelib_TypeClass_EXCEPTION
type class of exception
Definition: typeclass.h:67
typelib_TypeClass_ANY
type class of any
Definition: typeclass.h:57
typelib_TypeClass_SHORT
type class of short
Definition: typeclass.h:37
sal_Bool
unsigned char sal_Bool
Definition: types.h:37
typeclass.h
sal_Int8
signed char sal_Int8
Definition: types.h:42
typelib_TypeClass_BOOLEAN
type class of boolean
Definition: typeclass.h:33
typelib_TypeClass_FLOAT
type class of float
Definition: typeclass.h:49
com::sun::star::uno::Sequence
Template C++ class representing an IDL sequence.
Definition: unotype.hxx:33
types.h
typelib_TypeClass_HYPER
type class of hyper
Definition: typeclass.h:45
typelib_TypeClass_INTERFACE
type class of interface
Definition: typeclass.h:73
cppu::UnoType
Get the com::sun::star::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:40