LibreOffice LibreOffice 25.2 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
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
31#include "com/sun/star/uno/Type.h"
32#include "cppu/unotype.hxx"
33
34 namespace com
35{
36 namespace sun
37{
38 namespace star
39{
40 namespace uno
41{
42
43
44 inline Type::Type()
45{
46 _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
47 ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType();
48 ::typelib_typedescriptionreference_acquire( _pType );
49}
50
51 inline 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
57 inline Type::Type( TypeClass eTypeClass, const char * pTypeName )
58 : _pType( NULL )
59{
60 ::typelib_typedescriptionreference_newByAsciiName( &_pType, static_cast<typelib_TypeClass>(eTypeClass), pTypeName );
61}
62
63 inline Type::Type( typelib_TypeDescriptionReference * pType )
64 : _pType( pType )
65{
66 ::typelib_typedescriptionreference_acquire( _pType );
67}
68
69 inline Type::Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire )
70 : _pType( pType )
71{
72}
73
74 inline Type::Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire )
75 : _pType( pType )
76{
77}
78
79 inline Type::Type( const Type & rType )
80 : _pType( rType._pType )
81{
82 ::typelib_typedescriptionreference_acquire( _pType );
83}
84
85inline ::rtl::OUString Type::getTypeName() const
86{
87 return ::rtl::OUString( _pType->pTypeName );
88}
89
90 inline 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
97 inline Type & Type::operator = ( Type && rType )
98{
99 std::swap(_pType, rType._pType);
100 return *this;
101}
102#endif
103
104
105 template< class T >
106 typelib_TypeDescriptionReference * Array< T >::s_pType = NULL;
107
108#if defined LIBO_INTERNAL_ONLY
115 template<typename charT, typename traits> std::basic_ostream<charT, traits> &
116 operator <<(std::basic_ostream<charT, traits> & stream, Type const & type)
117{ return stream << type.getTypeName(); }
118#endif
119
120}
121}
122}
123}
124
125 inline 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
130 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType()
131{
132 return ::cppu::UnoType<void>::get();
133}
134 inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType()
135{
136 return ::cppu::UnoType<void>::get();
137}
138
139 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType()
140{
141 return ::cppu::UnoType< bool >::get();
142}
143 inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType()
144{
145 return ::cppu::UnoType< bool >::get();
146}
147 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * )
148{
149 return ::cppu::UnoType< bool >::get();
150}
151
152 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
153 SAL_UNUSED_PARAMETER bool const * )
154{
155 return ::cppu::UnoType< bool >::get();
156}
157
158 inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType()
159{
160 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
161}
162 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType()
163{
164 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
165}
166
167 inline 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
172 inline 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
177 inline 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
182 inline 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
187 inline 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
192 inline 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
197 inline 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
202 inline 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
207 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * )
208{
209 return ::cppu::UnoType< float >::get();
210}
211
212 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * )
213{
214 return ::cppu::UnoType< double >::get();
215}
216
217 template< typename T >
218 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType()
219{
220 return ::cppu::UnoType< T >::get();
221}
222
223 template<>
224 inline 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: */
config.h
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:371
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_Int8
signed char sal_Int8
Definition: types.h:43
typelib_TypeClass_VOID
@ typelib_TypeClass_VOID
type class of void
Definition: typeclass.h:32
typelib_TypeClass
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
typelib_typedescriptionreference_new
CPPU_DLLPUBLIC void typelib_typedescriptionreference_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
typelib_typedescriptionreference_acquire
CPPU_DLLPUBLIC void typelib_typedescriptionreference_acquire(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
Increments reference count of type description reference.
typelib_TypeDescriptionReference
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
typelib_typedescriptionreference_assign
CPPU_DLLPUBLIC void typelib_typedescriptionreference_assign(typelib_TypeDescriptionReference **ppDest, typelib_TypeDescriptionReference *pSource) SAL_THROW_EXTERN_C()
Assigns a type.
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.
typelib_typedescriptionreference_newByAsciiName
CPPU_DLLPUBLIC void typelib_typedescriptionreference_newByAsciiName(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, const char *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
unotype.hxx
Type.h
getCppuBooleanType
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:139
getBooleanCppuType
const ::com::sun::star::uno::Type & getBooleanCppuType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:143
getVoidCppuType
const ::com::sun::star::uno::Type & getVoidCppuType()
Gets the meta type of IDL type void.
Definition: Type.hxx:134
getCppuCharType
const ::com::sun::star::uno::Type & getCppuCharType()
Gets the meta type of IDL type char.
Definition: Type.hxx:162
getCppuType
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type *)
Definition: Type.hxx:125
getCppuVoidType
const ::com::sun::star::uno::Type & getCppuVoidType()
Gets the meta type of IDL type void.
Definition: Type.hxx:130
getCppuType< sal_Unicode >
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition: Type.hxx:224
getCharCppuType
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition: Type.hxx:158
com
Definition: types.h:377
com::sun::star::uno::operator<<
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
com::sun::star::uno::UnoType_NoAcquire
UnoType_NoAcquire
Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
Definition: Type.h:44
com::sun::star::uno::Type
C++ class representing an IDL meta type.
Definition: Type.h:59
com::sun::star::uno::Type::operator=
Type & operator=(const Type &rType)
Assignment operator: Acquires right side type and releases previously set type.
Definition: Type.hxx:90
com::sun::star::uno::Type::getTypeName
inline ::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition: Type.hxx:85
com::sun::star::uno::Type::Type
Type()
Default Constructor: Type is set to void.
Definition: Type.hxx:44
com::sun::star::uno::Type::getTypeLibType
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:162
com::sun::star::uno::Array::s_pType
static typelib_TypeDescriptionReference * s_pType
Definition: Type.h:205