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