# streams.h

Go to the documentation of this file.

    00001 // Module:  Log4CPLUS
    00002 // File:    streams.h
    00003 // Created: 4/2003
    00004 // Author:  Tad E. Smith
    00005 //
    00006 //
    00007 // Copyright (C) Tad E. Smith  All rights reserved.
    00008 //
    00009 // This software is published under the terms of the Apache Software
    00010 // License version 1.1, a copy of which has been included with this
    00011 // distribution in the LICENSE.APL file.
    00012 //
    00013
    00016 #ifndef LOG4CPLUS_STREAMS_HEADER_
    00017 #define LOG4CPLUS_STREAMS_HEADER_
    00018
    00019 #include <log4cplus/config.h>
    00020 #include <log4cplus/tstring.h>
    00021
    00022 #include <iostream>
    00023 #ifdef HAVE_SSTREAM
    00024 #  include <sstream>
    00025 #  define LOG4CPLUS_STREAM_NAMESPACE std
    00026 #elif defined(HAVE_STRSTREAM)
    00027 #  include <strstream>
    00028 #  if defined(__DECCXX) && !defined(__USE_STD_IOSTREAM)
    00029 #    define LOG4CPLUS_STREAM_NAMESPACE
    00030 #  else
    00031 #    define LOG4CPLUS_STREAM_NAMESPACE std
    00032 #  endif
    00033 #elif defined(HAVE_STRSTREAM_H)
    00034 #  include <strstream.h>
    00035 #  define LOG4CPLUS_STREAM_NAMESPACE
    00036 #else
    00037 #  error "There doesn't appear to be any s*stream headers!!"
    00038 #endif
    00039
    00040 #ifdef UNICODE
    00041     namespace log4cplus {
    00042         typedef LOG4CPLUS_STREAM_NAMESPACE::wostream tostream;
    00043         typedef LOG4CPLUS_STREAM_NAMESPACE::wistream tistream;
    00044         typedef LOG4CPLUS_STREAM_NAMESPACE::wostringstream tostringstream;
    00045         static tostream &tcout = LOG4CPLUS_STREAM_NAMESPACE::wcout;
    00046         static tostream &tcerr = LOG4CPLUS_STREAM_NAMESPACE::wcerr;
    00047     }
    00048
    00049 LOG4CPLUS_EXPORT log4cplus::tostream& operator <<(log4cplus::tostream&, const char* psz );
    00050
    00051 #else
    00052     namespace log4cplus {
    00053         typedef LOG4CPLUS_STREAM_NAMESPACE::ostream tostream;
    00054         typedef LOG4CPLUS_STREAM_NAMESPACE::istream tistream;
    00055         static tostream &tcout = LOG4CPLUS_STREAM_NAMESPACE::cout;
    00056         static tostream &tcerr = LOG4CPLUS_STREAM_NAMESPACE::cerr;
    00057 #ifdef HAVE_SSTREAM
    00058         typedef LOG4CPLUS_STREAM_NAMESPACE::ostringstream tostringstream;
    00059 #else
    00060         class tostringstream : public LOG4CPLUS_STREAM_NAMESPACE::ostrstream {
    00061         public:
    00062             tstring str() {
    00063                 char *ptr = LOG4CPLUS_STREAM_NAMESPACE::ostrstream::str();
    00064                 if(ptr) {
    00065                     return tstring(ptr, pcount());
    00066                 }
    00067                 else {
    00068                     return tstring();
    00069                 }
    00070             }
    00071         };
    00072
    00073 #endif // HAVE_SSTREAM
    00074     }
    00075 #endif // UNICODE
    00076
    00077 #endif // LOG4CPLUS_STREAMS_HEADER_
    00078