| 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 |
|
| 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 > |
| 106 |
typelib_TypeDescriptionReference * Array< T >::s_pType = NULL; |
| 107 |
|
| 108 |
#if defined LIBO_INTERNAL_ONLY |
| 109 |
/** |
| 110 |
Support for Type in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO |
| 111 |
macros, for example). |
| 112 |
|
| 113 |
@since LibreOffice 5.4 |
| 114 |
*/ |
| 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: */ |