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#ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
20#define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
21
22#include <sal/config.h>
23
24#include <cassert>
25#include <iomanip>
26#include <ostream>
27
28#include <com/sun/star/uno/Any.h>
29#include <uno/data.h>
30#include <uno/sequence2.h>
31#include <com/sun/star/uno/Type.hxx>
32#include <com/sun/star/uno/XInterface.hpp>
33#include <com/sun/star/uno/genfunc.hxx>
34#include <cppu/unotype.hxx>
35
36namespace com
37{
38namespace sun
39{
40namespace star
41{
42namespace uno
43{
44
45//__________________________________________________________________________________________________
46inline Any::Any() SAL_THROW(())
47{
48 ::uno_any_construct( this, 0, 0, (uno_AcquireFunc)cpp_acquire );
49}
50
51//______________________________________________________________________________
52template <typename T>
53inline Any::Any( T const & value )
54{
55 ::uno_type_any_construct(
56 this, const_cast<T *>(&value),
57 ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
58 (uno_AcquireFunc) cpp_acquire );
59}
60//______________________________________________________________________________
61inline Any::Any( bool value )
62{
63 sal_Bool b = value;
64 ::uno_type_any_construct(
65 this, &b, ::getCppuBooleanType().getTypeLibType(),
66 (uno_AcquireFunc) cpp_acquire );
67}
68
69//__________________________________________________________________________________________________
70inline Any::Any( const Any & rAny ) SAL_THROW(())
71{
72 ::uno_type_any_construct( this, rAny.pData, rAny.pType, (uno_AcquireFunc)cpp_acquire );
73}
74//__________________________________________________________________________________________________
75inline Any::Any( const void * pData_, const Type & rType ) SAL_THROW(())
76{
77 ::uno_type_any_construct(
78 this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
79 (uno_AcquireFunc)cpp_acquire );
80}
81//__________________________________________________________________________________________________
82inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
83{
84 ::uno_any_construct(
85 this, const_cast< void * >( pData_ ), pTypeDescr, (uno_AcquireFunc)cpp_acquire );
86}
87//__________________________________________________________________________________________________
88inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
89{
90 ::uno_type_any_construct(
91 this, const_cast< void * >( pData_ ), pType_, (uno_AcquireFunc)cpp_acquire );
92}
93//__________________________________________________________________________________________________
94inline Any::~Any() SAL_THROW(())
95{
96 ::uno_any_destruct(
97 this, (uno_ReleaseFunc)cpp_release );
98}
99//__________________________________________________________________________________________________
100inline Any & Any::operator = ( const Any & rAny ) SAL_THROW(())
101{
102 if (this != &rAny)
103 {
104 ::uno_type_any_assign(
105 this, rAny.pData, rAny.pType,
106 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
107 }
108 return *this;
109}
110//__________________________________________________________________________________________________
111inline ::rtl::OUString Any::getValueTypeName() const SAL_THROW(())
112{
113 return ::rtl::OUString( pType->pTypeName );
114}
115//__________________________________________________________________________________________________
116inline void Any::setValue( const void * pData_, const Type & rType ) SAL_THROW(())
117{
118 ::uno_type_any_assign(
119 this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
120 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
121}
122//__________________________________________________________________________________________________
123inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ ) SAL_THROW(())
124{
125 ::uno_type_any_assign(
126 this, const_cast< void * >( pData_ ), pType_,
127 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
128}
129//__________________________________________________________________________________________________
130inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr ) SAL_THROW(())
131{
132 ::uno_any_assign(
133 this, const_cast< void * >( pData_ ), pTypeDescr,
134 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
135}
136//__________________________________________________________________________________________________
137inline void Any::clear() SAL_THROW(())
138{
139 ::uno_any_clear(
140 this, (uno_ReleaseFunc)cpp_release );
141}
142//__________________________________________________________________________________________________
143inline bool Any::isExtractableTo( const Type & rType ) const SAL_THROW(())
144{
145 return ::uno_type_isAssignableFromData(
146 rType.getTypeLibType(), pData, pType,
147 (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
148}
149
150//______________________________________________________________________________
151template <typename T>
152inline bool Any::has() const
153{
154 Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(0));
155 return ::uno_type_isAssignableFromData(
156 rType.getTypeLibType(), pData, pType,
157 (uno_QueryInterfaceFunc) cpp_queryInterface,
158 (uno_ReleaseFunc) cpp_release );
159}
160
161// not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
162template <>
163bool Any::has<sal_uInt16>() const;
164
165//__________________________________________________________________________________________________
166inline bool Any::operator == ( const Any & rAny ) const SAL_THROW(())
167{
168 return ::uno_type_equalData(
169 pData, pType, rAny.pData, rAny.pType,
170 (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
171}
172//__________________________________________________________________________________________________
173inline bool Any::operator != ( const Any & rAny ) const SAL_THROW(())
174{
175 return (! ::uno_type_equalData(
176 pData, pType, rAny.pData, rAny.pType,
177 (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release ));
178}
179
180//__________________________________________________________________________________________________
181template< class C >
182inline Any SAL_CALL makeAny( const C & value ) SAL_THROW(())
183{
184 return Any( &value, ::cppu::getTypeFavourUnsigned(&value) );
185}
186
187// additionally specialized for C++ bool
188//______________________________________________________________________________
189template<>
190inline Any SAL_CALL makeAny( bool const & value ) SAL_THROW(())
191{
192 const sal_Bool b = value;
193 return Any( &b, ::getCppuBooleanType() );
194}
195
196//__________________________________________________________________________________________________
197#ifdef RTL_FAST_STRING
198template< class C1, class C2 >
199inline Any SAL_CALL makeAny( const rtl::OUStringConcat< C1, C2 >& value ) SAL_THROW(())
200{
201 const rtl::OUString str( value );
202 return Any( &str, ::cppu::getTypeFavourUnsigned(&str) );
203}
204#endif
205//__________________________________________________________________________________________________
206template< class C >
207inline void SAL_CALL operator <<= ( Any & rAny, const C & value ) SAL_THROW(())
208{
209 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
210 ::uno_type_any_assign(
211 &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
212 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
213}
214
215// additionally for C++ bool:
216//______________________________________________________________________________
217inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
218 SAL_THROW(())
219{
220 sal_Bool b = value;
221 ::uno_type_any_assign(
222 &rAny, &b, ::getCppuBooleanType().getTypeLibType(),
223 (uno_AcquireFunc) cpp_acquire, (uno_ReleaseFunc) cpp_release );
224}
225
226//______________________________________________________________________________
227#ifdef RTL_FAST_STRING
228template< class C1, class C2 >
229inline void SAL_CALL operator <<= ( Any & rAny, const rtl::OUStringConcat< C1, C2 >& value )
230 SAL_THROW(())
231{
232 const rtl::OUString str( value );
233 const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
234 ::uno_type_any_assign(
235 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
236 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
237}
238#endif
239//__________________________________________________________________________________________________
240template< class C >
241inline bool SAL_CALL operator >>= ( const Any & rAny, C & value ) SAL_THROW(())
242{
243 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
244 return ::uno_type_assignData(
245 &value, rType.getTypeLibType(),
246 rAny.pData, rAny.pType,
247 (uno_QueryInterfaceFunc)cpp_queryInterface,
248 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
249}
250
251// bool
252//__________________________________________________________________________________________________
253inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value ) SAL_THROW(())
254{
255 if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
256 {
257 value = (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False);
258 return true;
259 }
260 return false;
261}
262//__________________________________________________________________________________________________
263inline bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value ) SAL_THROW(())
264{
265 return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
266 (value != sal_False) == (* reinterpret_cast< const sal_Bool * >( rAny.pData ) != sal_False));
267}
268
269//______________________________________________________________________________
270template<>
271inline bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
272 SAL_THROW(())
273{
274 if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
275 {
276 value = *reinterpret_cast< sal_Bool const * >(
277 rAny.pData ) != sal_False;
278 return true;
279 }
280 return false;
281}
282
283//______________________________________________________________________________
284template<>
285inline bool SAL_CALL operator == ( Any const & rAny, bool const & value )
286 SAL_THROW(())
287{
288 return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
289 (value ==
290 (*reinterpret_cast< sal_Bool const * >( rAny.pData )
291 != sal_False)));
292}
293
294// byte
295//__________________________________________________________________________________________________
296inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value ) SAL_THROW(())
297{
298 if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
299 {
300 value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
301 return true;
302 }
303 return false;
304}
305// short
306//__________________________________________________________________________________________________
307inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value ) SAL_THROW(())
308{
309 switch (rAny.pType->eTypeClass)
310 {
311 case typelib_TypeClass_BYTE:
312 value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
313 return true;
314 case typelib_TypeClass_SHORT:
315 case typelib_TypeClass_UNSIGNED_SHORT:
316 value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
317 return true;
318 default:
319 return false;
320 }
321}
322//__________________________________________________________________________________________________
323inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value ) SAL_THROW(())
324{
325 switch (rAny.pType->eTypeClass)
326 {
327 case typelib_TypeClass_BYTE:
328 value = (sal_uInt16)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
329 return true;
330 case typelib_TypeClass_SHORT:
331 case typelib_TypeClass_UNSIGNED_SHORT:
332 value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
333 return true;
334 default:
335 return false;
336 }
337}
338// long
339//__________________________________________________________________________________________________
340inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value ) SAL_THROW(())
341{
342 switch (rAny.pType->eTypeClass)
343 {
344 case typelib_TypeClass_BYTE:
345 value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
346 return true;
347 case typelib_TypeClass_SHORT:
348 value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
349 return true;
350 case typelib_TypeClass_UNSIGNED_SHORT:
351 value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
352 return true;
353 case typelib_TypeClass_LONG:
354 case typelib_TypeClass_UNSIGNED_LONG:
355 value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
356 return true;
357 default:
358 return false;
359 }
360}
361//__________________________________________________________________________________________________
362inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value ) SAL_THROW(())
363{
364 switch (rAny.pType->eTypeClass)
365 {
366 case typelib_TypeClass_BYTE:
367 value = (sal_uInt32)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
368 return true;
369 case typelib_TypeClass_SHORT:
370 value = (sal_uInt32)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
371 return true;
372 case typelib_TypeClass_UNSIGNED_SHORT:
373 value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
374 return true;
375 case typelib_TypeClass_LONG:
376 case typelib_TypeClass_UNSIGNED_LONG:
377 value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
378 return true;
379 default:
380 return false;
381 }
382}
383// hyper
384//__________________________________________________________________________________________________
385inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value ) SAL_THROW(())
386{
387 switch (rAny.pType->eTypeClass)
388 {
389 case typelib_TypeClass_BYTE:
390 value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
391 return true;
392 case typelib_TypeClass_SHORT:
393 value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
394 return true;
395 case typelib_TypeClass_UNSIGNED_SHORT:
396 value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
397 return true;
398 case typelib_TypeClass_LONG:
399 value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
400 return true;
401 case typelib_TypeClass_UNSIGNED_LONG:
402 value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
403 return true;
404 case typelib_TypeClass_HYPER:
405 case typelib_TypeClass_UNSIGNED_HYPER:
406 value = * reinterpret_cast< const sal_Int64 * >( rAny.pData );
407 return true;
408 default:
409 return false;
410 }
411}
412//__________________________________________________________________________________________________
413inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value ) SAL_THROW(())
414{
415 switch (rAny.pType->eTypeClass)
416 {
417 case typelib_TypeClass_BYTE:
418 value = (sal_uInt64)( * reinterpret_cast< const sal_Int8 * >( rAny.pData ) );
419 return true;
420 case typelib_TypeClass_SHORT:
421 value = (sal_uInt64)( * reinterpret_cast< const sal_Int16 * >( rAny.pData ) );
422 return true;
423 case typelib_TypeClass_UNSIGNED_SHORT:
424 value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
425 return true;
426 case typelib_TypeClass_LONG:
427 value = (sal_uInt64)( * reinterpret_cast< const sal_Int32 * >( rAny.pData ) );
428 return true;
429 case typelib_TypeClass_UNSIGNED_LONG:
430 value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
431 return true;
432 case typelib_TypeClass_HYPER:
433 case typelib_TypeClass_UNSIGNED_HYPER:
434 value = * reinterpret_cast< const sal_uInt64 * >( rAny.pData );
435 return true;
436 default:
437 return false;
438 }
439}
440// float
441//__________________________________________________________________________________________________
442inline bool SAL_CALL operator >>= ( const Any & rAny, float & value ) SAL_THROW(())
443{
444 switch (rAny.pType->eTypeClass)
445 {
446 case typelib_TypeClass_BYTE:
447 value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
448 return true;
449 case typelib_TypeClass_SHORT:
450 value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
451 return true;
452 case typelib_TypeClass_UNSIGNED_SHORT:
453 value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
454 return true;
455 case typelib_TypeClass_FLOAT:
456 value = * reinterpret_cast< const float * >( rAny.pData );
457 return true;
458 default:
459 return false;
460 }
461}
462// double
463//__________________________________________________________________________________________________
464inline bool SAL_CALL operator >>= ( const Any & rAny, double & value ) SAL_THROW(())
465{
466 switch (rAny.pType->eTypeClass)
467 {
468 case typelib_TypeClass_BYTE:
469 value = * reinterpret_cast< const sal_Int8 * >( rAny.pData );
470 return true;
471 case typelib_TypeClass_SHORT:
472 value = * reinterpret_cast< const sal_Int16 * >( rAny.pData );
473 return true;
474 case typelib_TypeClass_UNSIGNED_SHORT:
475 value = * reinterpret_cast< const sal_uInt16 * >( rAny.pData );
476 return true;
477 case typelib_TypeClass_LONG:
478 value = * reinterpret_cast< const sal_Int32 * >( rAny.pData );
479 return true;
480 case typelib_TypeClass_UNSIGNED_LONG:
481 value = * reinterpret_cast< const sal_uInt32 * >( rAny.pData );
482 return true;
483 case typelib_TypeClass_FLOAT:
484 value = * reinterpret_cast< const float * >( rAny.pData );
485 return true;
486 case typelib_TypeClass_DOUBLE:
487 value = * reinterpret_cast< const double * >( rAny.pData );
488 return true;
489 default:
490 return false;
491 }
492}
493// string
494//__________________________________________________________________________________________________
495inline bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value ) SAL_THROW(())
496{
497 if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
498 {
499 value = * reinterpret_cast< const ::rtl::OUString * >( rAny.pData );
500 return true;
501 }
502 return false;
503}
504//__________________________________________________________________________________________________
505inline bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value ) SAL_THROW(())
506{
507 return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
508 value.equals( * reinterpret_cast< const ::rtl::OUString * >( rAny.pData ) ));
509}
510// type
511//__________________________________________________________________________________________________
512inline bool SAL_CALL operator >>= ( const Any & rAny, Type & value ) SAL_THROW(())
513{
514 if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
515 {
516 value = * reinterpret_cast< const Type * >( rAny.pData );
517 return true;
518 }
519 return false;
520}
521//__________________________________________________________________________________________________
522inline bool SAL_CALL operator == ( const Any & rAny, const Type & value ) SAL_THROW(())
523{
524 return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
525 value.equals( * reinterpret_cast< const Type * >( rAny.pData ) ));
526}
527// any
528//__________________________________________________________________________________________________
529inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value ) SAL_THROW(())
530{
531 if (&rAny != &value)
532 {
533 ::uno_type_any_assign(
534 &value, rAny.pData, rAny.pType,
535 (uno_AcquireFunc)cpp_acquire, (uno_ReleaseFunc)cpp_release );
536 }
537 return true;
538}
539// interface
540//__________________________________________________________________________________________________
541inline bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value ) SAL_THROW(())
542{
543 if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
544 {
545 return reinterpret_cast< const BaseReference * >( rAny.pData )->operator == ( value );
546 }
547 return false;
548}
549
550// operator to compare to an any.
551//__________________________________________________________________________________________________
552template< class C >
553inline bool SAL_CALL operator == ( const Any & rAny, const C & value ) SAL_THROW(())
554{
555 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
556 return ::uno_type_equalData(
557 rAny.pData, rAny.pType,
558 const_cast< C * >( &value ), rType.getTypeLibType(),
559 (uno_QueryInterfaceFunc)cpp_queryInterface, (uno_ReleaseFunc)cpp_release );
560}
561// operator to compare to an any. may use specialized operators ==.
562//__________________________________________________________________________________________________
563template< class C >
564inline bool SAL_CALL operator != ( const Any & rAny, const C & value ) SAL_THROW(())
565{
566 return (! operator == ( rAny, value ));
567}
568
569extern "C" rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
570 uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
571 SAL_THROW_EXTERN_C();
572
573//______________________________________________________________________________
574template <typename T>
575T Any::get() const
576{
577 T value = T();
578 if (! (*this >>= value)) {
579 throw RuntimeException(
580 ::rtl::OUString(
581 cppu_Any_extraction_failure_msg(
582 this,
583 ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
584 SAL_NO_ACQUIRE ),
585 Reference<XInterface>() );
586 }
587 return value;
588}
589// not impl: forbid use with ambiguous type (sal_Unicode, sal_uInt16)
590template <>
591sal_uInt16 Any::get<sal_uInt16>() const;
592
593/**
594 Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO
595 macros, for example).
596
597 @since LibreOffice 4.2
598*/
599template<typename charT, typename traits>
600inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o, Any const &any) {
601 o << "<Any: (" << any.getValueTypeName() << ')';
602 switch(any.pType->eTypeClass) {
603 case typelib_TypeClass_VOID:
604 break;
605 case typelib_TypeClass_BOOLEAN:
606 o << ' ' << any.get<bool>();
607 break;
608 case typelib_TypeClass_BYTE:
609 case typelib_TypeClass_SHORT:
610 case typelib_TypeClass_LONG:
611 case typelib_TypeClass_HYPER:
612 o << ' ' << any.get<sal_Int64>();
613 break;
614 case typelib_TypeClass_UNSIGNED_SHORT:
615 case typelib_TypeClass_UNSIGNED_LONG:
616 case typelib_TypeClass_UNSIGNED_HYPER:
617 o << ' ' << any.get<sal_uInt64>();
618 break;
619 case typelib_TypeClass_FLOAT:
620 case typelib_TypeClass_DOUBLE:
621 o << ' ' << any.get<double>();
622 break;
623 case typelib_TypeClass_CHAR: {
624 std::ios_base::fmtflags flgs = o.setf(
625 std::ios_base::hex, std::ios_base::basefield);
626 charT fill = o.fill('0');
627 o << " U+" << std::setw(4)
628 << *static_cast<sal_Unicode const *>(any.getValue());
629 o.setf(flgs);
630 o.fill(fill);
631 break;
632 }
633 case typelib_TypeClass_STRING:
634 o << ' ' << any.get<rtl::OUString>();
635 break;
636 case typelib_TypeClass_TYPE:
637 o << ' ' << any.get<css::uno::Type>().getTypeName();
638 break;
639 case typelib_TypeClass_SEQUENCE:
640 o << " len "
641 << ((*static_cast<uno_Sequence * const *>(any.getValue()))->
642 nElements);
643 break;
644 case typelib_TypeClass_ENUM:
645 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
646 break;
647 case typelib_TypeClass_STRUCT:
648 case typelib_TypeClass_EXCEPTION:
649 o << ' ' << any.getValue();
650 break;
651 case typelib_TypeClass_INTERFACE:
652 o << ' ' << *static_cast<void * const *>(any.getValue());
653 break;
654 default:
655 assert(false); // this cannot happen
656 break;
657 }
658 o << '>';
659 return o;
660}
661
662}
663}
664}
665}
666
667#endif
668
669/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
670