xref: /aoo42x/main/autodoc/inc/cosv/std_outp.hxx (revision 8a106958)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef CSV_STD_OUTP_HXX
25 #define CSV_STD_OUTP_HXX
26 
27 // USED SERVICES
28 	// BASE CLASSES
29 	// COMPONENTS
30 #include <cosv/csv_ostream.hxx>
31 	// PARAMETERS
32 
33 
34 
35 
36 namespace csv
37 {
38 
39 #ifdef CSV_NO_IOSTREAMS
40 class redirect_out : public ostream
41 {
42   public:
~redirect_out()43     virtual             ~redirect_out() {}
44 
re_endl()45     void                re_endl()               { do_re_endl(); }
re_flush()46     void                re_flush()              { do_re_flush(); }
47 
set_(redirect_out & o_rStdOut,redirect_out & o_rStdErr)48     static void         set_(
49                             redirect_out &      o_rStdOut,
50                             redirect_out &      o_rStdErr )
51                                                 { pStdOut_ = &o_rStdOut;
52                                                   pStdErr_ = &o_rStdErr; }
53 
54     static redirect_out &
std_()55                         std_()                  { return *pStdOut_; }
56     static redirect_out &
err_()57                         err_()                  { return *pStdErr_; }
useme_()58     static bool         useme_()                { return pStdOut_ != 0; }
59 
60   private:
61     virtual void        do_re_endl() = 0;
62     virtual void        do_re_flush() = 0;
63 
64     // DATA
65     static redirect_out *
66                         pStdOut_;
67     static redirect_out *
68                         pStdErr_;
69 };
70 #endif // defined(CSV_NO_IOSTREAMS)
71 
72 
73 inline ostream &
Cout()74 Cout()
75 {
76 
77 #ifndef CSV_NO_IOSTREAMS
78 //    return redirect_out::useme_()
79 //            ?   (ostream&)( redirect_out::std_() )
80 //            :   (ostream&)( std::cout );
81     return (ostream&)( std::cout );
82 #else
83     csv_assert( redirect_out::useme_() );
84     return redirect_out::std_();
85 #endif
86 }
87 
88 inline ostream &
Cerr()89 Cerr()
90 {
91 #ifndef CSV_NO_IOSTREAMS
92 //    return redirect_out::useme_()
93 //            ?   (ostream&)( redirect_out::err_() )
94 //            :   (ostream&)( std::cerr );
95     return (ostream&)( std::cerr );
96 #else
97     csv_assert( redirect_out::useme_() );
98     return redirect_out::err_();
99 #endif
100 }
101 
102 
103 
104 typedef void (*F_FLUSHING_FUNC)(ostream&, bool, int*);
105 
106 void                Endl( ostream&, bool, int* );
107 
108 void                Flush( ostream&, bool, int* );
109 
110 
111 }   // namespace csv
112 
113 
114 
115 inline csv::ostream &
operator <<(csv::ostream & io_rStream,csv::F_FLUSHING_FUNC i_fFlushingFunc)116 operator<<( csv::ostream &		    io_rStream,
117 	        csv::F_FLUSHING_FUNC    i_fFlushingFunc )
118 {
119 #ifndef CSV_NO_IOSTREAMS
120 //    (*i_fFlushingFunc)( io_rStream, csv::redirect_out::useme_(), 0 );
121     (*i_fFlushingFunc)( io_rStream, false, 0 );
122 #else
123     csv_assert( csv::redirect_out::useme_() );
124     (*i_fFlushingFunc)( io_rStream, true, 0 );
125 #endif
126     return io_rStream;
127 }
128 
129 
130 #endif
131 
132 
133