diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-09-18 11:54:05 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-09-18 11:54:05 +0200 |
commit | 96b45756b46ceb06dbec5c241d09acc96891e121 (patch) | |
tree | c4b19cb1c2777789fe089d4e866fc833fdd48b26 /sal | |
parent | -Werror=unused-parameter (diff) | |
download | core-96b45756b46ceb06dbec5c241d09acc96891e121.tar.gz core-96b45756b46ceb06dbec5c241d09acc96891e121.zip |
move ostream OUString operator<< directly to ustring.hxx
It apparently works that way, so there's no need to have
an #include loop.
Change-Id: I58d4f0461c14637872a139f0fbfb78f2a99fe28a
Diffstat (limited to 'sal')
-rw-r--r-- | sal/inc/rtl/oustringostreaminserter.hxx | 44 | ||||
-rw-r--r-- | sal/inc/rtl/ustring.hxx | 36 |
2 files changed, 34 insertions, 46 deletions
diff --git a/sal/inc/rtl/oustringostreaminserter.hxx b/sal/inc/rtl/oustringostreaminserter.hxx index c25998a8ee3e..48dc79e0e097 100644 --- a/sal/inc/rtl/oustringostreaminserter.hxx +++ b/sal/inc/rtl/oustringostreaminserter.hxx @@ -27,47 +27,9 @@ #ifndef INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX #define INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX -#include "sal/config.h" - -#include <ostream> - -#include "rtl/textenc.h" -#include "rtl/ustring.hxx" - -// 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) -// copy of the function and does not merge them together. The class -// is "brought" into the proper rtl namespace by a typedef below. -#ifdef RTL_STRING_UNITTEST -#define rtl rtlunittest -#endif - -namespace rtl { - -#ifdef RTL_STRING_UNITTEST -#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 > -inline std::basic_ostream<charT, traits> & operator <<( - std::basic_ostream<charT, traits> & stream, rtl::OUString const & string) -{ - return stream << - rtl::OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr(); - // best effort; potentially loses data due to conversion failures - // (stray surrogate halves) and embedded null characters -} - -} +// File kept only for backwards compatibility, the inserter is now defined +// together with OUString. +#include <rtl/ustring.hxx> #endif diff --git a/sal/inc/rtl/ustring.hxx b/sal/inc/rtl/ustring.hxx index 4afb1d292a11..b008054e17e3 100644 --- a/sal/inc/rtl/ustring.hxx +++ b/sal/inc/rtl/ustring.hxx @@ -32,12 +32,14 @@ #include "sal/config.h" #include <cassert> +#include <ostream> #include "osl/diagnose.h" #include <rtl/ustring.h> #include <rtl/string.hxx> #include <rtl/stringutils.hxx> #include <rtl/memory.h> +#include <rtl/textenc.h> #include "sal/log.hxx" #if defined EXCEPTIONS_OFF @@ -2141,6 +2143,35 @@ inline OString OUStringToOString( const OUString & rUnicode, } /* Namespace */ +#ifdef RTL_STRING_UNITTEST +#define rtl rtlunittest +#endif +namespace rtl +{ +#ifdef RTL_STRING_UNITTEST +#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 > +inline std::basic_ostream<charT, traits> & operator <<( + std::basic_ostream<charT, traits> & stream, OUString const & string) +{ + return stream << + rtl::OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr(); + // best effort; potentially loses data due to conversion failures + // (stray surrogate halves) and embedded null characters +} + +} // namespace + // RTL_USING is defined by gbuild for all modules except those with stable public API // (as listed in ure/source/README). It allows to use classes like OUString without // having to explicitly refer to the rtl namespace, which is kind of superfluous @@ -2154,9 +2185,4 @@ using ::rtl::OUStringToOString; #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: */ |