LibreOffice: cppu/unotype.hxx Source File

LibreOffice LibreOffice 24.8 SDK C/C++ API Reference

Loading...
Searching...
No Matches
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/*
21 * This file is part of LibreOffice published API.
22 */
23
24#ifndef INCLUDED_CPPU_UNOTYPE_HXX
25#define INCLUDED_CPPU_UNOTYPE_HXX
26
27#include "sal/config.h"
28
29#include <cstddef>
30
31#if defined LIBO_INTERNAL_ONLY
32#include <type_traits>
33#endif
34
35#include "sal/types.h"
36#include "typelib/typeclass.h"
37#include "typelib/typedescription.h"
38
39namespace com { namespace sun { namespace star { namespace uno {
40 class Type;
41 class Any;
42 class Exception;
43 template< typename > class Reference;
44 template< typename > class Sequence;
45 class XInterface;
46} } } }
47namespace rtl { class OUString; }
48
49namespace cppu {
50
51template< typename > class UnoType;
52
61struct UnoVoidType;
62
74struct UnoUnsignedShortType;
75
87struct UnoCharType;
88
101 template< typename > struct UnoSequenceType;
102
103 namespace detail {
104
105 inline css::uno::Type const & getTypeFromTypeDescriptionReference(
106 ::typelib_TypeDescriptionReference * const * tdr)
107{
108 return *reinterpret_cast< css::uno::Type const * >(tdr);
109}
110
111inline css::uno::Type const &
112getTypeFromTypeClass(::typelib_TypeClass tc) {
113 return getTypeFromTypeDescriptionReference(
114 ::typelib_static_type_getByTypeClass(tc));
115}
116
117}
118
119}
120
121namespace cppu { namespace detail {
122
123inline css::uno::Type const &
124cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
125 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_VOID);
126}
127
128inline css::uno::Type const &
129 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER bool const *) {
130 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
131}
132
133inline css::uno::Type const &
134 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER sal_Bool const *) {
135 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BOOLEAN);
136}
137
138inline css::uno::Type const &
139 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int8 const *) {
140 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_BYTE);
141}
142
143inline css::uno::Type const &
144 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
145 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_SHORT);
146}
147
148inline css::uno::Type const &
149 cppu_detail_getUnoType(
150 SAL_UNUSED_PARAMETER ::cppu::UnoUnsignedShortType const *)
151{
152 return ::cppu::detail::getTypeFromTypeClass(
153 ::typelib_TypeClass_UNSIGNED_SHORT);
154}
155
156#if defined LIBO_INTERNAL_ONLY
157 // cf. sal/types.h sal_Unicode
158inline css::uno::Type const &
159 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER sal_uInt16 const *) {
160 return cppu::detail::getTypeFromTypeClass(typelib_TypeClass_UNSIGNED_SHORT);
161}
162#endif
163
164inline css::uno::Type const &
165 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
166 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_LONG);
167}
168
169inline css::uno::Type const &
170 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
171 return ::cppu::detail::getTypeFromTypeClass(
172 ::typelib_TypeClass_UNSIGNED_LONG);
173}
174
175inline css::uno::Type const &
176 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
177 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_HYPER);
178}
179
180inline css::uno::Type const &
181 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
182 return ::cppu::detail::getTypeFromTypeClass(
183 ::typelib_TypeClass_UNSIGNED_HYPER);
184}
185
186inline css::uno::Type const &
187 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER float const *) {
188 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_FLOAT);
189}
190
191inline css::uno::Type const &
192 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER double const *) {
193 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_DOUBLE);
194}
195
196inline css::uno::Type const &
197 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
198 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_CHAR);
199}
200
201#if defined LIBO_INTERNAL_ONLY
202 // cf. sal/types.h sal_Unicode
203inline css::uno::Type const &
204 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER sal_Unicode const *) {
205 return cppu::detail::getTypeFromTypeClass(typelib_TypeClass_CHAR);
206}
207#endif
208
209inline css::uno::Type const &
210 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
211 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_STRING);
212}
213
214inline css::uno::Type const &
215 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER css::uno::Type const *)
216{
217 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_TYPE);
218}
219
220inline css::uno::Type const &
221 cppu_detail_getUnoType(SAL_UNUSED_PARAMETER css::uno::Any const *)
222{
223 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_ANY);
224}
225
226template< typename T > inline css::uno::Type const &
227 cppu_detail_getUnoType(
228 SAL_UNUSED_PARAMETER ::cppu::UnoSequenceType< T > const *)
229{
230 //TODO: depending on memory model, the following might not work reliably
231 static typelib_TypeDescriptionReference * p = NULL;
232 if (p == NULL) {
233 ::typelib_static_sequence_type_init(
234 &p, ::cppu::UnoType< T >::get().getTypeLibType());
235 }
236 return ::cppu::detail::getTypeFromTypeDescriptionReference(&p);
237}
238
239template< typename T > inline css::uno::Type const &
240 cppu_detail_getUnoType(
241 SAL_UNUSED_PARAMETER css::uno::Sequence< T > const *)
242{
243 return cppu_detail_getUnoType(
244 static_cast< ::cppu::UnoSequenceType< T > * >(NULL));
245}
246
247 inline css::uno::Type const & cppu_detail_getUnoType(
248 SAL_UNUSED_PARAMETER css::uno::Exception const *)
249{
250 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_EXCEPTION);
251}
252
253 inline css::uno::Type const & cppu_detail_getUnoType(
254 SAL_UNUSED_PARAMETER css::uno::XInterface const *)
255{
256 return ::cppu::detail::getTypeFromTypeClass(::typelib_TypeClass_INTERFACE);
257}
258
259template< typename T > inline css::uno::Type const &
260 cppu_detail_getUnoType(
261 SAL_UNUSED_PARAMETER css::uno::Reference< T > const *)
262{
263 return ::cppu::UnoType< T >::get();
264}
265
266} }
267
268namespace cppu {
269
290 template< typename T > class UnoType {
291public:
292 static css::uno::Type const & get() {
293 using namespace ::cppu::detail;
294#if defined LIBO_INTERNAL_ONLY
295 typedef typename std::remove_reference<T>::type T1;
296 // for certain uses of UnoType<decltype(x)>
297#else
298 typedef T T1;
299#endif
300 return cppu_detail_getUnoType(static_cast< T1 * >(NULL));
301 }
302
303private:
304 UnoType(UnoType &) SAL_DELETED_FUNCTION;
305 ~UnoType() SAL_DELETED_FUNCTION;
306 void operator =(UnoType &) SAL_DELETED_FUNCTION;
307};
308
309template<> css::uno::Type inline const & UnoType<void>::get() {
310 return cppu::UnoType<cppu::UnoVoidType>::get();
311}
312
323template< typename T > inline css::uno::Type const &
324getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *) {
325 return ::cppu::UnoType< T >::get();
326}
327
338inline css::uno::Type const &
339 getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
340 return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
341}
342
353template< typename T > inline css::uno::Type const &
354 getTypeFavourUnsigned(css::uno::Sequence< T > const *);
355 // defined in com/sun/star/uno/Sequence.hxx
356
358
370template< typename T > inline css::uno::Type const &
371 getTypeFavourChar(SAL_UNUSED_PARAMETER T const *) {
372 return ::cppu::UnoType< T >::get();
373}
374
386inline css::uno::Type const &
387 getTypeFavourChar(SAL_UNUSED_PARAMETER ::sal_Unicode const *) {
388 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
389}
390
402template< typename T > inline css::uno::Type const &
403 getTypeFavourChar(css::uno::Sequence< T > const *);
404 // defined in com/sun/star/uno/Sequence.hxx
405
407
408}
409
410#endif
411
412/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
types.h
SAL_DELETED_FUNCTION
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition types.h:396
SAL_UNUSED_PARAMETER
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition types.h:592
sal_Bool
unsigned char sal_Bool
Definition types.h:38
sal_Unicode
sal_uInt16 sal_Unicode
Definition types.h:123
config.h
typedescription.h
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_TypeDescriptionReference
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
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.
typeclass.h
typelib_TypeClass_VOID
@ typelib_TypeClass_VOID
type class of void
Definition typeclass.h:32
typelib_TypeClass_UNSIGNED_SHORT
@ typelib_TypeClass_UNSIGNED_SHORT
type class of unsigned short
Definition typeclass.h:42
typelib_TypeClass_CHAR
@ typelib_TypeClass_CHAR
type class of char
Definition typeclass.h:34
typelib_TypeClass_HYPER
@ typelib_TypeClass_HYPER
type class of hyper
Definition typeclass.h:48
typelib_TypeClass_BYTE
@ typelib_TypeClass_BYTE
type class of byte
Definition typeclass.h:38
typelib_TypeClass_BOOLEAN
@ typelib_TypeClass_BOOLEAN
type class of boolean
Definition typeclass.h:36
typelib_TypeClass_INTERFACE
@ typelib_TypeClass_INTERFACE
type class of interface
Definition typeclass.h:82
typelib_TypeClass_STRING
@ typelib_TypeClass_STRING
type class of string
Definition typeclass.h:56
typelib_TypeClass_SHORT
@ typelib_TypeClass_SHORT
type class of short
Definition typeclass.h:40
typelib_TypeClass_FLOAT
@ typelib_TypeClass_FLOAT
type class of float
Definition typeclass.h:52
typelib_TypeClass_DOUBLE
@ typelib_TypeClass_DOUBLE
type class of double
Definition typeclass.h:54
typelib_TypeClass_ANY
@ typelib_TypeClass_ANY
type class of any
Definition typeclass.h:60
typelib_TypeClass_TYPE
@ typelib_TypeClass_TYPE
type class of type
Definition typeclass.h:58
typelib_TypeClass_UNSIGNED_HYPER
@ typelib_TypeClass_UNSIGNED_HYPER
type class of unsigned hyper
Definition typeclass.h:50
typelib_TypeClass_LONG
@ typelib_TypeClass_LONG
type class of long
Definition typeclass.h:44
typelib_TypeClass_UNSIGNED_LONG
@ typelib_TypeClass_UNSIGNED_LONG
type class of unsigned long
Definition typeclass.h:46
typelib_TypeClass_EXCEPTION
@ typelib_TypeClass_EXCEPTION
type class of exception
Definition typeclass.h:73
typelib_TypeClass
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
com
Definition types.h:377
com::sun
Definition types.h:377
com::sun::star
Definition types.h:377
rtl
Definition bootstrap.hxx:34
com::sun::star::uno
Definition typedescription.hxx:43
cppu
Definition Enterable.hxx:31
cppu::getTypeFavourUnsigned
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition unotype.hxx:324
cppu::getTypeFavourChar
::com::sun::star::uno::Type const & getTypeFavourChar(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
Definition Sequence.hxx:343
cppu::detail
Definition unotype.hxx:103
cppu::detail::getTypeFromTypeDescriptionReference
css::uno::Type const & getTypeFromTypeDescriptionReference(::typelib_TypeDescriptionReference *const *tdr)
Definition unotype.hxx:105
cppu::detail::cppu_detail_getUnoType
css::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *)
Definition unotype.hxx:124
cppu::detail::getTypeFromTypeClass
css::uno::Type const & getTypeFromTypeClass(::typelib_TypeClass tc)
Definition unotype.hxx:112
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition ustring.hxx:172
com::sun::star::uno::Reference
Template reference class for interface type derived from BaseReference.
Definition Reference.h:184
com::sun::star::uno::Sequence
Template C++ class representing an IDL sequence.
Definition Sequence.h:61
cppu::UnoType
Get the css::uno::Type instance representing a certain UNO type.
Definition unotype.hxx:290
cppu::UnoType::get
static css::uno::Type const & get()
Definition unotype.hxx:292
cppu::UnoSequenceType
A unique C++ type template representing the UNO sequence types in cppu::UnoType.
Definition unotype.hxx:101
com::sun::star::uno::Any
C++ class representing an IDL any.
Definition Any.h:58
com::sun::star::uno::Type
C++ class representing an IDL meta type.
Definition Type.h:59