LibreOffice
LibreOffice 24.8 SDK C/C++ API Reference
Loading...
Searching...
No Matches
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
20/*
21 * This file is part of LibreOffice published API.
22 */
23#ifndef INCLUDED_COM_SUN_STAR_UNO_TYPE_HXX
24#define INCLUDED_COM_SUN_STAR_UNO_TYPE_HXX
25
26#include "sal/config.h"
27
28#include <cstddef>
29#include <ostream>
30
32#include "cppu/unotype.hxx"
33
34namespace com
35{
36namespace sun
37{
38namespace star
39{
40namespace uno
41{
42
43
50
51inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName )
52 : _pType( NULL )
53{
54 ::typelib_typedescriptionreference_new( &_pType, static_cast<typelib_TypeClass>(eTypeClass), rTypeName.pData );
55}
56
57inline Type::Type( TypeClass eTypeClass, const char * pTypeName )
58 : _pType( NULL )
59{
60 ::typelib_typedescriptionreference_newByAsciiName( &_pType, static_cast<typelib_TypeClass>(eTypeClass), pTypeName );
61}
62
64 : _pType( pType )
65{
67}
68
70 : _pType( pType )
71{
72}
73
75 : _pType( pType )
76{
77}
78
79inline Type::Type( const Type & rType )
80 : _pType( rType._pType )
81{
83}
84
85inline ::rtl::OUString Type::getTypeName() const
86{
87 return ::rtl::OUString( _pType->pTypeName );
88}
89
90inline Type & Type::operator = ( const Type & rType )
91{
92 ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
93 return *this;
94}
95
96#if defined LIBO_INTERNAL_ONLY
97inline Type & Type::operator = ( Type && rType )
98{
99 std::swap(_pType, rType._pType);
100 return *this;
101}
102#endif
103
104
105template< class T >
107
108#if defined LIBO_INTERNAL_ONLY
115template<typename charT, typename traits> std::basic_ostream<charT, traits> &
116operator <<(std::basic_ostream<charT, traits> & stream, Type const & type)
117{ return stream << type.getTypeName(); }
118#endif
119
120}
121}
122}
123}
124
125inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type * )
126{
127 return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
128}
129
130inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType()
131{
132 return ::cppu::UnoType<void>::get();
133}
134inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType()
135{
136 return ::cppu::UnoType<void>::get();
137}
138
139inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType()
140{
141 return ::cppu::UnoType< bool >::get();
142}
143inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType()
144{
145 return ::cppu::UnoType< bool >::get();
146}
147inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * )
148{
149 return ::cppu::UnoType< bool >::get();
150}
151
152inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
153 SAL_UNUSED_PARAMETER bool const * )
154{
155 return ::cppu::UnoType< bool >::get();
156}
157
158inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType()
159{
160 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
161}
162inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType()
163{
164 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
165}
166
167inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int8 * )
168{
169 return ::cppu::UnoType< ::sal_Int8 >::get();
170}
171
172inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::rtl::OUString * )
173{
174 return ::cppu::UnoType< ::rtl::OUString >::get();
175}
176
177inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int16 * )
178{
179 return ::cppu::UnoType< ::sal_Int16 >::get();
180}
181
182inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt16 * )
183{
184 return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
185}
186
187inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int32 * )
188{
189 return ::cppu::UnoType< ::sal_Int32 >::get();
190}
191
192inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt32 * )
193{
194 return ::cppu::UnoType< ::sal_uInt32 >::get();
195}
196
197inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int64 * )
198{
199 return ::cppu::UnoType< ::sal_Int64 >::get();
200}
201
202inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt64 * )
203{
204 return ::cppu::UnoType< ::sal_uInt64 >::get();
205}
206
207inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * )
208{
209 return ::cppu::UnoType< float >::get();
210}
211
212inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * )
213{
214 return ::cppu::UnoType< double >::get();
215}
216
217template< typename T >
218inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType()
219{
220 return ::cppu::UnoType< T >::get();
221}
222
223template<>
224inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
225{
226 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
227}
228
229#endif
230
231/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
__sal_NoAcquire
Definition types.h:371
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition types.h:592
unsigned char sal_Bool
Definition types.h:38
signed char sal_Int8
Definition types.h:43
@ typelib_TypeClass_VOID
type class of void
Definition typeclass.h:32
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
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.
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition Type.hxx:139
const ::com::sun::star::uno::Type & getBooleanCppuType()
Gets the meta type of IDL type boolean.
Definition Type.hxx:143
const ::com::sun::star::uno::Type & getVoidCppuType()
Gets the meta type of IDL type void.
Definition Type.hxx:134
const ::com::sun::star::uno::Type & getCppuCharType()
Gets the meta type of IDL type char.
Definition Type.hxx:162
const ::com::sun::star::uno::Type & getCppuVoidType()
Gets the meta type of IDL type void.
Definition Type.hxx:130
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition Type.hxx:224
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition Type.hxx:158
const ::com::sun::star::uno::Type & getCppuType()
Gets the meta type of an IDL type.
Definition Type.hxx:218
Definition types.h:377
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:708
UnoType_NoAcquire
Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
Definition Type.h:44
C++ class representing an IDL meta type.
Definition Type.h:59
Type & operator=(const Type &rType)
Assignment operator: Acquires right side type and releases previously set type.
Definition Type.hxx:90
inline ::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition Type.hxx:85
Type()
Default Constructor: Type is set to void.
Definition Type.hxx:44
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition Type.h:162
static typelib_TypeDescriptionReference * s_pType
Definition Type.h:205