1 // Module: Log4CPLUS
2 // File: streams.h
3 // Created: 4/2003
4 // Author: Tad E. Smith
5 //
6 //
7 // Copyright (C) Tad E. Smith All rights reserved.
8 //
9 // This software is published under the terms of the Apache Software
10 // License version 1.1, a copy of which has been included with this
11 // distribution in the LICENSE.APL file.
12 //
13
14 /** @file */
15
16 #ifndef LOG4CPLUS_STREAMS_HEADER_
17 #define LOG4CPLUS_STREAMS_HEADER_
18
19 #include <log4cplus/config.h>
20 #include <log4cplus/tstring.h>
21
22 #include <iostream>
23 #ifdef HAVE_SSTREAM
24 # include <sstream>
25 # define LOG4CPLUS_STREAM_NAMESPACE std
26 #elif defined(HAVE_STRSTREAM)
27 # include <strstream>
28 # if defined(__DECCXX) && !defined(__USE_STD_IOSTREAM)
29 # define LOG4CPLUS_STREAM_NAMESPACE
30 # else
31 # define LOG4CPLUS_STREAM_NAMESPACE std
32 # endif
33 #elif defined(HAVE_STRSTREAM_H)
34 # include <strstream.h>
35 # define LOG4CPLUS_STREAM_NAMESPACE
36 #else
37 # error "There doesn't appear to be any s*stream headers!!"
38 #endif
39
40 #ifdef UNICODE
41 namespace log4cplus {
42 typedef LOG4CPLUS_STREAM_NAMESPACE::wostream tostream;
43 typedef LOG4CPLUS_STREAM_NAMESPACE::wistream tistream;
44 typedef LOG4CPLUS_STREAM_NAMESPACE::wostringstream tostringstream;
45 static tostream &tcout = LOG4CPLUS_STREAM_NAMESPACE::wcout;
46 static tostream &tcerr = LOG4CPLUS_STREAM_NAMESPACE::wcerr;
47 }
48
49 LOG4CPLUS_EXPORT log4cplus::tostream& operator <<(log4cplus::tostream&, const char* psz );
50
51 #else
52 namespace log4cplus {
53 typedef LOG4CPLUS_STREAM_NAMESPACE::ostream tostream;
54 typedef LOG4CPLUS_STREAM_NAMESPACE::istream tistream;
55 static tostream &tcout = LOG4CPLUS_STREAM_NAMESPACE::cout;
56 static tostream &tcerr = LOG4CPLUS_STREAM_NAMESPACE::cerr;
57 #ifdef HAVE_SSTREAM
58 typedef LOG4CPLUS_STREAM_NAMESPACE::ostringstream tostringstream;
59 #else
60 class tostringstream : public LOG4CPLUS_STREAM_NAMESPACE::ostrstream {
61 public:
62 tstring str() {
63 char *ptr = LOG4CPLUS_STREAM_NAMESPACE::ostrstream::str();
64 if(ptr) {
65 return tstring(ptr, pcount());
66 }
67 else {
68 return tstring();
69 }
70 }
71 };
72
73 #endif // HAVE_SSTREAM
74 }
75 #endif // UNICODE
76
77 #endif // LOG4CPLUS_STREAMS_HEADER_
syntax highlighted by Code2HTML, v. 0.9.1