info/SRC680/m74 : C++-UNO Any additions
[email protected] Wed, 21 Sep 2005 13:08:49 +0200 (CEST)
| Newsgroups | gmane.comp.openoffice.announce.interface |
|---|---|
| Message-ID | <12311015.1127300929342.JavaMail.root@sd-web1> |
Type info Title C++-UNO Any additions Posted by [email protected] Affected ..., Effective from SRC680/m74 Summary + [public] template <typename T> explicit inline Any( T const & value ); + [public] explicit inline Any( bool value ); + [public] template <typename T> inline T get() const; + [public] template <typename T> inline bool has() const; + inline void SAL_CALL operator <<= ( Any & rAny, bool const & value ) SAL_THROW( () ); disallowing use of ambiguous C++-UNO types (sal_Unicode vs. sal_uInt16): + [private, undefined] explicit Any( sal_uInt16 ); + [private, undefined] template <> sal_uInt16 get<sal_uInt16>() const; + [private, undefined] template <> bool has<sal_uInt16>() const; Description FIRST, I have added a templated ctor to class com::sun::star::uno::Any: template <typename T> explicit inline Any( T const & value ); and support for C++ bool: explicit inline Any( bool value ); to be used instead of makeAny(), e.g. Any foo(myString); Any bar(false); SECOND, I have added the following template member functions to class com::sun::star::uno::Any: template <typename T> inline T get() const; provides a value of the specified type, so you can easily write e.g. sal_Int32 myVal = myAny.get<sal_Int32>(); Widening conversion without data loss is taken into account, objects will be queried for interface if necessary. A com::sun::star::uno::RuntimeException is thrown if the specified type cannot be provided. [This function is only available if code is compiled with exception support.] template <typename T> inline bool has() const; tests whether the Any can provide a value of specified type. Widening conversion without data loss is taken into account, objects will be queried for interface if necessary, e.g. if (myAny.has<sal_Int16>()) ... THIRD, I have added support for C++ bool to set an Any's value, which has been missing: inline void SAL_CALL operator <<= ( Any & rAny, bool const & value ) SAL_THROW( () ); FINALLY, all new template members cannot be used with ambiguous C++-UNO types sal_Unicode resp. sal_uInt16. This will result either in a compilation or link error (depends on the compiler). --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]