LibreOffice
LibreOffice 7.1 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
35namespace 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} } } }
43namespace rtl { class OUString; }
44
45namespace cppu {
46
47template< typename > class UnoType;
48
57struct UnoVoidType;
58
70struct UnoUnsignedShortType;
71
83struct UnoCharType;
84
97template< typename > struct UnoSequenceType;
98
99namespace detail {
100
101inline css::uno::Type const & getTypeFromTypeDescriptionReference(
102 ::typelib_TypeDescriptionReference * const * tdr)
103{
104 return *reinterpret_cast< css::uno::Type const * >(tdr);
105}
106
107inline css::uno::Type const &
111}
112
113}
114
115}
116
117namespace cppu { namespace detail {
118
119inline css::uno::Type const &
120cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *) {
122}
123
124inline css::uno::Type const &
127}
128
129inline css::uno::Type const &
132}
133
134inline css::uno::Type const &
137}
138
139inline css::uno::Type const &
140cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int16 const *) {
142}
143
144inline 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
154inline css::uno::Type const &
157}
158#endif
159
160inline css::uno::Type const &
161cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int32 const *) {
163}
164
165inline css::uno::Type const &
166cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt32 const *) {
169}
170
171inline css::uno::Type const &
172cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_Int64 const *) {
174}
175
176inline css::uno::Type const &
177cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::sal_uInt64 const *) {
180}
181
182inline css::uno::Type const &
185}
186
187inline css::uno::Type const &
190}
191
192inline css::uno::Type const &
193cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoCharType const *) {
195}
196
197#if defined LIBO_INTERNAL_ONLY
198 // cf. sal/types.h sal_Unicode
199inline css::uno::Type const &
202}
203#endif
204
205inline css::uno::Type const &
206cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::rtl::OUString const *) {
208}
209
210inline css::uno::Type const &
212{
214}
215
216inline css::uno::Type const &
218{
220}
221
222template< 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
235template< typename T > inline css::uno::Type const &
237 SAL_UNUSED_PARAMETER css::uno::Sequence< T > const *)
238{
240 static_cast< ::cppu::UnoSequenceType< T > * >(0));
241}
242
243inline css::uno::Type const & cppu_detail_getUnoType(
244 SAL_UNUSED_PARAMETER css::uno::Exception const *)
245{
247}
248
249inline css::uno::Type const & cppu_detail_getUnoType(
250 SAL_UNUSED_PARAMETER css::uno::XInterface const *)
251{
253}
254
255template< 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
264namespace cppu {
265
286template< typename T > class UnoType {
287public:
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
299private:
302 void operator =(UnoType &) SAL_DELETED_FUNCTION;
303};
304
305template<> css::uno::Type inline const & UnoType<void>::get() {
307}
308
319template< typename T > inline css::uno::Type const &
321 return ::cppu::UnoType< T >::get();
322}
323
334inline css::uno::Type const &
335getTypeFavourUnsigned(SAL_UNUSED_PARAMETER ::sal_uInt16 const *) {
336 return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
337}
338
349template< typename T > inline css::uno::Type const &
350getTypeFavourUnsigned(css::uno::Sequence< T > const *);
351 // defined in com/sun/star/uno/Sequence.hxx
352
354
366template< typename T > inline css::uno::Type const &
368 return ::cppu::UnoType< T >::get();
369}
370
382inline css::uno::Type const &
384 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
385}
386
398template< typename T > inline css::uno::Type const &
399getTypeFavourChar(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: */
#define SAL_DELETED_FUNCTION
short-circuit extra-verbose API namespaces
Definition: types.h:374
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:539
unsigned char sal_Bool
Definition: types.h:34
sal_uInt16 sal_Unicode
Definition: types.h:119
signed char sal_Int8
Definition: types.h:39
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.
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.
@ typelib_TypeClass_VOID
type class of void
Definition: typeclass.h:28
@ typelib_TypeClass_UNSIGNED_SHORT
type class of unsigned short
Definition: typeclass.h:38
@ typelib_TypeClass_CHAR
type class of char
Definition: typeclass.h:30
@ typelib_TypeClass_HYPER
type class of hyper
Definition: typeclass.h:44
@ typelib_TypeClass_BYTE
type class of byte
Definition: typeclass.h:34
@ typelib_TypeClass_BOOLEAN
type class of boolean
Definition: typeclass.h:32
@ typelib_TypeClass_INTERFACE
type class of interface
Definition: typeclass.h:78
@ typelib_TypeClass_STRING
type class of string
Definition: typeclass.h:52
@ typelib_TypeClass_SHORT
type class of short
Definition: typeclass.h:36
@ typelib_TypeClass_FLOAT
type class of float
Definition: typeclass.h:48
@ typelib_TypeClass_DOUBLE
type class of double
Definition: typeclass.h:50
@ typelib_TypeClass_ANY
type class of any
Definition: typeclass.h:56
@ typelib_TypeClass_TYPE
type class of type
Definition: typeclass.h:54
@ typelib_TypeClass_UNSIGNED_HYPER
type class of unsigned hyper
Definition: typeclass.h:46
@ typelib_TypeClass_LONG
type class of long
Definition: typeclass.h:40
@ typelib_TypeClass_UNSIGNED_LONG
type class of unsigned long
Definition: typeclass.h:42
@ typelib_TypeClass_EXCEPTION
type class of exception
Definition: typeclass.h:69
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
Definition: Enterable.hxx:27
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition: unotype.hxx:320
::com::sun::star::uno::Type const & getTypeFavourChar(SAL_UNUSED_PARAMETER ::com::sun::star::uno::Sequence< T > const *)
Definition: Sequence.hxx:299
Definition: unotype.hxx:35
Definition: unotype.hxx:35
Definition: unotype.hxx:43
Definition: unotype.hxx:99
css::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER css::uno::Reference< T > const *)
Definition: unotype.hxx:256
css::uno::Type const & getTypeFromTypeDescriptionReference(::typelib_TypeDescriptionReference *const *tdr)
Definition: unotype.hxx:101
css::uno::Type const & cppu_detail_getUnoType(SAL_UNUSED_PARAMETER ::cppu::UnoVoidType const *)
Definition: unotype.hxx:120
css::uno::Type const & getTypeFromTypeClass(::typelib_TypeClass tc)
Definition: unotype.hxx:108
Get the css::uno::Type instance representing a certain UNO type.
Definition: unotype.hxx:286
static css::uno::Type const & get()
Definition: unotype.hxx:288
A unique C++ type template representing the UNO sequence types in cppu::UnoType.
Definition: unotype.hxx:97
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:161