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

LibreOffice LibreOffice 7.4 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<typename T>
88 Any::Any(rtl::OUStringNumber<T> && 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
253template<typename T1, typename T2>
254Any toAny(rtl::OUStringConcat<T1, T2> && value)
255{ return Any(std::move(value)); }
256
257template<typename T>
258Any toAny(rtl::OUStringNumber<T> && value)
259{ return Any(std::move(value)); }
260
261template<typename T> bool fromAny(Any const & any, T * value) {
262 assert(value != nullptr);
263 return any >>= *value;
264}
265
266template<> bool fromAny(Any const & any, Any * value) {
267 assert(value != nullptr);
268 *value = any;
269 return true;
270}
271
272#endif
273
274template< class C >
275 inline void SAL_CALL operator <<= ( Any & rAny, const C & value )
276{
277 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
278 ::uno_type_any_assign(
279 &rAny, const_cast< C * >( &value ), rType.getTypeLibType(),
280 cpp_acquire, cpp_release );
281}
282
283// additionally for C++ bool:
284
285template<>
286 inline void SAL_CALL operator <<= ( Any & rAny, bool const & value )
287{
288 sal_Bool b = value;
289 ::uno_type_any_assign(
290 &rAny, &b, cppu::UnoType<bool>::get().getTypeLibType(),
291 cpp_acquire, cpp_release );
292}
293
294
295#ifdef LIBO_INTERNAL_ONLY // "RTL_FAST_STRING"
296template< class C1, class C2 >
297inline void operator <<= ( Any & rAny, rtl::OUStringConcat< C1, C2 >&& value )
298{
299 const rtl::OUString str( std::move(value) );
300 const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
301 ::uno_type_any_assign(
302 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
303 cpp_acquire, cpp_release );
304}
305template<typename T1, typename T2>
306void operator <<=(Any &, rtl::OUStringConcat<T1, T2> const &) = delete;
307template< class C >
308inline void operator <<= ( Any & rAny, rtl::OUStringNumber< C >&& value )
309{
310 const rtl::OUString str( std::move(value) );
311 const Type & rType = ::cppu::getTypeFavourUnsigned(&str);
312 ::uno_type_any_assign(
313 &rAny, const_cast< rtl::OUString * >( &str ), rType.getTypeLibType(),
314 cpp_acquire, cpp_release );
315}
316template<typename T>
317void operator <<=(Any &, rtl::OUStringNumber<T> const &) = delete;
318#endif
319
320#if defined LIBO_INTERNAL_ONLY
321template<> void SAL_CALL operator <<=(Any &, Any const &) = delete;
322#endif
323
324template< class C >
325 inline bool SAL_CALL operator >>= ( const Any & rAny, C & value )
326{
327 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
328 return ::uno_type_assignData(
329 &value, rType.getTypeLibType(),
330 rAny.pData, rAny.pType,
331 cpp_queryInterface,
332 cpp_acquire, cpp_release );
333}
334
335// bool
336
337template<>
338 inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Bool & value )
339{
340 if (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass)
341 {
342 value = bool(* static_cast< const sal_Bool * >( rAny.pData ));
343 return true;
344 }
345 return false;
346}
347
348template<>
349 inline bool SAL_CALL operator == ( const Any & rAny, const sal_Bool & value )
350{
351 return (typelib_TypeClass_BOOLEAN == rAny.pType->eTypeClass &&
352 bool(value) == bool(* static_cast< const sal_Bool * >( rAny.pData )));
353}
354
355
356template<>
357 inline bool SAL_CALL operator >>= ( Any const & rAny, bool & value )
358{
359 if (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN)
360 {
361 value = *static_cast< sal_Bool const * >( rAny.pData );
362 return true;
363 }
364 return false;
365}
366
367
368template<>
369 inline bool SAL_CALL operator == ( Any const & rAny, bool const & value )
370{
371 return (rAny.pType->eTypeClass == typelib_TypeClass_BOOLEAN &&
372 (value ==
373 bool(*static_cast< sal_Bool const * >( rAny.pData ))));
374}
375
376// byte
377
378template<>
379 inline bool SAL_CALL operator >>= ( const ::com::sun::star::uno::Any & rAny, sal_Int8 & value )
380{
381 if (typelib_TypeClass_BYTE == rAny.pType->eTypeClass)
382 {
383 value = * static_cast< const sal_Int8 * >( rAny.pData );
384 return true;
385 }
386 return false;
387}
388// short
389
390template<>
391 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int16 & value )
392{
393 switch (rAny.pType->eTypeClass)
394 {
395 case typelib_TypeClass_BYTE:
396 value = * static_cast< const sal_Int8 * >( rAny.pData );
397 return true;
398 case typelib_TypeClass_SHORT:
399 case typelib_TypeClass_UNSIGNED_SHORT:
400 value = * static_cast< const sal_Int16 * >( rAny.pData );
401 return true;
402 default:
403 return false;
404 }
405}
406
407template<>
408 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt16 & value )
409{
410 switch (rAny.pType->eTypeClass)
411 {
412 case typelib_TypeClass_BYTE:
413 value = static_cast<sal_uInt16>( * static_cast< const sal_Int8 * >( rAny.pData ) );
414 return true;
415 case typelib_TypeClass_SHORT:
416 case typelib_TypeClass_UNSIGNED_SHORT:
417 value = * static_cast< const sal_uInt16 * >( rAny.pData );
418 return true;
419 default:
420 return false;
421 }
422}
423// long
424
425template<>
426 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int32 & value )
427{
428 switch (rAny.pType->eTypeClass)
429 {
430 case typelib_TypeClass_BYTE:
431 value = * static_cast< const sal_Int8 * >( rAny.pData );
432 return true;
433 case typelib_TypeClass_SHORT:
434 value = * static_cast< const sal_Int16 * >( rAny.pData );
435 return true;
436 case typelib_TypeClass_UNSIGNED_SHORT:
437 value = * static_cast< const sal_uInt16 * >( rAny.pData );
438 return true;
439 case typelib_TypeClass_LONG:
440 case typelib_TypeClass_UNSIGNED_LONG:
441 value = * static_cast< const sal_Int32 * >( rAny.pData );
442 return true;
443 default:
444 return false;
445 }
446}
447
448template<>
449 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt32 & value )
450{
451 switch (rAny.pType->eTypeClass)
452 {
453 case typelib_TypeClass_BYTE:
454 value = static_cast<sal_uInt32>( * static_cast< const sal_Int8 * >( rAny.pData ) );
455 return true;
456 case typelib_TypeClass_SHORT:
457 value = static_cast<sal_uInt32>( * static_cast< const sal_Int16 * >( rAny.pData ) );
458 return true;
459 case typelib_TypeClass_UNSIGNED_SHORT:
460 value = * static_cast< const sal_uInt16 * >( rAny.pData );
461 return true;
462 case typelib_TypeClass_LONG:
463 case typelib_TypeClass_UNSIGNED_LONG:
464 value = * static_cast< const sal_uInt32 * >( rAny.pData );
465 return true;
466 default:
467 return false;
468 }
469}
470// hyper
471
472template<>
473 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_Int64 & value )
474{
475 switch (rAny.pType->eTypeClass)
476 {
477 case typelib_TypeClass_BYTE:
478 value = * static_cast< const sal_Int8 * >( rAny.pData );
479 return true;
480 case typelib_TypeClass_SHORT:
481 value = * static_cast< const sal_Int16 * >( rAny.pData );
482 return true;
483 case typelib_TypeClass_UNSIGNED_SHORT:
484 value = * static_cast< const sal_uInt16 * >( rAny.pData );
485 return true;
486 case typelib_TypeClass_LONG:
487 value = * static_cast< const sal_Int32 * >( rAny.pData );
488 return true;
489 case typelib_TypeClass_UNSIGNED_LONG:
490 value = * static_cast< const sal_uInt32 * >( rAny.pData );
491 return true;
492 case typelib_TypeClass_HYPER:
493 case typelib_TypeClass_UNSIGNED_HYPER:
494 value = * static_cast< const sal_Int64 * >( rAny.pData );
495 return true;
496 default:
497 return false;
498 }
499}
500
501template<>
502 inline bool SAL_CALL operator >>= ( const Any & rAny, sal_uInt64 & value )
503{
504 switch (rAny.pType->eTypeClass)
505 {
506 case typelib_TypeClass_BYTE:
507 value = static_cast<sal_uInt64>( * static_cast< const sal_Int8 * >( rAny.pData ) );
508 return true;
509 case typelib_TypeClass_SHORT:
510 value = static_cast<sal_uInt64>( * static_cast< const sal_Int16 * >( rAny.pData ) );
511 return true;
512 case typelib_TypeClass_UNSIGNED_SHORT:
513 value = * static_cast< const sal_uInt16 * >( rAny.pData );
514 return true;
515 case typelib_TypeClass_LONG:
516 value = static_cast<sal_uInt64>( * static_cast< const sal_Int32 * >( rAny.pData ) );
517 return true;
518 case typelib_TypeClass_UNSIGNED_LONG:
519 value = * static_cast< const sal_uInt32 * >( rAny.pData );
520 return true;
521 case typelib_TypeClass_HYPER:
522 case typelib_TypeClass_UNSIGNED_HYPER:
523 value = * static_cast< const sal_uInt64 * >( rAny.pData );
524 return true;
525 default:
526 return false;
527 }
528}
529// float
530
531template<>
532 inline bool SAL_CALL operator >>= ( const Any & rAny, float & value )
533{
534 switch (rAny.pType->eTypeClass)
535 {
536 case typelib_TypeClass_BYTE:
537 value = * static_cast< const sal_Int8 * >( rAny.pData );
538 return true;
539 case typelib_TypeClass_SHORT:
540 value = * static_cast< const sal_Int16 * >( rAny.pData );
541 return true;
542 case typelib_TypeClass_UNSIGNED_SHORT:
543 value = * static_cast< const sal_uInt16 * >( rAny.pData );
544 return true;
545 case typelib_TypeClass_FLOAT:
546 value = * static_cast< const float * >( rAny.pData );
547 return true;
548 default:
549 return false;
550 }
551}
552// double
553
554template<>
555 inline bool SAL_CALL operator >>= ( const Any & rAny, double & value )
556{
557 switch (rAny.pType->eTypeClass)
558 {
559 case typelib_TypeClass_BYTE:
560 value = * static_cast< const sal_Int8 * >( rAny.pData );
561 return true;
562 case typelib_TypeClass_SHORT:
563 value = * static_cast< const sal_Int16 * >( rAny.pData );
564 return true;
565 case typelib_TypeClass_UNSIGNED_SHORT:
566 value = * static_cast< const sal_uInt16 * >( rAny.pData );
567 return true;
568 case typelib_TypeClass_LONG:
569 value = * static_cast< const sal_Int32 * >( rAny.pData );
570 return true;
571 case typelib_TypeClass_UNSIGNED_LONG:
572 value = * static_cast< const sal_uInt32 * >( rAny.pData );
573 return true;
574 case typelib_TypeClass_FLOAT:
575 value = * static_cast< const float * >( rAny.pData );
576 return true;
577 case typelib_TypeClass_DOUBLE:
578 value = * static_cast< const double * >( rAny.pData );
579 return true;
580 default:
581 return false;
582 }
583}
584// string
585
586template<>
587 inline bool SAL_CALL operator >>= ( const Any & rAny, ::rtl::OUString & value )
588{
589 if (typelib_TypeClass_STRING == rAny.pType->eTypeClass)
590 {
591 value = * static_cast< const ::rtl::OUString * >( rAny.pData );
592 return true;
593 }
594 return false;
595}
596
597template<>
598 inline bool SAL_CALL operator == ( const Any & rAny, const ::rtl::OUString & value )
599{
600 return (typelib_TypeClass_STRING == rAny.pType->eTypeClass &&
601 value == * static_cast< const ::rtl::OUString * >( rAny.pData ) );
602}
603// type
604
605template<>
606 inline bool SAL_CALL operator >>= ( const Any & rAny, Type & value )
607{
608 if (typelib_TypeClass_TYPE == rAny.pType->eTypeClass)
609 {
610 value = * static_cast< const Type * >( rAny.pData );
611 return true;
612 }
613 return false;
614}
615
616template<>
617 inline bool SAL_CALL operator == ( const Any & rAny, const Type & value )
618{
619 return (typelib_TypeClass_TYPE == rAny.pType->eTypeClass &&
620 value.equals( * static_cast< const Type * >( rAny.pData ) ));
621}
622// any
623
624#if defined LIBO_INTERNAL_ONLY
625template<> bool SAL_CALL operator >>=(Any const &, Any &) = delete;
626#else
627template<>
628 inline bool SAL_CALL operator >>= ( const Any & rAny, Any & value )
629{
630 if (&rAny != &value)
631 {
632 ::uno_type_any_assign(
633 &value, rAny.pData, rAny.pType,
634 cpp_acquire, cpp_release );
635 }
636 return true;
637}
638#endif
639// interface
640
641template<>
642 inline bool SAL_CALL operator == ( const Any & rAny, const BaseReference & value )
643{
644 if (typelib_TypeClass_INTERFACE == rAny.pType->eTypeClass)
645 {
646 return static_cast< const BaseReference * >( rAny.pData )->operator == ( value );
647 }
648 return false;
649}
650
651// operator to compare to an any.
652
653template< class C >
654 inline bool SAL_CALL operator == ( const Any & rAny, const C & value )
655{
656 const Type & rType = ::cppu::getTypeFavourUnsigned(&value);
657 return ::uno_type_equalData(
658 rAny.pData, rAny.pType,
659 const_cast< C * >( &value ), rType.getTypeLibType(),
660 cpp_queryInterface, cpp_release );
661}
662// operator to compare to an any. may use specialized operators ==.
663
664template< class C >
665 inline bool SAL_CALL operator != ( const Any & rAny, const C & value )
666{
667 return (! operator == ( rAny, value ));
668}
669
670template <typename T>
671T Any::get() const
672{
673 T value = T();
674 if (! (*this >>= value)) {
675 throw RuntimeException(
676 ::rtl::OUString(
677 cppu_Any_extraction_failure_msg(
678 this,
679 ::cppu::getTypeFavourUnsigned(&value).getTypeLibType() ),
680 SAL_NO_ACQUIRE ) );
681 }
682 return value;
683}
684
685#if defined LIBO_INTERNAL_ONLY
686template<> Any Any::get() const = delete;
687#endif
688
695template<typename charT, typename traits>
696inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o, Any const &any) {
697 o << "<Any: (" << any.getValueTypeName() << ')';
698 switch(any.pType->eTypeClass) {
699 case typelib_TypeClass_VOID:
700 break;
701 case typelib_TypeClass_BOOLEAN:
702 o << ' ' << any.get<bool>();
703 break;
704 case typelib_TypeClass_BYTE:
705 case typelib_TypeClass_SHORT:
706 case typelib_TypeClass_LONG:
707 case typelib_TypeClass_HYPER:
708 o << ' ' << any.get<sal_Int64>();
709 break;
710 case typelib_TypeClass_UNSIGNED_SHORT:
711 case typelib_TypeClass_UNSIGNED_LONG:
712 case typelib_TypeClass_UNSIGNED_HYPER:
713 o << ' ' << any.get<sal_uInt64>();
714 break;
715 case typelib_TypeClass_FLOAT:
716 case typelib_TypeClass_DOUBLE:
717 o << ' ' << any.get<double>();
718 break;
719 case typelib_TypeClass_CHAR: {
720 std::ios_base::fmtflags flgs = o.setf(
721 std::ios_base::hex, std::ios_base::basefield);
722 charT fill = o.fill('0');
723 o << " U+" << std::setw(4)
724 << unsigned(*static_cast<sal_Unicode const *>(any.getValue()));
725 o.setf(flgs);
726 o.fill(fill);
727 break;
728 }
729 case typelib_TypeClass_STRING:
730 o << ' ' << any.get<rtl::OUString>();
731 break;
732 case typelib_TypeClass_TYPE:
733 o << ' ' << any.get<css::uno::Type>().getTypeName();
734 break;
735 case typelib_TypeClass_SEQUENCE:
736 o << " len "
737 << ((*static_cast<uno_Sequence * const *>(any.getValue()))->
738 nElements);
739 break;
740 case typelib_TypeClass_ENUM:
741 o << ' ' << *static_cast<sal_Int32 const *>(any.getValue());
742 break;
743 case typelib_TypeClass_STRUCT:
744 case typelib_TypeClass_EXCEPTION:
745 o << ' ' << any.getValue();
746 break;
747 case typelib_TypeClass_INTERFACE:
748 o << ' ' << *static_cast<void * const *>(any.getValue());
749 break;
750 default:
751 assert(false); // this cannot happen
752 break;
753 }
754 o << '>';
755 return o;
756}
757
758}
759}
760}
761}
762
763#endif
764
765/* 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_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_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.
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
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: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:654
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:696
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:665
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:325
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:275
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::OUString
This String class provides base functionality for C++ like Unicode character array handling.
Definition: ustring.hxx:203
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:57
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:671
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:197
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
com::sun::star::uno::Type::getTypeLibType
typelib_TypeDescriptionReference * getTypeLibType() const
Gets the C typelib type description reference pointer.
Definition: Type.h:162