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/Priority.hh>
00015
#ifdef LOG4CPP_HAVE_SSTREAM
00016
#include <sstream>
00017
#endif
00018
00019
namespace log4cpp {
00020
00021 class LOG4CPP_EXPORT Category;
00022
00027 class LOG4CPP_EXPORT CategoryStream {
00028
public:
00029
00034 typedef enum {
00035 ENDLINE
00036 } Separator;
00037
00044 CategoryStream(Category& category, Priority::Value priority);
00045
00049 ~CategoryStream();
00050
00055 inline Category& getCategory()
const {
return _category; };
00056
00061 inline Priority::Value getPriority() const throw() {
00062
return _priority;
00063 };
00064
00072 CategoryStream& operator<<(Separator separator);
00073
00078
void flush();
00079
00085 template<
typename T> CategoryStream& operator<<(
const T& t) {
00086
if (getPriority() != Priority::NOTSET) {
00087
if (!_buffer) {
00088
if (!(_buffer =
new std::ostringstream)) {
00089
00090 }
00091 }
00092 (*_buffer) << t;
00093 }
00094
return *
this;
00095 }
00096
00097
private:
00098
Category& _category;
00099 Priority::Value _priority;
00100
std::ostringstream* _buffer;
00101 };
00102
00103 }
00104
#endif // _LOG4CPP_CATEGORYSTREAM_HH