LibreOffice
LibreOffice 6.0 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 * >(
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 {
57 }
58 
60  : _pType( pType )
61 {
63 }
64 
66  : _pType( pType )
67 {
68 }
69 
71  : _pType( pType )
72 {
73 }
74 
75 inline Type::Type( const Type & rType )
76  : _pType( rType._pType )
77 {
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 >
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: */
UnoType_NoAcquire
Enum defining UNO_TYPE_NO_ACQUIRE for type description reference transfer.
Definition: Type.h:39
CPPU_DLLPUBLIC void typelib_typedescriptionreference_new(typelib_TypeDescriptionReference **ppTDR, typelib_TypeClass eTypeClass, rtl_uString *pTypeName) SAL_THROW_EXTERN_C()
Creates a type description reference.
const ::com::sun::star::uno::Type & getBooleanCppuType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:131
char sal_Char
A legacy synonym for char.
Definition: types.h:121
Type & operator=(const Type &rType)
Assignment operator: Acquires right side type and releases previously set type.
Definition: Type.hxx:86
const ::com::sun::star::uno::Type & getCppuType< sal_Unicode >()
Gets the meta type of IDL type char.
Definition: Type.hxx:212
const ::com::sun::star::uno::Type & getCharCppuType()
Gets the meta type of IDL type char.
Definition: Type.hxx:146
const ::com::sun::star::uno::Type & getVoidCppuType()
Gets the meta type of IDL type void.
Definition: Type.hxx:122
const ::com::sun::star::uno::Type & getCppuType(SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Type *)
Definition: Type.hxx:113
Definition: types.h:383
unsigned char sal_Bool
Definition: types.h:39
const ::com::sun::star::uno::Type & getCppuVoidType()
Gets the meta type of IDL type void.
Definition: Type.hxx:118
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:154
__sal_NoAcquire
Definition: types.h:376
#define SAL_UNUSED_PARAMETER
Annotate unused but required C++ function parameters.
Definition: types.h:587
inline::rtl::OUString getTypeName() const
Gets the name of the set type.
Definition: Type.hxx:81
C++ class representing an IDL meta type.
Definition: Type.h:54
Type()
Default Constructor: Type is set to void.
Definition: Type.hxx:40
signed char sal_Int8
Definition: types.h:44
enum _typelib_TypeClass typelib_TypeClass
This type class enum is binary compatible with the IDL enum com.sun.star.uno.TypeClass.
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.
const ::com::sun::star::uno::Type & getCppuCharType()
Gets the meta type of IDL type char.
Definition: Type.hxx:150
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.
const ::com::sun::star::uno::Type & getCppuBooleanType()
Gets the meta type of IDL type boolean.
Definition: Type.hxx:127
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.
Helper class to specify a type pointer for idl arrays.
Definition: Type.h:194
type class of void
Definition: typeclass.h:29