Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 : : *
5 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
6 : : *
7 : : * OpenOffice.org - a multi-platform office productivity suite
8 : : *
9 : : * This file is part of OpenOffice.org.
10 : : *
11 : : * OpenOffice.org is free software: you can redistribute it and/or modify
12 : : * it under the terms of the GNU Lesser General Public License version 3
13 : : * only, as published by the Free Software Foundation.
14 : : *
15 : : * OpenOffice.org is distributed in the hope that it will be useful,
16 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 : : * GNU Lesser General Public License version 3 for more details
19 : : * (a copy is included in the LICENSE file that accompanied this code).
20 : : *
21 : : * You should have received a copy of the GNU Lesser General Public License
22 : : * version 3 along with OpenOffice.org. If not, see
23 : : * <http://www.openoffice.org/license.html>
24 : : * for a copy of the LGPLv3 License.
25 : : ************************************************************************/
26 : :
27 : : #ifndef INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX
28 : : #define INCLUDED_RTL_OUSTRINGOSTREAMINSERTER_HXX
29 : :
30 : : #include "sal/config.h"
31 : :
32 : : #include <ostream>
33 : :
34 : : #include "rtl/textenc.h"
35 : : #include "rtl/ustring.hxx"
36 : :
37 : : // The unittest uses slightly different code to help check that the proper
38 : : // calls are made. The class is put into a different namespace to make
39 : : // sure the compiler generates a different (if generating also non-inline)
40 : : // copy of the function and does not merge them together. The class
41 : : // is "brought" into the proper rtl namespace by a typedef below.
42 : : #ifdef RTL_STRING_UNITTEST
43 : : #define rtl rtlunittest
44 : : #endif
45 : :
46 : : namespace rtl {
47 : :
48 : : #ifdef RTL_STRING_UNITTEST
49 : : #undef rtl
50 : : #endif
51 : :
52 : : /**
53 : : Support for rtl::OUString in std::ostream (and thus in
54 : : CPPUNIT_ASSERT or SAL_INFO macros, for example).
55 : :
56 : : The rtl::OUString is converted to UTF-8.
57 : :
58 : : @since LibreOffice 3.5.
59 : : */
60 : : template< typename charT, typename traits > std::basic_ostream<charT, traits> &
61 : 93 : operator <<(
62 : : std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
63 : : {
64 : : return stream <<
65 [ + - ]: 93 : rtl::OUStringToOString(string, RTL_TEXTENCODING_UTF8).getStr();
66 : : // best effort; potentially loses data due to conversion failures
67 : : // (stray surrogate halves) and embedded null characters
68 : : }
69 : :
70 : : }
71 : :
72 : : #endif
73 : :
74 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|