summaryrefslogtreecommitdiff
path: root/include/com/sun/star
diff options
context:
space:
mode:
authorBoris DuĊĦek <me@dusek.me>2013-08-12 09:03:08 +0200
committerStephan Bergmann <sbergman@redhat.com>2013-08-14 13:29:39 +0200
commit8284ca9c4b5ca82e0a94d1fac9385f5e0dc6625f (patch)
tree1bb5e88ec639e8036fa6de8a8394f8b062999108 /include/com/sun/star
parent6fdf1275986cf63440fb86224a4152c0d3251de3 (diff)
Implement operator<<(std::ostream&, const uno::Any&)
In other words, SAL_DEBUG(any) works now. Structured any types (e.g. struct, array) not implemented yet. Change-Id: I6460e72bbeff86da17711cab5d2018508468290c Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/com/sun/star')
-rw-r--r--include/com/sun/star/uno/Any.hxx74
1 files changed, 74 insertions, 0 deletions
diff --git a/include/com/sun/star/uno/Any.hxx b/include/com/sun/star/uno/Any.hxx
index 6f3bda9692bd..b7a5c0484cab 100644
--- a/include/com/sun/star/uno/Any.hxx
+++ b/include/com/sun/star/uno/Any.hxx
@@ -19,6 +19,8 @@
#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
#define _COM_SUN_STAR_UNO_ANY_HXX_
+#include <ostream>
+
#include <com/sun/star/uno/Any.h>
#include <uno/data.h>
#include <com/sun/star/uno/Type.hxx>
@@ -586,6 +588,78 @@ template <>
sal_uInt16 Any::get<sal_uInt16>() const;
#endif // ! defined(EXCEPTIONS_OFF)
+/**
+ * @since LibreOffice 4.2
+ */
+template<typename charT, typename traits>
+inline std::basic_ostream<charT, traits> &operator<<(std::basic_ostream<charT, traits> &o, Any &any) {
+ // prolog with type
+ o << "<Any: (" << any.getValueTypeName() << ")";
+ // log value
+ switch(any.pType->eTypeClass) {
+ case typelib_TypeClass_BOOLEAN: {
+ bool b = bool();
+ any >>= b;
+ o << b;
+ break;
+ }
+
+ case typelib_TypeClass_BYTE:
+ case typelib_TypeClass_SHORT:
+ case typelib_TypeClass_LONG:
+ case typelib_TypeClass_HYPER: {
+ sal_Int64 i = sal_Int64();
+ any >>= i;
+ o << i;
+ break;
+ }
+
+ case typelib_TypeClass_UNSIGNED_SHORT:
+ case typelib_TypeClass_UNSIGNED_LONG:
+ case typelib_TypeClass_UNSIGNED_HYPER: {
+ sal_uInt64 u = sal_uInt64();
+ any >>= u;
+ o << u;
+ break;
+ }
+
+ case typelib_TypeClass_FLOAT:
+ case typelib_TypeClass_DOUBLE: {
+ double d = double();
+ any >>= d;
+ o << d;
+ break;
+ }
+
+ case typelib_TypeClass_STRING: {
+ ::rtl::OUString s;
+ any >>= s;
+ o << s;
+ break;
+ }
+
+ case typelib_TypeClass_VOID:
+ case typelib_TypeClass_CHAR:
+ case typelib_TypeClass_TYPE:
+ case typelib_TypeClass_SEQUENCE:
+ case typelib_TypeClass_ENUM:
+ case typelib_TypeClass_STRUCT:
+ case typelib_TypeClass_EXCEPTION:
+ case typelib_TypeClass_INTERFACE: {
+ // log nothing here - leave just type
+ break;
+ }
+
+ default:
+ assert(false); // this cannot happen
+ o << "!!this type should not happen in Any!!";
+ break;
+ }
+ // epilog
+ o << ">";
+ return o;
+}
+
}
}
}