My Project
UDK 3.2.7 C/C++ API Reference
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Any.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * Copyright 2000, 2010 Oracle and/or its affiliates.
7  *
8  * OpenOffice.org - a multi-platform office productivity suite
9  *
10  * This file is part of OpenOffice.org.
11  *
12  * OpenOffice.org is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 3
14  * only, as published by the Free Software Foundation.
15  *
16  * OpenOffice.org is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License version 3 for more details
20  * (a copy is included in the LICENSE file that accompanied this code).
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * version 3 along with OpenOffice.org. If not, see
24  * <http://www.openoffice.org/license.html>
25  * for a copy of the LGPLv3 License.
26  *
27  ************************************************************************/
28 #ifndef _COM_SUN_STAR_UNO_ANY_H_
29 #define _COM_SUN_STAR_UNO_ANY_H_
30 
31 #include <uno/any2.h>
33 #include <com/sun/star/uno/Type.h>
34 #include "cppu/unotype.hxx"
35 #include <rtl/alloc.h>
36 
37 
38 namespace com
39 {
40 namespace sun
41 {
42 namespace star
43 {
44 namespace uno
45 {
46 
55 class Any : public uno_Any
56 {
57 public:
59  // these are here to force memory de/allocation to sal lib.
60  inline static void * SAL_CALL operator new ( size_t nSize ) SAL_THROW(())
61  { return ::rtl_allocateMemory( nSize ); }
62  inline static void SAL_CALL operator delete ( void * pMem ) SAL_THROW(())
63  { ::rtl_freeMemory( pMem ); }
64  inline static void * SAL_CALL operator new ( size_t, void * pMem ) SAL_THROW(())
65  { return pMem; }
66  inline static void SAL_CALL operator delete ( void *, void * ) SAL_THROW(())
67  {}
69 
72  inline Any() SAL_THROW(());
73 
78  template <typename T>
79  explicit inline Any( T const & value );
81  explicit inline Any( bool value );
82 
87  inline Any( const Any & rAny ) SAL_THROW(());
88 
94  inline Any( const void * pData_, const Type & rType ) SAL_THROW(());
95 
101  inline Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
102 
108  inline Any( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
109 
112  inline ~Any() SAL_THROW(());
113 
119  inline Any & SAL_CALL operator = ( const Any & rAny ) SAL_THROW(());
120 
125  inline const Type & SAL_CALL getValueType() const SAL_THROW(())
126  { return * reinterpret_cast< const Type * >( &pType ); }
131  inline typelib_TypeDescriptionReference * SAL_CALL getValueTypeRef() const SAL_THROW(())
132  { return pType; }
133 
139  inline void SAL_CALL getValueTypeDescription( typelib_TypeDescription ** ppTypeDescr ) const SAL_THROW(())
140  { ::typelib_typedescriptionreference_getDescription( ppTypeDescr, pType ); }
141 
146  inline TypeClass SAL_CALL getValueTypeClass() const SAL_THROW(())
147  { return (TypeClass)pType->eTypeClass; }
148 
153  inline ::rtl::OUString SAL_CALL getValueTypeName() const SAL_THROW(());
154 
159  inline sal_Bool SAL_CALL hasValue() const SAL_THROW(())
160  { return (typelib_TypeClass_VOID != pType->eTypeClass); }
161 
166  inline const void * SAL_CALL getValue() const SAL_THROW(())
167  { return pData; }
168 
169 #if ! defined(EXCEPTIONS_OFF)
170 
183  template <typename T>
184  inline T get() const;
185 #endif // ! defined(EXCEPTIONS_OFF)
186 
193  inline void SAL_CALL setValue( const void * pData_, const Type & rType ) SAL_THROW(());
200  inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescriptionReference * pType ) SAL_THROW(());
207  inline void SAL_CALL setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(());
208 
212  inline void SAL_CALL clear() SAL_THROW(());
213 
220  inline sal_Bool SAL_CALL isExtractableTo( const Type & rType ) const SAL_THROW(());
221 
228  template <typename T>
229  inline bool has() const;
230 
237  inline sal_Bool SAL_CALL operator == ( const Any & rAny ) const SAL_THROW(());
244  inline sal_Bool SAL_CALL operator != ( const Any & rAny ) const SAL_THROW(());
245 
246 private:
247  // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
248  explicit Any( sal_uInt16 );
249 #if defined(_MSC_VER)
250  // Omitting the following private declarations leads to an internal compiler
251  // error on MSVC (version 1310).
252  // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
253 #if ! defined(EXCEPTIONS_OFF)
254  template <>
255  sal_uInt16 get<sal_uInt16>() const;
256 #endif // ! defined(EXCEPTIONS_OFF)
257  template <>
258  bool has<sal_uInt16>() const;
259 #endif // defined(_MSC_VER)
260 };
261 
268 template< class C >
269 inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(());
270 
271 // additionally specialized for C++ bool
272 template<>
273 inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(());
274 
275 class BaseReference;
276 class Type;
277 
284 template< class C >
285 inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(());
286 
287 // additionally for C++ bool:
288 inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
289  SAL_THROW(());
290 
300 template< class C >
301 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(());
302 
313 template< class C >
314 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(());
325 template< class C >
326 inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(());
327 
328 // additional specialized >>= and == operators
329 // bool
330 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Bool & value ) SAL_THROW(());
331 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(());
332 template<>
333 inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
334  SAL_THROW(());
335 template<>
336 inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
337  SAL_THROW(());
338 // byte
339 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int8 & value ) SAL_THROW(());
340 // short
341 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(());
342 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(());
343 // long
344 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(());
345 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(());
346 // hyper
347 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(());
348 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(());
349 // float
350 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(());
351 // double
352 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(());
353 // string
354 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(());
355 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(());
356 // type
357 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(());
358 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(());
359 // any
360 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(());
361 // interface
362 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(());
363 
364 }
365 }
366 }
367 }
368 
378 inline const ::com::sun::star::uno::Type & SAL_CALL getCppuType( SAL_UNUSED_PARAMETER const ::com::sun::star::uno::Any * ) SAL_THROW(())
379 {
380  return ::cppu::UnoType< ::com::sun::star::uno::Any >::get();
381 }
382 
383 #endif
384 
385 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */