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/Export.hh"
00015 #include "log4cpp/OstringStream.hh"
00016 #include "log4cpp/Priority.hh"
00017
00018 namespace log4cpp {
00019
00020 class LOG4CPP_EXPORT Category;
00021
00026 class LOG4CPP_EXPORT CategoryStream {
00027 public:
00028
00033 typedef enum {
00034 ENDLINE
00035 } Separator;
00036
00043 CategoryStream(Category& category, Priority::Value priority);
00044
00048 ~CategoryStream();
00049
00054 inline Category& getCategory() const { return _category; };
00055
00060 inline Priority::Value getPriority() const throw() {
00061 return _priority;
00062 };
00063
00071 CategoryStream& operator<<(Separator separator);
00072
00077 void flush();
00078
00084 template<typename T> CategoryStream& operator<<(const T& t) {
00085 if (getPriority() != Priority::NOTSET) {
00086 if (!_buffer) {
00087 if (!(_buffer = new OstringStream)) {
00088
00089 }
00090 }
00091 (*_buffer) << t;
00092 }
00093 return *this;
00094 }
00095
00096 private:
00097 Category& _category;
00098 Priority::Value _priority;
00099 OstringStream* _buffer;
00100 };
00101
00102 }
00103 #endif // _LOG4CPP_CATEGORYSTREAM_HH