LibreOffice
LibreOffice 24.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 #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 >
107 
108 #if defined LIBO_INTERNAL_ONLY
109 
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: */
Type()
Default Constructor: Type is set to void.
Definition: Type.hxx:44
static typelib_TypeDescriptionReference * s_pType
Definition: Type.h:205
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:130
signed char sal_Int8
Definition: types.h:43
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:162
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 & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:139
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:143
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type *)
Definition: Type.hxx:125
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition: Type.hxx:158
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:134
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition: Type.hxx:224