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

LibreOffice LibreOffice 24.8 SDK C/C++ API Reference |

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