diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-04-03 17:29:08 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-04-03 18:16:38 +0200 |
commit | 2ac5b08361bf0c7c98ff9bc10869e2b41c9d85fd (patch) | |
tree | 0ff40b8c0bed74ac19245da6b76706a0691a6e6d /sal | |
parent | 7d540bd08ea06c95d5ac27530b8386ae1bea6526 (diff) |
try including the ostream<<OUString operator directly with OUString
The theory is that
- the operator is suboptimal, because it always uses utf-8 as the encoding,
which might possibly lead to some encoding problem somewhere
but
- the SAL_LOG macros need it anyway, or they are otherwise cumbersome
with OUString
- as people learn to use the macros more, rtl/oustringostreaminserter.hxx
will be included in more and more places, eventually possibly triggering
the above problem anyway
- people probably should not just blindly do ostream << oustring if they
have special encoding requirements
So let's try to simply always have the operator available and see how
it works out.
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/oustringostreaminserter.hxx | 16 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 5 | ||||
-rw-r--r-- | sal/inc/sal/log.hxx | 8 |
3 files changed, 15 insertions, 14 deletions
diff --git a/sal/inc/rtl/oustringostreaminserter.hxx b/sal/inc/rtl/oustringostreaminserter.hxx index 632bc23492ce..28d7c17561d5 100644 --- a/sal/inc/rtl/oustringostreaminserter.hxx +++ b/sal/inc/rtl/oustringostreaminserter.hxx @@ -34,14 +34,6 @@ #include "rtl/textenc.h" #include "rtl/ustring.hxx" -/** Include this header to support rtl::OUString in std::ostream (and thus in - CPPUNIT_ASSERT macros, for example). - - The rtl::OUString is converted to UTF-8. - - @since LibreOffice 3.5. -*/ - // The unittest uses slightly different code to help check that the proper // calls are made. The class is put into a different namespace to make // sure the compiler generates a different (if generating also non-inline) @@ -57,6 +49,14 @@ namespace rtl { #undef rtl #endif +/** + Support for rtl::OUString in std::ostream (and thus in + CPPUNIT_ASSERT or SAL_INFO macros, for example). + + The rtl::OUString is converted to UTF-8. + + @since LibreOffice 3.5. +*/ template< typename charT, typename traits > std::basic_ostream<charT, traits> & operator <<( std::basic_ostream<charT, traits> & stream, rtl::OUString const & string) diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index ee1ba7f7eed5..093b6c953fa4 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -2085,4 +2085,9 @@ inline OString OUStringToOString( const OUString & rUnicode, #endif /* _RTL_USTRING_HXX */ +// Include the ostream << operator directly here, so that it's always available +// for SAL_INFO etc. Make sure it's outside of #ifdef _RTL_USTRING_HXX, because +// includes ustring.hxx back. +#include <rtl/oustringostreaminserter.hxx> + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/inc/sal/log.hxx b/sal/inc/sal/log.hxx index 59c11cd02713..bb41a6f58e03 100644 --- a/sal/inc/sal/log.hxx +++ b/sal/inc/sal/log.hxx @@ -197,13 +197,9 @@ inline char const * unwrapStream(SAL_UNUSED_PARAMETER StreamIgnore const &) { SAL_INFO("foo", "string " << s << " of length " << n) - would be an example of such a call; if the given s is of type rtl::OUString, + would be an example of such a call. - \#include "rtl/oustringostreaminserter.hxx" - - would make sure that an appropriate operator << is available. - - In either case, the composed message should be in UTF-8 and it should + In the composed message should be in UTF-8 and it should contain no vertical formatting characters and no null characters For the _IF variants, log output is only generated if the given condition is |