UDK 3.2.7 C/C++ API Reference

com/sun/star/uno/Any.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
00002 /*
00003  * This file is part of the LibreOffice project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * This file incorporates work covered by the following license notice:
00010  *
00011  *   Licensed to the Apache Software Foundation (ASF) under one or more
00012  *   contributor license agreements. See the NOTICE file distributed
00013  *   with this work for additional information regarding copyright
00014  *   ownership. The ASF licenses this file to you under the Apache
00015  *   License, Version 2.0 (the "License"); you may not use this file
00016  *   except in compliance with the License. You may obtain a copy of
00017  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
00018  */
00019 #ifndef _COM_SUN_STAR_UNO_ANY_H_
00020 #define _COM_SUN_STAR_UNO_ANY_H_
00021 
00022 #include <uno/any2.h>
00023 #include <typelib/typedescription.h>
00024 #include <com/sun/star/uno/Type.h>
00025 #include "cppu/unotype.hxx"
00026 #include <rtl/alloc.h>
00027 
00028 
00029 namespace com
00030 {
00031 namespace sun
00032 {
00033 namespace star
00034 {
00035 namespace uno
00036 {
00037 
00046 class Any : public uno_Any
00047 {
00048 public:
00050     // these are here to force memory de/allocation to sal lib.
00051     inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
00052         { return ::rtl_allocateMemory( nSize ); }
00053     inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
00054         { ::rtl_freeMemory( pMem ); }
00055     inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
00056         { return pMem; }
00057     inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
00058         {}
00060 
00063     inline Any() SAL_THROW(());
00064 
00069     template <typename T>
00070     explicit inline Any( T const & value );
00072     explicit inline Any( bool value );
00073 
00078     inline Any( const Any & rAny ) SAL_THROW(());
00079 
00085     inline Any( const void * pData_, const Type & rType ) SAL_THROW(());
00086 
00092     inline Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
00093 
00099     inline Any( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
00100 
00103     inline ~Any() SAL_THROW(());
00104 
00110     inline Any & SAL_CALL operator = ( const Any & rAny ) SAL_THROW(());
00111 
00116     inline const Type & SAL_CALL getValueType() const SAL_THROW(())
00117         { return * reinterpret_cast< const Type * >( &pType ); }
00122     inline typelib_TypeDescriptionReference * SAL_CALL getValueTypeRef() const SAL_THROW(())
00123         { return pType; }
00124 
00130     inline void SAL_CALL getValueTypeDescription( typelib_TypeDescription ** ppTypeDescr ) const SAL_THROW(())
00131         { ::typelib_typedescriptionreference_getDescription( ppTypeDescr, pType ); }
00132 
00137     inline TypeClass SAL_CALL getValueTypeClass() const SAL_THROW(())
00138         { return (TypeClass)pType->eTypeClass; }
00139 
00144     inline ::rtl::OUString SAL_CALL getValueTypeName() const SAL_THROW(());
00145 
00150     inline sal_Bool SAL_CALL hasValue() const SAL_THROW(())
00151         { return (typelib_TypeClass_VOID != pType->eTypeClass); }
00152 
00157     inline const void * SAL_CALL getValue() const SAL_THROW(())
00158         { return pData; }
00159 
00160 #if ! defined(EXCEPTIONS_OFF)
00161 
00174     template <typename T>
00175     inline T get() const;
00176 #endif // ! defined(EXCEPTIONS_OFF)
00177 
00184     inline void SAL_CALL setValue( const void * pData_, const Type & rType ) SAL_THROW(());
00191     inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
00198     inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
00199 
00203     inline void SAL_CALL clear() SAL_THROW(());
00204 
00211     inline sal_Bool SAL_CALL isExtractableTo( const Type & rType ) const SAL_THROW(());
00212 
00219     template <typename T>
00220     inline bool has() const;
00221 
00228     inline sal_Bool SAL_CALL operator == ( const Any & rAny ) const SAL_THROW(());
00235     inline sal_Bool SAL_CALL operator != ( const Any & rAny ) const SAL_THROW(());
00236 
00237 private:
00238     // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
00239     explicit Any( sal_uInt16 );
00240 #if defined(_MSC_VER)
00241     // Omitting the following private declarations leads to an internal compiler
00242     // error on MSVC (version 1310).
00243     // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
00244 #if ! defined(EXCEPTIONS_OFF)
00245     template <>
00246     sal_uInt16 get<sal_uInt16>() const;
00247 #endif // ! defined(EXCEPTIONS_OFF)
00248     template <>
00249     bool has<sal_uInt16>() const;
00250 #endif // defined(_MSC_VER)
00251 };
00252 
00259 template< class C >
00260 inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(());
00261 
00262 // additionally specialized for C++ bool
00263 template<>
00264 inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(());
00265 
00266 class BaseReference;
00267 class Type;
00268 
00275 template< class C >
00276 inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(());
00277 
00278 // additionally for C++ bool:
00279 inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
00280     SAL_THROW(());
00281 
00291 template< class C >
00292 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(());
00293 
00304 template< class C >
00305 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(());
00316 template< class C >
00317 inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(());
00318 
00319 // additional specialized >>= and == operators
00320 // bool
00321 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Bool & value ) SAL_THROW(());
00322 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(());
00323 template<>
00324 inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
00325     SAL_THROW(());
00326 template<>
00327 inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
00328     SAL_THROW(());
00329 // byte
00330 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int8 & value ) SAL_THROW(());
00331 // short
00332 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(());
00333 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(());
00334 // long
00335 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(());
00336 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(());
00337 // hyper
00338 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(());
00339 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(());
00340 // float
00341 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(());
00342 // double
00343 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(());
00344 // string
00345 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(());
00346 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(());
00347 // type
00348 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(());
00349 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(());
00350 // any
00351 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(());
00352 // interface
00353 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(());
00354 
00355 }
00356 }
00357 }
00358 }
00359 
00369 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Any * ) SAL_THROW(())
00370 {
00371     return ::cppu::UnoType< ::com::sun::star::uno::Any >::get();
00372 }
00373 
00374 #endif
00375 
00376 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines