xref: /aoo41x/main/cppu/inc/com/sun/star/uno/Any.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _COM_SUN_STAR_UNO_ANY_HXX_
28 #define _COM_SUN_STAR_UNO_ANY_HXX_
29 
30 #include <com/sun/star/uno/Any.h>
31 #include <uno/data.h>
32 #include <com/sun/star/uno/Type.hxx>
33 #include <com/sun/star/uno/XInterface.hpp>
34 #include <com/sun/star/uno/genfunc.hxx>
35 #include "cppu/unotype.hxx"
36 
37 namespace com
38 {
39 namespace sun
40 {
41 namespace star
42 {
43 namespace uno
44 {
45 
46 //__________________________________________________________________________________________________
47 inline Any::Any() SAL_THROW( () )
48 {
49 	::uno_any_construct( this, 0, 0, (uno_AcquireFunc)cpp_acquire );
50 }
51 
52 //______________________________________________________________________________
53 template <typename T>
54 inline Any::Any( T const & value )
55 {
56 	::uno_type_any_construct(
57 		this, const_cast<T *>(&value),
58         ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
59         (uno_AcquireFunc) cpp_acquire );
60 }
61 //______________________________________________________________________________
62 inline Any::Any( bool value )
63 {
64     sal_Bool b = value;
65 	::uno_type_any_construct(
66 		this, &b, ::getCppuBooleanType().getTypeLibType(),
67         (uno_AcquireFunc) cpp_acquire );
68 }
69 
70 //__________________________________________________________________________________________________
71 inline Any::Any( const Any & rAny ) SAL_THROW( () )
72 {
73 	::uno_type_any_construct( this, rAny.pData, rAny.pType, (uno_AcquireFunc)cpp_acquire );
74 }
75 //__________________________________________________________________________________________________
76 inline Any::Any( const void * pData_, const Type & rType ) SAL_THROW( () )
77 {
78 	::uno_type_any_construct(
79 		this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
80         (uno_AcquireFunc)cpp_acquire );
81 }
82 //__________________________________________________________________________________________________
83 inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW( () )
84 {
85 	::uno_any_construct(
86 		this, const_cast< void * >( pData_ ), pTypeDescr, (uno_AcquireFunc)cpp_acquire );
87 }
88 //__________________________________________________________________________________________________
89 inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW( () )
90 {
91 	::uno_type_any_construct(
92 		this, const_cast< void * >( pData_ ), pType_, (uno_AcquireFunc)cpp_acquire );
93 }
94 //__________________________________________________________________________________________________
95 inline Any::~Any() SAL_THROW( () )
96 {
97 	::uno_any_destruct(
98 		this, (uno_ReleaseFunc)cpp_release );
99 }
100 //__________________________________________________________________________________________________
101 inline Any & Any::operator = ( const Any & rAny ) SAL_THROW( () )
102 {
103 	if (this != &rAny)
104 	{
105 		::uno_type_any_assign(
106 			this, rAny.pData, rAny.pType,
107             (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
108 	}
109 	return *this;
110 }
111 //__________________________________________________________________________________________________
112 inline ::rtl::OUString Any::getValueTypeName() const SAL_THROW( () )
113 {
114 	return ::rtl::OUString( pType->pTypeName );
115 }
116 //__________________________________________________________________________________________________
117 inline void Any::setValue( const void * pData_, const Type & rType ) SAL_THROW( () )
118 {
119 	::uno_type_any_assign(
120 		this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
121         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
122 }
123 //__________________________________________________________________________________________________
124 inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW( () )
125 {
126 	::uno_type_any_assign(
127 		this, const_cast< void * >( pData_ ), pType_,
128         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
129 }
130 //__________________________________________________________________________________________________
131 inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW( () )
132 {
133 	::uno_any_assign(
134 		this, const_cast< void * >( pData_ ), pTypeDescr,
135         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
136 }
137 //__________________________________________________________________________________________________
138 inline void Any::clear() SAL_THROW( () )
139 {
140 	::uno_any_clear(
141 		this, (uno_ReleaseFunc)cpp_release );
142 }
143 //__________________________________________________________________________________________________
144 inline sal_Bool Any::isExtractableTo( const Type & rType ) const SAL_THROW( () )
145 {
146     return ::uno_type_isAssignableFromData(
147         rType.getTypeLibType(), pData, pType,
148         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
149 }
150 
151 //______________________________________________________________________________
152 template <typename T>
153 inline bool Any::has() const
154 {
155     Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
156     return ::uno_type_isAssignableFromData(
157         rType.getTypeLibType(), pData, pType,
158         (uno_QueryInterfaceFunc) cpp_queryInterface,
159         (uno_ReleaseFunc) cpp_release );
160 }
161 #if ! defined(__SUNPRO_CC)
162 // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
163 template <>
164 bool Any::has<sal_uInt16>() const;
165 #endif // ! defined(__SUNPRO_CC)
166 
167 //__________________________________________________________________________________________________
168 inline sal_Bool Any::operator == ( const Any & rAny ) const SAL_THROW( () )
169 {
170 	return ::uno_type_equalData(
171 		pData, pType, rAny.pData, rAny.pType,
172         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
173 }
174 //__________________________________________________________________________________________________
175 inline sal_Bool Any::operator != ( const Any & rAny ) const SAL_THROW( () )
176 {
177 	return (! ::uno_type_equalData(
178 		pData, pType, rAny.pData, rAny.pType,
179         (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release ));
180 }
181 
182 //__________________________________________________________________________________________________
183 template< class C >
184 inline Any SAL_CALL makeAny( const C & value ) SAL_THROW( () )
185 {
186 	return Any( &value, ::cppu::getTypeFavourUnsigned(&value) );
187 }
188 
189 // additionally specialized for C++ bool
190 //______________________________________________________________________________
191 template<>
192 inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW( () )
193 {
194     const sal_Bool b = value;
195 	return Any( &b, ::getCppuBooleanType() );
196 }
197 
198 //__________________________________________________________________________________________________
199 template< class C >
200 inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW( () )
201 {
202 	const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
203 	::uno_type_any_assign(
204 		&rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
205         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
206 }
207 
208 // additionally for C++ bool:
209 //______________________________________________________________________________
210 inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
211     SAL_THROW( () )
212 {
213     sal_Bool b = value;
214     ::uno_type_any_assign(
215         &rAny, &b, ::getCppuBooleanType().getTypeLibType(),
216         (uno_AcquireFunc) cpp_acquire, (uno_ReleaseFunc) cpp_release );
217 }
218 
219 //__________________________________________________________________________________________________
220 template< class C >
221 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW( () )
222 {
223 	const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
224 	return ::uno_type_assignData(
225 		&value, rType.getTypeLibType(),
226 		rAny.pData, rAny.pType,
227 		(uno_QueryInterfaceFunc)cpp_queryInterface,
228         (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
229 }
230 
231 // bool
232 //__________________________________________________________________________________________________
233 inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) SAL_THROW( () )
234 {
235 	if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
236 	{
237 		value = (* reinterpret_cast< const sal_Bool * >( &rAny.pReserved ) != sal_False);
238 		return sal_True;
239 	}
240 	return sal_False;
241 }
242 //__________________________________________________________________________________________________
243 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW( () )
244 {
245 	return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
246 			(value != sal_False) == (* reinterpret_cast< const sal_Bool * >( &rAny.pReserved ) != sal_False));
247 }
248 
249 //______________________________________________________________________________
250 template<>
251 inline sal_Bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
252     SAL_THROW( () )
253 {
254 	if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
255 	{
256 		value = *reinterpret_cast< sal_Bool const * >(
257             &rAny.pReserved ) != sal_False;
258 		return true;
259 	}
260 	return false;
261 }
262 
263 //______________________________________________________________________________
264 template<>
265 inline sal_Bool SAL_CALL operator == ( Any const & rAny, bool const & value )
266     SAL_THROW( () )
267 {
268 	return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
269 			(value ==
270              (*reinterpret_cast< sal_Bool const * >( &rAny.pReserved )
271               != sal_False)));
272 }
273 
274 // byte
275 //__________________________________________________________________________________________________
276 inline sal_Bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) SAL_THROW( () )
277 {
278 	if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
279 	{
280 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
281 		return sal_True;
282 	}
283 	return sal_False;
284 }
285 // short
286 //__________________________________________________________________________________________________
287 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW( () )
288 {
289 	switch (rAny.pType->eTypeClass)
290 	{
291 	case typelib_TypeClass_BYTE:
292 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
293 		return sal_True;
294 	case typelib_TypeClass_SHORT:
295 	case typelib_TypeClass_UNSIGNED_SHORT:
296 		value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
297 		return sal_True;
298 	default:
299 		return sal_False;
300 	}
301 }
302 //__________________________________________________________________________________________________
303 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW( () )
304 {
305 	switch (rAny.pType->eTypeClass)
306 	{
307 	case typelib_TypeClass_BYTE:
308 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
309 		return sal_True;
310 	case typelib_TypeClass_SHORT:
311 	case typelib_TypeClass_UNSIGNED_SHORT:
312 		value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
313 		return sal_True;
314 	default:
315 		return sal_False;
316 	}
317 }
318 // long
319 //__________________________________________________________________________________________________
320 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW( () )
321 {
322 	switch (rAny.pType->eTypeClass)
323 	{
324 	case typelib_TypeClass_BYTE:
325 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
326 		return sal_True;
327 	case typelib_TypeClass_SHORT:
328 		value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
329 		return sal_True;
330 	case typelib_TypeClass_UNSIGNED_SHORT:
331 		value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
332 		return sal_True;
333 	case typelib_TypeClass_LONG:
334 	case typelib_TypeClass_UNSIGNED_LONG:
335 		value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
336 		return sal_True;
337 	default:
338 		return sal_False;
339 	}
340 }
341 //__________________________________________________________________________________________________
342 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW( () )
343 {
344 	switch (rAny.pType->eTypeClass)
345 	{
346 	case typelib_TypeClass_BYTE:
347 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
348 		return sal_True;
349 	case typelib_TypeClass_SHORT:
350 		value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
351 		return sal_True;
352 	case typelib_TypeClass_UNSIGNED_SHORT:
353 		value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
354 		return sal_True;
355 	case typelib_TypeClass_LONG:
356 	case typelib_TypeClass_UNSIGNED_LONG:
357 		value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
358 		return sal_True;
359 	default:
360 		return sal_False;
361 	}
362 }
363 // hyper
364 //__________________________________________________________________________________________________
365 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW( () )
366 {
367 	switch (rAny.pType->eTypeClass)
368 	{
369 	case typelib_TypeClass_BYTE:
370 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
371 		return sal_True;
372 	case typelib_TypeClass_SHORT:
373 		value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
374 		return sal_True;
375 	case typelib_TypeClass_UNSIGNED_SHORT:
376 		value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
377 		return sal_True;
378 	case typelib_TypeClass_LONG:
379 		value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
380 		return sal_True;
381 	case typelib_TypeClass_UNSIGNED_LONG:
382 		value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
383 		return sal_True;
384 	case typelib_TypeClass_HYPER:
385 	case typelib_TypeClass_UNSIGNED_HYPER:
386         value = * reinterpret_cast< const sal_Int64 * >(
387             (sizeof(void *) >= sizeof(sal_Int64)) ? (void *)&rAny.pReserved : rAny.pData );
388 		return sal_True;
389 
390 	default:
391 		return sal_False;
392 	}
393 }
394 //__________________________________________________________________________________________________
395 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW( () )
396 {
397 	switch (rAny.pType->eTypeClass)
398 	{
399 	case typelib_TypeClass_BYTE:
400 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
401 		return sal_True;
402 	case typelib_TypeClass_SHORT:
403 		value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
404 		return sal_True;
405 	case typelib_TypeClass_UNSIGNED_SHORT:
406 		value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
407 		return sal_True;
408 	case typelib_TypeClass_LONG:
409 		value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
410 		return sal_True;
411 	case typelib_TypeClass_UNSIGNED_LONG:
412 		value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
413 		return sal_True;
414 	case typelib_TypeClass_HYPER:
415 	case typelib_TypeClass_UNSIGNED_HYPER:
416         value = * reinterpret_cast< const sal_uInt64 * >(
417             (sizeof(void *) >= sizeof(sal_uInt64)) ? (void *)&rAny.pReserved : rAny.pData );
418 		return sal_True;
419 
420 	default:
421 		return sal_False;
422 	}
423 }
424 // float
425 //__________________________________________________________________________________________________
426 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW( () )
427 {
428 	switch (rAny.pType->eTypeClass)
429 	{
430 	case typelib_TypeClass_BYTE:
431 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
432 		return sal_True;
433 	case typelib_TypeClass_SHORT:
434 		value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
435 		return sal_True;
436 	case typelib_TypeClass_UNSIGNED_SHORT:
437 		value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
438 		return sal_True;
439 	case typelib_TypeClass_FLOAT:
440         value = * reinterpret_cast< const float * >(
441             (sizeof(void *) >= sizeof(float)) ? (void *)&rAny.pReserved : rAny.pData );
442 		return sal_True;
443 
444 	default:
445 		return sal_False;
446 	}
447 }
448 // double
449 //__________________________________________________________________________________________________
450 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW( () )
451 {
452 	switch (rAny.pType->eTypeClass)
453 	{
454 	case typelib_TypeClass_BYTE:
455 		value = * reinterpret_cast< const sal_Int8 * >( &rAny.pReserved );
456 		return sal_True;
457 	case typelib_TypeClass_SHORT:
458 		value = * reinterpret_cast< const sal_Int16 * >( &rAny.pReserved );
459 		return sal_True;
460 	case typelib_TypeClass_UNSIGNED_SHORT:
461 		value = * reinterpret_cast< const sal_uInt16 * >( &rAny.pReserved );
462 		return sal_True;
463 	case typelib_TypeClass_LONG:
464 		value = * reinterpret_cast< const sal_Int32 * >( &rAny.pReserved );
465 		return sal_True;
466 	case typelib_TypeClass_UNSIGNED_LONG:
467 		value = * reinterpret_cast< const sal_uInt32 * >( &rAny.pReserved );
468 		return sal_True;
469 	case typelib_TypeClass_FLOAT:
470         value = * reinterpret_cast< const float * >(
471             (sizeof(void *) >= sizeof(float)) ? (void *)&rAny.pReserved : rAny.pData );
472 		return sal_True;
473 	case typelib_TypeClass_DOUBLE:
474         value = * reinterpret_cast< const double * >(
475             (sizeof(void *) >= sizeof(double)) ? (void *)&rAny.pReserved : rAny.pData );
476 		return sal_True;
477 
478 	default:
479 		return sal_False;
480 	}
481 }
482 // string
483 //__________________________________________________________________________________________________
484 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW( () )
485 {
486 	if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
487 	{
488 		value = * reinterpret_cast< const ::rtl::OUString * >( &rAny.pReserved );
489 		return sal_True;
490 	}
491 	return sal_False;
492 }
493 //__________________________________________________________________________________________________
494 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW( () )
495 {
496 	return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
497 			value.equals( * reinterpret_cast< const ::rtl::OUString * >( &rAny.pReserved ) ));
498 }
499 // type
500 //__________________________________________________________________________________________________
501 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW( () )
502 {
503 	if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
504 	{
505 		value = * reinterpret_cast< const Type * >( &rAny.pReserved );
506 		return sal_True;
507 	}
508 	return sal_False;
509 }
510 //__________________________________________________________________________________________________
511 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW( () )
512 {
513 	return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
514 			value.equals( * reinterpret_cast< const Type * >( &rAny.pReserved ) ));
515 }
516 // any
517 //__________________________________________________________________________________________________
518 inline sal_Bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW( () )
519 {
520 	if (&rAny != &value)
521 	{
522 		::uno_type_any_assign(
523 			&value, rAny.pData, rAny.pType,
524             (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
525 	}
526 	return sal_True;
527 }
528 // interface
529 //__________________________________________________________________________________________________
530 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW( () )
531 {
532 	if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
533 	{
534 		return reinterpret_cast< const BaseReference * >( &rAny.pReserved )->operator == ( value );
535 	}
536 	return sal_False;
537 }
538 
539 // operator to compare to an any.
540 //__________________________________________________________________________________________________
541 template< class C >
542 inline sal_Bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW( () )
543 {
544 	const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
545 	return ::uno_type_equalData(
546 		rAny.pData, rAny.pType,
547 		const_cast< C * >( &value ), rType.getTypeLibType(),
548 		(uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
549 }
550 // operator to compare to an any.  may use specialized operators ==.
551 //__________________________________________________________________________________________________
552 template< class C >
553 inline sal_Bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW( () )
554 {
555 	return (! operator == ( rAny, value ));
556 }
557 
558 #if ! defined(EXCEPTIONS_OFF)
559 extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
560     uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
561     SAL_THROW_EXTERN_C();
562 
563 //______________________________________________________________________________
564 template <typename T>
565 T Any::get() const
566 {
567     T value = T();
568     if (! (*this >>= value)) {
569         throw RuntimeException(
570             ::rtl::OUString(
571                 cppu_Any_extraction_failure_msg(
572                     this,
573                     ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
574                 SAL_NO_ACQUIRE ),
575             Reference<XInterface>() );
576     }
577     return value;
578 }
579 // not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
580 template <>
581 sal_uInt16 Any::get<sal_uInt16>() const;
582 #endif // ! defined(EXCEPTIONS_OFF)
583 
584 }
585 }
586 }
587 }
588 
589 #endif
590