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

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