LibreOffice
LibreOffice 7.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 * >(
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 
64  : _pType( pType )
65 {
67 }
68 
70  : _pType( pType )
71 {
72 }
73 
75  : _pType( pType )
76 {
77 }
78 
79 inline Type::Type( const Type & rType )
80  : _pType( rType._pType )
81 {
83 }
84 
85 inline ::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 
97 template< class T >
99 
100 #if defined LIBO_INTERNAL_ONLY
101 
107 template<typename charT, typename traits> std::basic_ostream<charT, traits> &
108 operator <<(std::basic_ostream<charT, traits> & stream, Type const & type)
109 { return stream << type.getTypeName(); }
110 #endif
111 
112 }
113 }
114 }
115 }
116 
117 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type * )
118 {
119  return ::cppu::UnoType< ::com::sun::star::uno::Type >::get();
120 }
121 
122 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType()
123 {
124  return ::cppu::UnoType<void>::get();
125 }
126 inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType()
127 {
128  return ::cppu::UnoType<void>::get();
129 }
130 
131 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType()
132 {
133  return ::cppu::UnoType< bool >::get();
134 }
135 inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType()
136 {
137  return ::cppu::UnoType< bool >::get();
138 }
139 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * )
140 {
141  return ::cppu::UnoType< bool >::get();
142 }
143 
144 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
145  SAL_UNUSED_PARAMETER bool const * )
146 {
147  return ::cppu::UnoType< bool >::get();
148 }
149 
150 inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType()
151 {
152  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
153 }
154 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType()
155 {
156  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
157 }
158 
159 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int8 * )
160 {
161  return ::cppu::UnoType< ::sal_Int8 >::get();
162 }
163 
164 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::rtl::OUString * )
165 {
166  return ::cppu::UnoType< ::rtl::OUString >::get();
167 }
168 
169 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int16 * )
170 {
171  return ::cppu::UnoType< ::sal_Int16 >::get();
172 }
173 
174 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt16 * )
175 {
176  return ::cppu::UnoType< ::cppu::UnoUnsignedShortType >::get();
177 }
178 
179 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int32 * )
180 {
181  return ::cppu::UnoType< ::sal_Int32 >::get();
182 }
183 
184 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt32 * )
185 {
186  return ::cppu::UnoType< ::sal_uInt32 >::get();
187 }
188 
189 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Int64 * )
190 {
191  return ::cppu::UnoType< ::sal_Int64 >::get();
192 }
193 
194 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_uInt64 * )
195 {
196  return ::cppu::UnoType< ::sal_uInt64 >::get();
197 }
198 
199 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * )
200 {
201  return ::cppu::UnoType< float >::get();
202 }
203 
204 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * )
205 {
206  return ::cppu::UnoType< double >::get();
207 }
208 
209 template< typename T >
210 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType()
211 {
212  return ::cppu::UnoType< T >::get();
213 }
214 
215 template<>
216 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType< sal_Unicode >()
217 {
218  return ::cppu::UnoType< ::cppu::UnoCharType >::get();
219 }
220 
221 #endif
222 
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Type()
Default Constructor: Type is set to void.
Definition: Type.hxx:44
inline ::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition: Type.hxx:85
const ::com::sun::star::uno::Type & getCppuVoidType()
Gets the meta type of IDL type void.
Definition: Type.hxx:122
signed char sal_Int8
Definition: types.h:43
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:158
const ::com::sun::star::uno::Type & getCppuCharType()
Gets the meta type of IDL type char.
Definition: Type.hxx:154
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:131
Type & operator=(const Type &rType)
Assignment operator: Acquires right side type and releases previously set type.
Definition: Type.hxx:90
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
CPPU_DLLPUBLIC void typelib_typedescriptionreference_newByAsciiName(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, const char *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:568
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_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
Definition: types.h:359
UnoType_NoAcquire
Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
Definition: Type.h:43
CPPU_DLLPUBLIC void typelib_typedescriptionreference_assign(typelib_TypeDescriptionReference **ppDest, typelib_TypeDescriptionReference *pSource) SAL_THROW_EXTERN_C()
Assigns a type.
CPPU_DLLPUBLIC void typelib_typedescriptionreference_acquire(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
Increments reference count of type description reference.
unsigned char sal_Bool
Definition: types.h:38
type class of void
Definition: typeclass.h:32
__sal_NoAcquire
Definition: types.h:352
const ::com::sun::star::uno::Type & getBooleanCppuType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:135
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type *)
Definition: Type.hxx:117
Helper class to specify a type pointer for idl arrays.
Definition: Type.h:198
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition: Type.hxx:150
C++ class representing an IDL meta type.
Definition: Type.h:58
const ::com::sun::star::uno::Type & getVoidCppuType()
Gets the meta type of IDL type void.
Definition: Type.hxx:126
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition: Type.hxx:216