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