Loading...
Searching...
No Matches
CategoryStream.hh
Go to the documentation of this file.
/*
* CategoryStream.hh
*
* Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
* Copyright 2001, Bastiaan Bakker. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/
#ifndef _LOG4SHIB_CATEGORYSTREAM_HH
#define _LOG4SHIB_CATEGORYSTREAM_HH
#include <log4shib/Portability.hh>
#include <log4shib/Priority.hh>
#ifdef LOG4SHIB_HAVE_SSTREAM
#include <sstream>
#endif
namespace log4shib {
class LOG4SHIB_EXPORT Category;
class LOG4SHIB_EXPORT CategoryStream;
LOG4SHIB_EXPORT CategoryStream& eol (CategoryStream& os);
class LOG4SHIB_EXPORT CategoryStream {
public:
CategoryStream(Category& category, Priority::Value priority);
~CategoryStream();
inline Category& getCategory() const { return _category; };
inline Priority::Value getPriority() const throw() {
return _priority;
};
void flush();
template<typename T> CategoryStream& operator<<(const T& t) {
if (getPriority() != Priority::NOTSET) {
if (!_buffer) {
if (!(_buffer = new std::ostringstream)) {
// XXX help help help
}
}
(*_buffer) << t;
}
return *this;
}
private:
Category& _category;
Priority::Value _priority;
std::ostringstream* _buffer;
public:
typedef CategoryStream& (*cspf) (CategoryStream&);
CategoryStream& operator << (cspf);
LOG4SHIB_EXPORT friend CategoryStream& eol (CategoryStream& os);
};
}
#endif // _LOG4SHIB_CATEGORYSTREAM_HH
LOG4SHIB_EXPORT
#define LOG4SHIB_EXPORT
Definition Export.hh:11
Portability.hh
Priority.hh
log4shib::CategoryStream
This class enables streaming simple types and objects to a category.
Definition CategoryStream.hh:33
log4shib::CategoryStream::cspf
CategoryStream &(* cspf)(CategoryStream &)
Definition CategoryStream.hh:92
log4shib::CategoryStream::operator<<
CategoryStream & operator<<(const T &t)
Stream in arbitrary types and objects.
Definition CategoryStream.hh:74
log4shib::CategoryStream::getPriority
Priority::Value getPriority() const
Returns the priority for this stream.
Definition CategoryStream.hh:59
log4shib::CategoryStream::getCategory
Category & getCategory() const
Returns the destination Category for this stream.
Definition CategoryStream.hh:53
log4shib::CategoryStream::CategoryStream
CategoryStream(Category &category, Priority::Value priority)
Construct a CategoryStream for given Category with given priority.
Definition CategoryStream.cpp:21
log4shib::CategoryStream::eol
LOG4SHIB_EXPORT friend CategoryStream & eol(CategoryStream &os)
eol manipulator
Definition CategoryStream.cpp:43
log4shib::Category
This is the central class in the log4j package.
Definition Category.hh:32
log4shib::Priority::NOTSET
@ NOTSET
Definition Priority.hh:78
log4shib::Priority::Value
int Value
The type of Priority Values.
Definition Priority.hh:84
std::ostringstream
Definition Portability.hh:38
log4shib
The top level namespace for all 'Log for C++' types and classes.
Definition AbortAppender.hh:16
log4shib::eol
LOG4SHIB_EXPORT CategoryStream & eol(CategoryStream &os)
eol manipulator
Definition CategoryStream.cpp:43