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  *
00004  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
00005  *
00006  * Copyright 2000, 2010 Oracle and/or its affiliates.
00007  *
00008  * OpenOffice.org - a multi-platform office productivity suite
00009  *
00010  * This file is part of OpenOffice.org.
00011  *
00012  * OpenOffice.org is free software: you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 3
00014  * only, as published by the Free Software Foundation.
00015  *
00016  * OpenOffice.org is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License version 3 for more details
00020  * (a copy is included in the LICENSE file that accompanied this code).
00021  *
00022  * You should have received a copy of the GNU Lesser General Public License
00023  * version 3 along with OpenOffice.org.  If not, see
00024  * <http://www.openoffice.org/license.html>
00025  * for a copy of the LGPLv3 License.
00026  *
00027  ************************************************************************/
00028 #ifndef _COM_SUN_STAR_UNO_ANY_H_
00029 #define _COM_SUN_STAR_UNO_ANY_H_
00030 
00031 #include <uno/any2.h>
00032 #include <typelib/typedescription.h>
00033 #include <com/sun/star/uno/Type.h>
00034 #include "cppu/unotype.hxx"
00035 #include <rtl/alloc.h>
00036 
00037 
00038 namespace com
00039 {
00040 namespace sun
00041 {
00042 namespace star
00043 {
00044 namespace uno
00045 {
00046 
00055 class Any : public uno_Any
00056 {
00057 public:
00059     // these are here to force memory de/allocation to sal lib.
00060     inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
00061         { return ::rtl_allocateMemory( nSize ); }
00062     inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
00063         { ::rtl_freeMemory( pMem ); }
00064     inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
00065         { return pMem; }
00066     inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
00067         {}
00069 
00072     inline Any() SAL_THROW(());
00073 
00078     template <typename T>
00079     explicit inline Any( T const & value );
00081     explicit inline Any( bool value );
00082 
00087     inline Any( const Any & rAny ) SAL_THROW(());
00088 
00094     inline Any( const void * pData_, const Type & rType ) SAL_THROW(());
00095 
00101     inline Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
00102 
00108     inline Any( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
00109 
00112     inline ~Any() SAL_THROW(());
00113 
00119     inline Any & SAL_CALL operator = ( const Any & rAny ) SAL_THROW(());
00120 
00125     inline const Type & SAL_CALL getValueType() const SAL_THROW(())
00126         { return * reinterpret_cast< const Type * >( &pType ); }
00131     inline typelib_TypeDescriptionReference * SAL_CALL getValueTypeRef() const SAL_THROW(())
00132         { return pType; }
00133 
00139     inline void SAL_CALL getValueTypeDescription( typelib_TypeDescription ** ppTypeDescr ) const SAL_THROW(())
00140         { ::typelib_typedescriptionreference_getDescription( ppTypeDescr, pType ); }
00141 
00146     inline TypeClass SAL_CALL getValueTypeClass() const SAL_THROW(())
00147         { return (TypeClass)pType->eTypeClass; }
00148 
00153     inline ::rtl::OUString SAL_CALL getValueTypeName() const SAL_THROW(());
00154 
00159     inline sal_Bool SAL_CALL hasValue() const SAL_THROW(())
00160         { return (typelib_TypeClass_VOID != pType->eTypeClass); }
00161 
00166     inline const void * SAL_CALL getValue() const SAL_THROW(())
00167         { return pData; }
00168 
00169 #if ! defined(EXCEPTIONS_OFF)
00170 
00183     template <typename T>
00184     inline T get() const;
00185 #endif // ! defined(EXCEPTIONS_OFF)
00186 
00193     inline void SAL_CALL setValue( const void * pData_, const Type & rType ) SAL_THROW(());
00200     inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
00207     inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
00208 
00212     inline void SAL_CALL clear() SAL_THROW(());
00213 
00220     inline sal_Bool SAL_CALL isExtractableTo( const Type & rType ) const SAL_THROW(());
00221 
00228     template <typename T>
00229     inline bool has() const;
00230 
00237     inline sal_Bool SAL_CALL operator == ( const Any & rAny ) const SAL_THROW(());
00244     inline sal_Bool SAL_CALL operator != ( const Any & rAny ) const SAL_THROW(());
00245 
00246 private:
00247     // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
00248     explicit Any( sal_uInt16 );
00249 #if defined(_MSC_VER)
00250     // Omitting the following private declarations leads to an internal compiler
00251     // error on MSVC (version 1310).
00252     // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
00253 #if ! defined(EXCEPTIONS_OFF)
00254     template <>
00255     sal_uInt16 get<sal_uInt16>() const;
00256 #endif // ! defined(EXCEPTIONS_OFF)
00257     template <>
00258     bool has<sal_uInt16>() const;
00259 #endif // defined(_MSC_VER)
00260 };
00261 
00268 template< class C >
00269 inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(());
00270 
00271 // additionally specialized for C++ bool
00272 template<>
00273 inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(());
00274 
00275 class BaseReference;
00276 class Type;
00277 
00284 template< class C >
00285 inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(());
00286 
00287 // additionally for C++ bool:
00288 inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
00289     SAL_THROW(());
00290 
00300 template< class C >
00301 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(());
00302 
00313 template< class C >
00314 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(());
00325 template< class C >
00326 inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(());
00327 
00328 // additional specialized >>= and == operators
00329 // bool
00330 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Bool & value ) SAL_THROW(());
00331 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(());
00332 template<>
00333 inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
00334     SAL_THROW(());
00335 template<>
00336 inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
00337     SAL_THROW(());
00338 // byte
00339 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int8 & value ) SAL_THROW(());
00340 // short
00341 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(());
00342 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(());
00343 // long
00344 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(());
00345 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(());
00346 // hyper
00347 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(());
00348 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(());
00349 // float
00350 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(());
00351 // double
00352 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(());
00353 // string
00354 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(());
00355 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(());
00356 // type
00357 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(());
00358 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(());
00359 // any
00360 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(());
00361 // interface
00362 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(());
00363 
00364 }
00365 }
00366 }
00367 }
00368 
00378 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Any * ) SAL_THROW(())
00379 {
00380     return ::cppu::UnoType< ::com::sun::star::uno::Any >::get();
00381 }
00382 
00383 #endif
00384 
00385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines