merged tag ooo/OOO330_m14
[LibreOffice.git] / cosv / inc / cosv / std_outp.hxx
blob705aa8312a027b8d17ada8885df00f1075014e66
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
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.
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).
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.
26 ************************************************************************/
28 #ifndef CSV_STD_OUTP_HXX
29 #define CSV_STD_OUTP_HXX
31 // USED SERVICES
32 // BASE CLASSES
33 // COMPONENTS
34 #include <cosv/csv_ostream.hxx>
35 // PARAMETERS
40 namespace csv
43 #ifdef CSV_NO_IOSTREAMS
44 class redirect_out : public ostream
46 public:
47 virtual ~redirect_out() {}
49 void re_endl() { do_re_endl(); }
50 void re_flush() { do_re_flush(); }
52 static void set_(
53 redirect_out & o_rStdOut,
54 redirect_out & o_rStdErr )
55 { pStdOut_ = &o_rStdOut;
56 pStdErr_ = &o_rStdErr; }
58 static redirect_out &
59 std_() { return *pStdOut_; }
60 static redirect_out &
61 err_() { return *pStdErr_; }
62 static bool useme_() { return pStdOut_ != 0; }
64 private:
65 virtual void do_re_endl() = 0;
66 virtual void do_re_flush() = 0;
68 // DATA
69 static redirect_out *
70 pStdOut_;
71 static redirect_out *
72 pStdErr_;
74 #endif // defined(CSV_NO_IOSTREAMS)
77 inline ostream &
78 Cout()
81 #ifndef CSV_NO_IOSTREAMS
82 // return redirect_out::useme_()
83 // ? (ostream&)( redirect_out::std_() )
84 // : (ostream&)( std::cout );
85 return (ostream&)( std::cout );
86 #else
87 csv_assert( redirect_out::useme_() );
88 return redirect_out::std_();
89 #endif
92 inline ostream &
93 Cerr()
95 #ifndef CSV_NO_IOSTREAMS
96 // return redirect_out::useme_()
97 // ? (ostream&)( redirect_out::err_() )
98 // : (ostream&)( std::cerr );
99 return (ostream&)( std::cerr );
100 #else
101 csv_assert( redirect_out::useme_() );
102 return redirect_out::err_();
103 #endif
108 typedef void (*F_FLUSHING_FUNC)(ostream&, bool, int*);
110 void Endl( ostream&, bool, int* );
112 void Flush( ostream&, bool, int* );
115 } // namespace csv
119 inline csv::ostream &
120 operator<<( csv::ostream & io_rStream,
121 csv::F_FLUSHING_FUNC i_fFlushingFunc )
123 #ifndef CSV_NO_IOSTREAMS
124 // (*i_fFlushingFunc)( io_rStream, csv::redirect_out::useme_(), 0 );
125 (*i_fFlushingFunc)( io_rStream, false, 0 );
126 #else
127 csv_assert( csv::redirect_out::useme_() );
128 (*i_fFlushingFunc)( io_rStream, true, 0 );
129 #endif
130 return io_rStream;
134 #endif