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

LibreOffice LibreOffice 7.4 SDK C/C++ API Reference

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