LibreOffice LibreOffice 5.4 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
27 #include <com/sun/star/uno/Type.h>
28 #include <cppu/unotype.hxx>
29
30 namespace com
31 {
32 namespace sun
33 {
34 namespace star
35 {
36 namespace uno
37 {
38
39
40 inline Type::Type()
41 {
42 _pType = reinterpret_cast< const ::com::sun::star::uno::Type * >(
43 ::typelib_static_type_getByTypeClass( typelib_TypeClass_VOID ) )->getTypeLibType();
44 ::typelib_typedescriptionreference_acquire( _pType );
45 }
46
47 inline Type::Type( TypeClass eTypeClass, const ::rtl::OUString & rTypeName )
48 : _pType( NULL )
49 {
50 ::typelib_typedescriptionreference_new( &_pType, (typelib_TypeClass)eTypeClass, rTypeName.pData );
51 }
52
53 inline Type::Type( TypeClass eTypeClass, const sal_Char * pTypeName )
54 : _pType( NULL )
55 {
56 ::typelib_typedescriptionreference_newByAsciiName( &_pType, (typelib_TypeClass)eTypeClass, pTypeName );
57 }
58
59 inline Type::Type( typelib_TypeDescriptionReference * pType )
60 : _pType( pType )
61 {
62 ::typelib_typedescriptionreference_acquire( _pType );
63 }
64
65 inline Type::Type( typelib_TypeDescriptionReference * pType, UnoType_NoAcquire )
66 : _pType( pType )
67 {
68 }
69
70 inline Type::Type( typelib_TypeDescriptionReference * pType, __sal_NoAcquire )
71 : _pType( pType )
72 {
73 }
74
75 inline Type::Type( const Type & rType )
76 : _pType( rType._pType )
77 {
78 ::typelib_typedescriptionreference_acquire( _pType );
79 }
80
81 inline ::rtl::OUString Type::getTypeName() const
82 {
83 return ::rtl::OUString( _pType->pTypeName );
84 }
85
86 inline Type & Type::operator = ( const Type & rType )
87 {
88 ::typelib_typedescriptionreference_assign( &_pType, rType._pType );
89 return *this;
90 }
91
92
93 template< class T >
94 typelib_TypeDescriptionReference * Array< T >::s_pType = NULL;
95
96 #if defined LIBO_INTERNAL_ONLY
97
103 template<typename charT, typename traits> std::basic_ostream<charT, traits> &
104 operator <<(std::basic_ostream<charT, traits> & stream, Type const & type)
105 { return stream << type.getTypeName(); }
106 #endif
107
108 }
109 }
110 }
111 }
112
113 inline 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
118 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuVoidType()
119 {
120 return ::cppu::UnoType<void>::get();
121 }
122 inline const ::com::sun::star::uno::Type & SAL_CALL getVoidCppuType()
123 {
124 return ::cppu::UnoType<void>::get();
125 }
126
127 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuBooleanType()
128 {
129 return ::cppu::UnoType< bool >::get();
130 }
131 inline const ::com::sun::star::uno::Type & SAL_CALL getBooleanCppuType()
132 {
133 return ::cppu::UnoType< bool >::get();
134 }
135 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const sal_Bool * )
136 {
137 return ::cppu::UnoType< bool >::get();
138 }
139
140 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType(
141 SAL_UNUSED_PARAMETER bool const * )
142 {
143 return ::cppu::UnoType< bool >::get();
144 }
145
146 inline const ::com::sun::star::uno::Type & SAL_CALL getCharCppuType()
147 {
148 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
149 }
150 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuCharType()
151 {
152 return ::cppu::UnoType< ::cppu::UnoCharType >::get();
153 }
154
155 inline 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
160 inline 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
165 inline 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
170 inline 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
175 inline 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
180 inline 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
185 inline 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
190 inline 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
195 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const float * )
196 {
197 return ::cppu::UnoType< float >::get();
198 }
199
200 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const double * )
201 {
202 return ::cppu::UnoType< double >::get();
203 }
204
205 template< typename T >
206 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType()
207 {
208 return ::cppu::UnoType< T >::get();
209 }
210
211 template<>
212 inline 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: */
com::sun::star::uno::Type::getTypeName
inline ::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition: Type.hxx:81
Type.h
getCppuType
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type *)
Definition: Type.hxx:113
com::sun::star::uno::Array
Helper class to specify a type pointer for idl arrays.
Definition: Type.h:194
sal_Int8
signed char sal_Int8
Definition: types.h:44
typelib_typedescriptionreference_newByAsciiName
CPPU_DLLPUBLIC void typelib_typedescriptionreference_newByAsciiName(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, const sal_Char *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
com
Definition: types.h:373
getBooleanCppuType
const ::com::sun::star::uno::Type & getBooleanCppuType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:131
typelib_TypeDescriptionReference
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
getVoidCppuType
const ::com::sun::star::uno::Type & getVoidCppuType()
Gets the meta type of IDL type void.
Definition: Type.hxx:122
SAL_UNUSED_PARAMETER
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:577
getCharCppuType
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition: Type.hxx:146
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:86
typelib_typedescriptionreference_acquire
CPPU_DLLPUBLIC void typelib_typedescriptionreference_acquire(typelib_TypeDescriptionReference *pRef) SAL_THROW_EXTERN_C()
Increments reference count of type description reference.
typelib_TypeClass
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
sal_Bool
unsigned char sal_Bool
Definition: types.h:39
__sal_NoAcquire
__sal_NoAcquire
Definition: types.h:366
typelib_TypeClass_VOID
type class of void
Definition: typeclass.h:29
getCppuType< sal_Unicode >
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition: Type.hxx:212
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.
unotype.hxx
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_assign
CPPU_DLLPUBLIC void typelib_typedescriptionreference_assign(typelib_TypeDescriptionReference **ppDest, typelib_TypeDescriptionReference *pSource) SAL_THROW_EXTERN_C()
Assigns a type.
getCppuVoidType
const ::com::sun::star::uno::Type & getCppuVoidType()
Gets the meta type of IDL type void.
Definition: Type.hxx:118
getCppuCharType
const ::com::sun::star::uno::Type & getCppuCharType()
Gets the meta type of IDL type char.
Definition: Type.hxx:150
getCppuBooleanType
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:127
config.h
sal_Char
char sal_Char
A legacy synonym for char.
Definition: types.h:121
com::sun::star::uno::UnoType_NoAcquire
UnoType_NoAcquire
Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
Definition: Type.h:39
com::sun::star::uno::Type::Type
Type()
Default Constructor: Type is set to void.
Definition: Type.hxx:40
com::sun::star::uno::Type::getTypeLibType
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:154
com::sun::star::uno::Type
C++ class representing an IDL meta type.
Definition: Type.h:54