00001
00002
00003
00004
00005
00006
00007
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
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