Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CategoryStream.hh

Go to the documentation of this file.
00001 /*
00002  * CategoryStream.hh
00003  *
00004  * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
00005  * Copyright 2001, Bastiaan Bakker. All rights reserved.
00006  *
00007  * See the COPYING file for the terms of usage and distribution.
00008  */
00009 
00010 #ifndef _LOG4CPP_CATEGORYSTREAM_HH
00011 #define _LOG4CPP_CATEGORYSTREAM_HH
00012 
00013 #include <log4cpp/Portability.hh>
00014 #include <log4cpp/OstringStream.hh>
00015 #include <log4cpp/Priority.hh>
00016 
00017 namespace log4cpp {
00018 
00019     class LOG4CPP_EXPORT Category;
00020 
00025     class LOG4CPP_EXPORT CategoryStream {
00026         public:
00027 
00032         typedef enum {
00033             ENDLINE
00034         } Separator;
00035 
00042         CategoryStream(Category& category, Priority::Value priority);
00043 
00047         ~CategoryStream();
00048         
00053         inline Category& getCategory() const { return _category; };
00054 
00059         inline Priority::Value getPriority() const throw() { 
00060             return _priority; 
00061         };
00062 
00070         CategoryStream& operator<<(Separator separator);
00071 
00076         void flush();
00077 
00083         template<typename T> CategoryStream& operator<<(const T& t) {
00084             if (getPriority() != Priority::NOTSET) {
00085                 if (!_buffer) {
00086                     if (!(_buffer = new OstringStream)) {
00087                         // XXX help help help
00088                     }
00089                 }
00090                 (*_buffer) << t;
00091             }
00092             return *this;
00093         }
00094         
00095         private:
00096         Category& _category;
00097         Priority::Value _priority;
00098         OstringStream* _buffer;
00099     };
00100 
00101 }
00102 #endif // _LOG4CPP_CATEGORYSTREAM_HH

Generated on Thu Aug 15 00:00:20 2002 for log4cpp by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002