LibreOffice: com/sun/star/uno/Any.hxx Source File

LibreOffice LibreOffice 24.2 SDK C/C++ API Reference

Loading...
Searching...
No Matches
Any.hxx
Go to the documentation of this file.
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
20/*
21 * This file is part of LibreOffice published API.
22 */
23#ifndef INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
24#define INCLUDED_COM_SUN_STAR_UNO_ANY_HXX
25
26#include "sal/config.h"
27
28#include <algorithm>
29#include <cassert>
30#include <cstddef>
31#include <iomanip>
32#include <ostream>
33#include <utility>
34
35#include "com/sun/star/uno/Any.h"
36#include "uno/data.h"
37#include "uno/sequence2.h"
38#include "com/sun/star/uno/Type.hxx"
39#include "com/sun/star/uno/Reference.h"
40#include "com/sun/star/uno/genfunc.hxx"
41#include "com/sun/star/uno/RuntimeException.hpp"
42#include "cppu/cppudllapi.h"
43#include "cppu/unotype.hxx"
44
45 extern "C" CPPU_DLLPUBLIC rtl_uString * SAL_CALL cppu_Any_extraction_failure_msg(
46 uno_Any const * pAny, typelib_TypeDescriptionReference * pType )
47 SAL_THROW_EXTERN_C();
48
49namespace com
50{
51namespace sun
52{
53namespace star
54{
55namespace uno
56{
57
58
59 inline Any::Any()
60{
61 ::uno_any_construct( this, NULL, NULL, cpp_acquire );
62}
63
64
65template <typename T>
66 inline Any::Any( T const & value )
67{
68 ::uno_type_any_construct(
69 this, const_cast<T *>(&value),
70 ::cppu::getTypeFavourUnsigned(&value).getTypeLibType(),
71 cpp_acquire );
72}
73
74 inline Any::Any( bool value )
75{
76 sal_Bool b = value;
77 ::uno_type_any_construct(
78 this, &b, cppu::UnoType<bool>::get().getTypeLibType(),
79 cpp_acquire );
80}
81
82#if defined LIBO_INTERNAL_ONLY
83template<typename T1, typename T2>
84 Any::Any(rtl::OUStringConcat<T1, T2> && value):
85 Any(rtl::OUString(std::move(value)))
86{}
87template<std::size_t nBufSize>
88 Any::Any(rtl::StringNumber<sal_Unicode, nBufSize> && value): Any(rtl::OUString(std::move(value))) {}
89template <std::size_t N>
90 Any::Any(const rtl::OUStringLiteral<N>& value): Any(rtl::OUString(value)) {}
91#endif
92
93 inline Any::Any( const Any & rAny )
94{
95 ::uno_type_any_construct( this, rAny.pData, rAny.pType, cpp_acquire );
96}
97
98 inline Any::Any( const void * pData_, const Type & rType )
99{
100 ::uno_type_any_construct(
101 this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
102 cpp_acquire );
103}
104
105 inline Any::Any( const void * pData_, typelib_TypeDescription * pTypeDescr )
106{
107 ::uno_any_construct(
108 this, const_cast< void * >( pData_ ), pTypeDescr, cpp_acquire );
109}
110
111 inline Any::Any( const void * pData_, typelib_TypeDescriptionReference * pType_ )
112{
113 ::uno_type_any_construct(
114 this, const_cast< void * >( pData_ ), pType_, cpp_acquire );
115}
116
117 inline Any::~Any()
118{
119 ::uno_any_destruct(
120 this, cpp_release );
121}
122
123 inline Any & Any::operator = ( const Any & rAny )
124{
125 if (this != &rAny)
126 {
127 ::uno_type_any_assign(
128 this, rAny.pData, rAny.pType,
129 cpp_acquire, cpp_release );
130 }
131 return *this;
132}
133
134#if defined LIBO_INTERNAL_ONLY
135
136 Any::Any(Any && other) noexcept {
137 uno_any_construct(this, nullptr, nullptr, &cpp_acquire);
138 std::swap(other.pType, pType);
139 std::swap(other.pData, pData);
140 std::swap(other.pReserved, pReserved);
141 if (pData == &other.pReserved) {
142 pData = &pReserved;
143 }
144 // This leaves other.pData (where "other" is now VOID) dangling to somewhere (cf.
145 // CONSTRUCT_EMPTY_ANY, cppu/source/uno/prim.hxx), but what's relevant is
146 // only that it isn't a nullptr (as e.g. >>= -> uno_type_assignData ->
147 // _assignData takes a null pSource to mean "construct a default value").
148}
149
150Any & Any::operator =(Any && other) noexcept {
151 std::swap(other.pType, pType);
152 std::swap(other.pData, pData);
153 std::swap(other.pReserved, pReserved);
154 if (pData == &other.pReserved) {
155 pData = &pReserved;
156 }
157 if (other.pData == &pReserved) {
158 other.pData = &other.pReserved;
159 }
160 return *this;
161}
162
163#endif
164
165inline ::rtl::OUString Any::getValueTypeName() const
166{
167 return ::rtl::OUString( pType->pTypeName );
168}
169
170 inline void Any::setValue( const void * pData_, const Type & rType )
171{
172 ::uno_type_any_assign(
173 this, const_cast< void * >( pData_ ), rType.getTypeLibType(),
174 cpp_acquire, cpp_release );
175}
176
177 inline void Any::setValue( const void * pData_, typelib_TypeDescriptionReference * pType_ )
178{
179 ::uno_type_any_assign(
180 this, const_cast< void * >( pData_ ), pType_,
181 cpp_acquire, cpp_release );
182}
183
184 inline void Any::setValue( const void * pData_, typelib_TypeDescription * pTypeDescr )
185{
186 ::uno_any_assign(
187 this, const_cast< void * >( pData_ ), pTypeDescr,
188 cpp_acquire, cpp_release );
189}
190
191 inline void Any::clear()
192{
193 ::uno_any_clear(
194 this, cpp_release );
195}
196
197 inline bool Any::isExtractableTo( const Type & rType ) const
198{
199 return ::uno_type_isAssignableFromData(
200 rType.getTypeLibType(), pData, pType,
201 cpp_queryInterface, cpp_release );
202}
203
204
205template <typename T>
206 inline bool Any::has() const
207{
208 Type const & rType = ::cppu::getTypeFavourUnsigned(static_cast< T * >(NULL));
209 return ::uno_type_isAssignableFromData(
210 rType.getTypeLibType(), pData, pType,
211 cpp_queryInterface,
212 cpp_release );
213}
214
215#if defined LIBO_INTERNAL_ONLY
216template<> bool Any::has<Any>() const = delete;
217#endif
218
219 inline bool Any::operator == ( const Any & rAny ) const
220{
221 return ::uno_type_equalData(
222 pData, pType, rAny.pData, rAny.pType,
223 cpp_queryInterface, cpp_release );
224}
225
226 inline bool Any::operator != ( const Any & rAny ) const
227{
228 return (! ::uno_type_equalData(
229 pData, pType, rAny.pData, rAny.pType,
230 cpp_queryInterface, cpp_release ));
231}
232
233
234#if !defined LIBO_INTERNAL_ONLY
235template< class C >
236 inline Any SAL_CALL makeAny( const C & value )
237{
238 return Any(value);
239}
240
241 template<> Any makeAny(sal_uInt16 const & value)
242{ return Any(&value, cppu::UnoType<cppu::UnoUnsignedShortType>::get()); }
243#endif
244
245 template<typename T> Any toAny(T const & value) {
246 return Any(value);
247}
248
249 template<> Any toAny(Any const & value) { return value; }
250
251#if defined LIBO_INTERNAL_ONLY
252
253inline Any toAny(Any&& value) { return std::move(value); }
254
255template<typename T1, typename T2>
256Any toAny(rtl::OUStringConcat<T1, T2> && value)
257{ return Any(std::move(value)); }
258
259template<std::size_t nBufSize>
260Any toAny(rtl::StringNumber<sal_Unicode, nBufSize> && value)
261{ return Any(std::move(value)); }
262
263template<typename T> bool fromAny(Any const & any, T * value) {
264 assert(value != nullptr);
265 return any >>= *value;
266}
267
268template<> bool fromAny(Any const & any, Any * value) {
269 assert(value != nullptr);
270 *value = any;
271 return true;
272}
273
274#endif
275
276template< class C >
277 inline void SAL_CALL operator <<= ( Any & rAny, const C & value )
278{
279 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
280 ::uno_type_any_assign(
281 &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
282 cpp_acquire, cpp_release );
283}
284
285// additionally for C++ bool:
286
287template<>
288 inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
289{
290 sal_Bool b = value;
291 ::uno_type_any_assign(
292 &rAny, &b, cppu::UnoType<bool>::get().getTypeLibType(),
293 cpp_acquire, cpp_release );
294}
295
296
297#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
298template< class C1, class C2 >
299inline void operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value )
300{
301 const rtl::OUString str( std::move(value) );
302 const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
303 ::uno_type_any_assign(
304 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
305 cpp_acquire, cpp_release );
306}
307template<typename T1, typename T2>
308void operator <<=(Any &, rtl::OUStringConcat<T1, T2> const &) = delete;
309template< std::size_t nBufSize >
310inline void operator <<= ( Any & rAny, rtl::StringNumber< sal_Unicode, nBufSize >&& value )
311{
312 const rtl::OUString str( std::move(value) );
313 const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
314 ::uno_type_any_assign(
315 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
316 cpp_acquire, cpp_release );
317}
318template<std::size_t nBufSize>
319void operator <<=(Any &, rtl::StringNumber<sal_Unicode, nBufSize> const &) = delete;
320#endif
321
322#if defined LIBO_INTERNAL_ONLY
323template<> void SAL_CALL operator <<=(Any &, Any const &) = delete;
324#endif
325
326template< class C >
327 inline bool SAL_CALL operator >>= ( const Any & rAny, C & value )
328{
329 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
330 return ::uno_type_assignData(
331 &value, rType.getTypeLibType(),
332 rAny.pData, rAny.pType,
333 cpp_queryInterface,
334 cpp_acquire, cpp_release );
335}
336
337// bool
338
339template<>
340 inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value )
341{
342 if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
343 {
344 value = bool(* static_cast< const sal_Bool * >( rAny.pData ));
345 return true;
346 }
347 return false;
348}
349
350template<>
351 inline bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value )
352{
353 return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
354 bool(value) == bool(* static_cast< const sal_Bool * >( rAny.pData )));
355}
356
357
358template<>
359 inline bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
360{
361 if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
362 {
363 value = *static_cast< sal_Bool const * >( rAny.pData );
364 return true;
365 }
366 return false;
367}
368
369
370template<>
371 inline bool SAL_CALL operator == ( Any const & rAny, bool const & value )
372{
373 return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
374 (value ==
375 bool(*static_cast< sal_Bool const * >( rAny.pData ))));
376}
377
378// byte
379
380template<>
381 inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value )
382{
383 if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
384 {
385 value = * static_cast< const sal_Int8 * >( rAny.pData );
386 return true;
387 }
388 return false;
389}
390// short
391
392template<>
393 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value )
394{
395 switch (rAny.pType->eTypeClass)
396 {
397 case typelib_TypeClass_BYTE:
398 value = * static_cast< const sal_Int8 * >( rAny.pData );
399 return true;
400 case typelib_TypeClass_SHORT:
401 case typelib_TypeClass_UNSIGNED_SHORT:
402 value = * static_cast< const sal_Int16 * >( rAny.pData );
403 return true;
404 default:
405 return false;
406 }
407}
408
409template<>
410 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value )
411{
412 switch (rAny.pType->eTypeClass)
413 {
414 case typelib_TypeClass_BYTE:
415 value = static_cast<sal_uInt16>( * static_cast< const sal_Int8 * >( rAny.pData ) );
416 return true;
417 case typelib_TypeClass_SHORT:
418 case typelib_TypeClass_UNSIGNED_SHORT:
419 value = * static_cast< const sal_uInt16 * >( rAny.pData );
420 return true;
421 default:
422 return false;
423 }
424}
425// long
426
427template<>
428 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value )
429{
430 switch (rAny.pType->eTypeClass)
431 {
432 case typelib_TypeClass_BYTE:
433 value = * static_cast< const sal_Int8 * >( rAny.pData );
434 return true;
435 case typelib_TypeClass_SHORT:
436 value = * static_cast< const sal_Int16 * >( rAny.pData );
437 return true;
438 case typelib_TypeClass_UNSIGNED_SHORT:
439 value = * static_cast< const sal_uInt16 * >( rAny.pData );
440 return true;
441 case typelib_TypeClass_LONG:
442 case typelib_TypeClass_UNSIGNED_LONG:
443 value = * static_cast< const sal_Int32 * >( rAny.pData );
444 return true;
445 default:
446 return false;
447 }
448}
449
450template<>
451 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value )
452{
453 switch (rAny.pType->eTypeClass)
454 {
455 case typelib_TypeClass_BYTE:
456 value = static_cast<sal_uInt32>( * static_cast< const sal_Int8 * >( rAny.pData ) );
457 return true;
458 case typelib_TypeClass_SHORT:
459 value = static_cast<sal_uInt32>( * static_cast< const sal_Int16 * >( rAny.pData ) );
460 return true;
461 case typelib_TypeClass_UNSIGNED_SHORT:
462 value = * static_cast< const sal_uInt16 * >( rAny.pData );
463 return true;
464 case typelib_TypeClass_LONG:
465 case typelib_TypeClass_UNSIGNED_LONG:
466 value = * static_cast< const sal_uInt32 * >( rAny.pData );
467 return true;
468 default:
469 return false;
470 }
471}
472// hyper
473
474template<>
475 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value )
476{
477 switch (rAny.pType->eTypeClass)
478 {
479 case typelib_TypeClass_BYTE:
480 value = * static_cast< const sal_Int8 * >( rAny.pData );
481 return true;
482 case typelib_TypeClass_SHORT:
483 value = * static_cast< const sal_Int16 * >( rAny.pData );
484 return true;
485 case typelib_TypeClass_UNSIGNED_SHORT:
486 value = * static_cast< const sal_uInt16 * >( rAny.pData );
487 return true;
488 case typelib_TypeClass_LONG:
489 value = * static_cast< const sal_Int32 * >( rAny.pData );
490 return true;
491 case typelib_TypeClass_UNSIGNED_LONG:
492 value = * static_cast< const sal_uInt32 * >( rAny.pData );
493 return true;
494 case typelib_TypeClass_HYPER:
495 case typelib_TypeClass_UNSIGNED_HYPER:
496 value = * static_cast< const sal_Int64 * >( rAny.pData );
497 return true;
498 default:
499 return false;
500 }
501}
502
503template<>
504 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value )
505{
506 switch (rAny.pType->eTypeClass)
507 {
508 case typelib_TypeClass_BYTE:
509 value = static_cast<sal_uInt64>( * static_cast< const sal_Int8 * >( rAny.pData ) );
510 return true;
511 case typelib_TypeClass_SHORT:
512 value = static_cast<sal_uInt64>( * static_cast< const sal_Int16 * >( rAny.pData ) );
513 return true;
514 case typelib_TypeClass_UNSIGNED_SHORT:
515 value = * static_cast< const sal_uInt16 * >( rAny.pData );
516 return true;
517 case typelib_TypeClass_LONG:
518 value = static_cast<sal_uInt64>( * static_cast< const sal_Int32 * >( rAny.pData ) );
519 return true;
520 case typelib_TypeClass_UNSIGNED_LONG:
521 value = * static_cast< const sal_uInt32 * >( rAny.pData );
522 return true;
523 case typelib_TypeClass_HYPER:
524 case typelib_TypeClass_UNSIGNED_HYPER:
525 value = * static_cast< const sal_uInt64 * >( rAny.pData );
526 return true;
527 default:
528 return false;
529 }
530}
531// float
532
533template<>
534 inline bool SAL_CALL operator >>= ( const Any & rAny, float & value )
535{
536 switch (rAny.pType->eTypeClass)
537 {
538 case typelib_TypeClass_BYTE:
539 value = * static_cast< const sal_Int8 * >( rAny.pData );
540 return true;
541 case typelib_TypeClass_SHORT:
542 value = * static_cast< const sal_Int16 * >( rAny.pData );
543 return true;
544 case typelib_TypeClass_UNSIGNED_SHORT:
545 value = * static_cast< const sal_uInt16 * >( rAny.pData );
546 return true;
547 case typelib_TypeClass_FLOAT:
548 value = * static_cast< const float * >( rAny.pData );
549 return true;
550 default:
551 return false;
552 }
553}
554// double
555
556template<>
557 inline bool SAL_CALL operator >>= ( const Any & rAny, double & value )
558{
559 switch (rAny.pType->eTypeClass)
560 {
561 case typelib_TypeClass_BYTE:
562 value = * static_cast< const sal_Int8 * >( rAny.pData );
563 return true;
564 case typelib_TypeClass_SHORT:
565 value = * static_cast< const sal_Int16 * >( rAny.pData );
566 return true;
567 case typelib_TypeClass_UNSIGNED_SHORT:
568 value = * static_cast< const sal_uInt16 * >( rAny.pData );
569 return true;
570 case typelib_TypeClass_LONG:
571 value = * static_cast< const sal_Int32 * >( rAny.pData );
572 return true;
573 case typelib_TypeClass_UNSIGNED_LONG:
574 value = * static_cast< const sal_uInt32 * >( rAny.pData );
575 return true;
576 case typelib_TypeClass_FLOAT:
577 value = * static_cast< const float * >( rAny.pData );
578 return true;
579 case typelib_TypeClass_DOUBLE:
580 value = * static_cast< const double * >( rAny.pData );
581 return true;
582 default:
583 return false;
584 }
585}
586// string
587
588template<>
589 inline bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value )
590{
591 if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
592 {
593 value = * static_cast< const ::rtl::OUString * >( rAny.pData );
594 return true;
595 }
596 return false;
597}
598
599template<>
600 inline bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value )
601{
602 return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
603 value == * static_cast< const ::rtl::OUString * >( rAny.pData ) );
604}
605
606#if defined LIBO_INTERNAL_ONLY
607template<std::size_t N>
608inline bool SAL_CALL operator == (const Any& rAny, const rtl::OUStringLiteral<N>& value)
609{
610 return operator ==(rAny, rtl::OUString(value));
611}
612#endif
613// type
614
615template<>
616 inline bool SAL_CALL operator >>= ( const Any & rAny, Type & value )
617{
618 if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
619 {
620 value = * static_cast< const Type * >( rAny.pData );
621 return true;
622 }
623 return false;
624}
625
626template<>
627 inline bool SAL_CALL operator == ( const Any & rAny, const Type & value )
628{
629 return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
630 value.equals( * static_cast< const Type * >( rAny.pData ) ));
631}
632// any
633
634#if defined LIBO_INTERNAL_ONLY
635template<> bool SAL_CALL operator >>=(Any const &, Any &) = delete;
636#else
637template<>
638 inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value )
639{
640 if (&rAny != &value)
641 {
642 ::uno_type_any_assign(
643 &value, rAny.pData, rAny.pType,
644 cpp_acquire, cpp_release );
645 }
646 return true;
647}
648#endif
649// interface
650
651template<>
652 inline bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value )
653{
654 if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
655 {
656 return static_cast< const BaseReference * >( rAny.pData )->operator == ( value );
657 }
658 return false;
659}
660
661// operator to compare to an any.
662
663template< class C >
664 inline bool SAL_CALL operator == ( const Any & rAny, const C & value )
665{
666 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
667 return ::uno_type_equalData(
668 rAny.pData, rAny.pType,
669 const_cast< C * >( &value ), rType.getTypeLibType(),
670 cpp_queryInterface, cpp_release );
671}
672// operator to compare to an any. may use specialized operators ==.
673
674template< class C >
675 inline bool SAL_CALL operator != ( const Any & rAny, const C & value )
676{
677 return (! operator == ( rAny, value ));
678}
679
680template <typename T>
681 T Any::get() const
682{
683 T value = T();
684 if (! (*this >>= value)) {
685 throw RuntimeException(
686 ::rtl::OUString(
687 cppu_Any_extraction_failure_msg(
688 this,
689 ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
690 SAL_NO_ACQUIRE ) );
691 }
692 return value;
693}
694
695#if defined LIBO_INTERNAL_ONLY
696template<> Any Any::get() const = delete;
697#endif
698
705template<typename charT, typename traits>
706inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o, Any const &any) {
707 o << "<Any: (" << any.getValueTypeName() << ')';
708 switch(any.pType->eTypeClass) {
709 case typelib_TypeClass_VOID:
710 break;
711 case typelib_TypeClass_BOOLEAN:
712 o << ' ' << any.get<bool>();
713 break;
714 case typelib_TypeClass_BYTE:
715 case typelib_TypeClass_SHORT:
716 case typelib_TypeClass_LONG:
717 case typelib_TypeClass_HYPER:
718 o << ' ' << any.get<sal_Int64>();
719 break;
720 case typelib_TypeClass_UNSIGNED_SHORT:
721 case typelib_TypeClass_UNSIGNED_LONG:
722 case typelib_TypeClass_UNSIGNED_HYPER:
723 o << ' ' << any.get<sal_uInt64>();
724 break;
725 case typelib_TypeClass_FLOAT:
726 case typelib_TypeClass_DOUBLE:
727 o << ' ' << any.get<double>();
728 break;
729 case typelib_TypeClass_CHAR: {
730 std::ios_base::fmtflags flgs = o.setf(
731 std::ios_base::hex, std::ios_base::basefield);
732 charT fill = o.fill('0');
733 o << " U+" << std::setw(4)
734 << unsigned(*static_cast<sal_Unicode const *>(any.getValue()));
735 o.setf(flgs);
736 o.fill(fill);
737 break;
738 }
739 case typelib_TypeClass_STRING:
740 o << ' ' << any.get<rtl::OUString>();
741 break;
742 case typelib_TypeClass_TYPE:
743 o << ' ' << any.get<css::uno::Type>().getTypeName();
744 break;
745 case typelib_TypeClass_SEQUENCE:
746 o << " len "
747 << ((*static_cast<uno_Sequence * const *>(any.getValue()))->
748 nElements);
749 break;
750 case typelib_TypeClass_ENUM:
751 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
752 break;
753 case typelib_TypeClass_STRUCT:
754 case typelib_TypeClass_EXCEPTION:
755 o << ' ' << any.getValue();
756 break;
757 case typelib_TypeClass_INTERFACE:
758 o << ' ' << *static_cast<void * const *>(any.getValue());
759 break;
760 default:
761 assert(false); // this cannot happen
762 break;
763 }
764 o << '>';
765 return o;
766}
767
768}
769}
770}
771}
772
773#endif
774
775/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SAL_NO_ACQUIRE
@ SAL_NO_ACQUIRE
definition of a no acquire enum for ctors
Definition types.h:356
sal_Bool
unsigned char sal_Bool
Definition types.h:38
SAL_THROW_EXTERN_C
#define SAL_THROW_EXTERN_C()
Nothrow specification for C functions.
Definition types.h:334
sal_Unicode
sal_uInt16 sal_Unicode
Definition types.h:123
sal_Int8
signed char sal_Int8
Definition types.h:43
config.h
typelib_TypeDescription
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescription typelib_TypeDescription
Full type description of a type.
typelib_TypeDescriptionReference
struct SAL_DLLPUBLIC_RTTI _typelib_TypeDescriptionReference typelib_TypeDescriptionReference
Holds a weak reference to a type description.
typelib_TypeClass_VOID
@ typelib_TypeClass_VOID
type class of void
Definition typeclass.h:32
typelib_TypeClass_UNSIGNED_SHORT
@ typelib_TypeClass_UNSIGNED_SHORT
type class of unsigned short
Definition typeclass.h:42
typelib_TypeClass_STRUCT
@ typelib_TypeClass_STRUCT
type class of struct
Definition typeclass.h:66
typelib_TypeClass_CHAR
@ typelib_TypeClass_CHAR
type class of char
Definition typeclass.h:34
typelib_TypeClass_HYPER
@ typelib_TypeClass_HYPER
type class of hyper
Definition typeclass.h:48
typelib_TypeClass_BYTE
@ typelib_TypeClass_BYTE
type class of byte
Definition typeclass.h:38
typelib_TypeClass_BOOLEAN
@ typelib_TypeClass_BOOLEAN
type class of boolean
Definition typeclass.h:36
typelib_TypeClass_INTERFACE
@ typelib_TypeClass_INTERFACE
type class of interface
Definition typeclass.h:82
typelib_TypeClass_STRING
@ typelib_TypeClass_STRING
type class of string
Definition typeclass.h:56
typelib_TypeClass_SHORT
@ typelib_TypeClass_SHORT
type class of short
Definition typeclass.h:40
typelib_TypeClass_FLOAT
@ typelib_TypeClass_FLOAT
type class of float
Definition typeclass.h:52
typelib_TypeClass_DOUBLE
@ typelib_TypeClass_DOUBLE
type class of double
Definition typeclass.h:54
typelib_TypeClass_TYPE
@ typelib_TypeClass_TYPE
type class of type
Definition typeclass.h:58
typelib_TypeClass_UNSIGNED_HYPER
@ typelib_TypeClass_UNSIGNED_HYPER
type class of unsigned hyper
Definition typeclass.h:50
typelib_TypeClass_SEQUENCE
@ typelib_TypeClass_SEQUENCE
type class of sequence
Definition typeclass.h:75
typelib_TypeClass_LONG
@ typelib_TypeClass_LONG
type class of long
Definition typeclass.h:44
typelib_TypeClass_ENUM
@ typelib_TypeClass_ENUM
type class of enum
Definition typeclass.h:62
typelib_TypeClass_UNSIGNED_LONG
@ typelib_TypeClass_UNSIGNED_LONG
type class of unsigned long
Definition typeclass.h:46
typelib_TypeClass_EXCEPTION
@ typelib_TypeClass_EXCEPTION
type class of exception
Definition typeclass.h:73
uno_any_destruct
CPPU_DLLPUBLIC void uno_any_destruct(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Destructs an any.
uno_any_construct
CPPU_DLLPUBLIC void uno_any_construct(uno_Any *pDest, void *pSource, struct _typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
Constructs an any with a given value.
uno_type_any_construct
CPPU_DLLPUBLIC void uno_type_any_construct(uno_Any *pDest, void *pSource, struct _typelib_TypeDescriptionReference *pType, uno_AcquireFunc acquire) SAL_THROW_EXTERN_C()
Constructs an any with a given value.
uno_Any
struct SAL_DLLPUBLIC_RTTI _uno_Any uno_Any
This is the binary specification of a UNO any.
uno_type_any_assign
CPPU_DLLPUBLIC void uno_type_any_assign(uno_Any *pDest, void *pSource, struct _typelib_TypeDescriptionReference *pType, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Assign an any with a given value.
uno_any_clear
CPPU_DLLPUBLIC void uno_any_clear(uno_Any *pValue, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Sets value to void.
uno_any_assign
CPPU_DLLPUBLIC void uno_any_assign(uno_Any *pDest, void *pSource, struct _typelib_TypeDescription *pTypeDescr, uno_AcquireFunc acquire, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Assign an any with a given value.
data.h
uno_type_equalData
CPPU_DLLPUBLIC sal_Bool uno_type_equalData(void *pVal1, struct _typelib_TypeDescriptionReference *pVal1Type, void *pVal2, struct _typelib_TypeDescriptionReference *pVal2Type, uno_QueryInterfaceFunc queryInterface, uno_ReleaseFunc release) SAL_THROW_EXTERN_C()
Tests if two values are equal.
sequence2.h
cppudllapi.h
CPPU_DLLPUBLIC
#define CPPU_DLLPUBLIC
Definition cppudllapi.h:13
unotype.hxx
Any.h
cppu_Any_extraction_failure_msg
CPPU_DLLPUBLIC rtl_uString * cppu_Any_extraction_failure_msg(uno_Any const *pAny, typelib_TypeDescriptionReference *pType) SAL_THROW_EXTERN_C()
genfunc.hxx
Reference.h
Type.hxx
com
Definition types.h:359
rtl
Definition bootstrap.hxx:34
com::sun::star::uno::operator==
bool operator==(const Any &rAny, const C &value)
Template equality operator: compares set value of left side any to right side value.
Definition Any.hxx:664
com::sun::star::uno::operator<<
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &o, Any const &any)
Support for Any in std::ostream (and thus in CPPUNIT_ASSERT or SAL_INFO macros, for example).
Definition Any.hxx:706
com::sun::star::uno::makeAny
Any makeAny(const C &value)
Template function to generically construct an any from a C++ value.
Definition Any.hxx:236
com::sun::star::uno::operator!=
bool operator!=(const Any &rAny, const C &value)
Template inequality operator: compares set value of left side any to right side value.
Definition Any.hxx:675
com::sun::star::uno::operator>>=
bool operator>>=(const Any &rAny, C &value)
Template binary >>= operator to assign a value from an any.
Definition Any.hxx:327
com::sun::star::uno::cpp_release
void cpp_release(void *pCppI)
Function to release a C++ interface.
Definition genfunc.hxx:50
com::sun::star::uno::cpp_queryInterface
void * cpp_queryInterface(void *pCppI, typelib_TypeDescriptionReference *pType)
Function to query for a C++ interface.
Definition genfunc.hxx:55
com::sun::star::uno::cpp_acquire
void cpp_acquire(void *pCppI)
Function to acquire a C++ interface.
Definition genfunc.hxx:45
com::sun::star::uno::toAny
Any toAny(T const &value)
Wrap a value in an Any, if necessary.
Definition Any.hxx:245
com::sun::star::uno::operator<<=
void operator<<=(Any &rAny, const C &value)
Template binary <<= operator to set the value of an any.
Definition Any.hxx:277
cppu::getTypeFavourUnsigned
css::uno::Type const & getTypeFavourUnsigned(SAL_UNUSED_PARAMETER T const *)
A working replacement for getCppuType (see there).
Definition unotype.hxx:324
_sal_Sequence
This is the binary specification of a SAL sequence.
Definition types.h:304
rtl::Reference
Template reference class for reference type.
Definition ref.hxx:46
rtl::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition ustring.hxx:171
com::sun::star::uno::Reference
Template reference class for interface type derived from BaseReference.
Definition Reference.h:184
com::sun::star::uno::Reference::get
interface_type * get() const
Gets interface pointer.
Definition Reference.h:403
cppu::UnoType
Get the css::uno::Type instance representing a certain UNO type.
Definition unotype.hxx:290
com::sun::star::uno::Any
C++ class representing an IDL any.
Definition Any.h:58
com::sun::star::uno::Any::has
bool has() const
Tests whether this any can provide a value of specified type.
Definition Any.hxx:206
com::sun::star::uno::Any::get
T get() const
Provides a value of specified type, so you can easily write e.g.
Definition Any.hxx:681
com::sun::star::uno::Any::operator!=
bool operator!=(const Any &rAny) const
Inequality operator: compares two anys.
Definition Any.hxx:226
com::sun::star::uno::Any::operator=
Any & operator=(const Any &rAny)
Assignment operator: Sets the value of the given any.
Definition Any.hxx:123
com::sun::star::uno::Any::getValueTypeName
inline ::rtl::OUString getValueTypeName() const
Gets the type name of the set value.
Definition Any.hxx:165
com::sun::star::uno::Any::operator==
bool operator==(const Any &rAny) const
Equality operator: compares two anys.
Definition Any.hxx:219
com::sun::star::uno::Any::setValue
void setValue(const void *pData_, const Type &rType)
Sets a value.
Definition Any.hxx:170
com::sun::star::uno::Any::isExtractableTo
bool isExtractableTo(const Type &rType) const
Tests whether this any is extractable to a value of given type.
Definition Any.hxx:197
com::sun::star::uno::Any::getValue
const void * getValue() const
Gets a pointer to the set value.
Definition Any.h:198
com::sun::star::uno::Any::~Any
~Any()
Destructor: Destructs any content and frees memory.
Definition Any.hxx:117
com::sun::star::uno::Any::clear
void clear()
Clears this any.
Definition Any.hxx:191
com::sun::star::uno::Any::Any
Any()
Default constructor: Any holds no value; its type is void.
Definition Any.hxx:59
com::sun::star::uno::BaseReference
This base class serves as a base class for all template reference classes and has been introduced due...
Definition Reference.h:67
com::sun::star::uno::Type
C++ class representing an IDL meta type.
Definition Type.h:59
com::sun::star::uno::Type::equals
bool equals(const Type &rType) const
Compares two types.
Definition Type.h:181