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