LibreOffice
LibreOffice 7.1 SDK C/C++ API Reference
Type.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#ifndef INCLUDED_COM_SUN_STAR_UNO_TYPE_HXX
20#define INCLUDED_COM_SUN_STAR_UNO_TYPE_HXX
21
22#include "sal/config.h"
23
24#include <cstddef>
25#include <ostream>
26
28#include "cppu/unotype.hxx"
29
30namespace com
31{
32namespace sun
33{
34namespace star
35{
36namespace uno
37{
38
39
40inline Type::Type()
41{
42 _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
45}
46
47inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName )
48 : _pType( NULL )
49{
50 ::typelib_typedescriptionreference_new( &_pType, static_cast<typelib_TypeClass>(eTypeClass), rTypeName.pData );
51}
52
53inline Type::Type( TypeClass eTypeClass, const char * pTypeName )
54 : _pType( NULL )
55{
56 ::typelib_typedescriptionreference_newByAsciiName( &_pType, static_cast<typelib_TypeClass>(eTypeClass), pTypeName );
57}
58
60 : _pType( pType )
61{
63}
64
66 : _pType( pType )
67{
68}
69
71 : _pType( pType )
72{
73}
74
75inline Type::Type( const Type & rType )
76 : _pType( rType._pType )
77{
79}
80
81inline ::rtl::OUString Type::getTypeName() const
82{
83 return ::rtl::OUString( _pType->pTypeName );
84}
85
86inline Type & Type::operator = ( const Type & rType )
87{
88 ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
89 return *this;
90}
91
92
93template< class T >
95
96#if defined LIBO_INTERNAL_ONLY
103template<typename charT, typename traits> std::basic_ostream<charT, traits> &
104operator <<(std::basic_ostream<charT, traits> & stream, Type const & type)
105{ return stream << type.getTypeName(); }
106#endif
107
108}
109}
110}
111}
112
113inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type * )
114{
115 return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
116}
117
118inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType()
119{
120 return ::cppu::UnoType<void>::get();
121}
122inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType()
123{
124 return ::cppu::UnoType<void>::get();
125}
126
127inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType()
128{
129 return ::cppu::UnoType< bool >::get();
130}
131inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType()
132{
133 return ::cppu::UnoType< bool >::get();
134}
135inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * )
136{
137 return ::cppu::UnoType< bool >::get();
138}
139
140inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
141 SAL_UNUSED_PARAMETER bool const * )
142{
143 return ::cppu::UnoType< bool >::get();
144}
145
146inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType()
147{
148 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
149}
150inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType()
151{
152 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
153}
154
155inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int8 * )
156{
157 return ::cppu::UnoType< ::sal_Int8 >::get();
158}
159
160inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::rtl::OUString * )
161{
162 return ::cppu::UnoType< ::rtl::OUString >::get();
163}
164
165inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int16 * )
166{
167 return ::cppu::UnoType< ::sal_Int16 >::get();
168}
169
170inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt16 * )
171{
172 return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
173}
174
175inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int32 * )
176{
177 return ::cppu::UnoType< ::sal_Int32 >::get();
178}
179
180inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt32 * )
181{
182 return ::cppu::UnoType< ::sal_uInt32 >::get();
183}
184
185inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int64 * )
186{
187 return ::cppu::UnoType< ::sal_Int64 >::get();
188}
189
190inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt64 * )
191{
192 return ::cppu::UnoType< ::sal_uInt64 >::get();
193}
194
195inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * )
196{
197 return ::cppu::UnoType< float >::get();
198}
199
200inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * )
201{
202 return ::cppu::UnoType< double >::get();
203}
204
205template< typename T >
206inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType()
207{
208 return ::cppu::UnoType< T >::get();
209}
210
211template<>
212inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
213{
214 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
215}
216
217#endif
218
219/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
__sal_NoAcquire
Definition: types.h:349
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:539
unsigned char sal_Bool
Definition: types.h:34
signed char sal_Int8
Definition: types.h:39
CPPU_DLLPUBLIC void typelib_typedescriptionreference_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
CPPU_DLLPUBLIC void typelib_typedescriptionreference_acquire(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
Increments reference count of type description reference.
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
CPPU_DLLPUBLIC void typelib_typedescriptionreference_assign(typelib_TypeDescriptionReference **ppDest, typelib_TypeDescriptionReference *pSource) SAL_THROW_EXTERN_C()
Assigns a type.
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_DLLPUBLIC void typelib_typedescriptionreference_newByAsciiName(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, const char *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
@ typelib_TypeClass_VOID
type class of void
Definition: typeclass.h:28
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:127
const ::com::sun::star::uno::Type & getBooleanCppuType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:131
const ::com::sun::star::uno::Type & getVoidCppuType()
Gets the meta type of IDL type void.
Definition: Type.hxx:122
const ::com::sun::star::uno::Type & getCppuCharType()
Gets the meta type of IDL type char.
Definition: Type.hxx:150
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type *)
Definition: Type.hxx:113
const ::com::sun::star::uno::Type & getCppuVoidType()
Gets the meta type of IDL type void.
Definition: Type.hxx:118
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition: Type.hxx:212
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition: Type.hxx:146
Definition: unotype.hxx:35
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &o, Any const &any)
Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition: Any.hxx:695
UnoType_NoAcquire
Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
Definition: Type.h:40
C++ class representing an IDL meta type.
Definition: Type.h:55
Type & operator=(const Type &rType)
Assignment operator: Acquires right side type and releases previously set type.
Definition: Type.hxx:86
inline ::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition: Type.hxx:81
Type()
Default Constructor: Type is set to void.
Definition: Type.hxx:40
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:154
Helper class to specify a type pointer for idl arrays.
Definition: Type.h:195