CategoryStream.cpp
Go to the documentation of this file.
1 /*
2  * CategoryStream.cpp
3  *
4  * Copyright 2001, LifeLine Networks BV (www.lifeline.nl). All rights reserved.
5  * Copyright 2001, Bastiaan Bakker. All rights reserved.
6  *
7  * See the COPYING file for the terms of usage and distribution.
8  */
9 
10 #include "PortabilityImpl.hh"
11 
12 #ifdef LOG4CPP_HAVE_UNISTD_H
13 # include <unistd.h>
14 #endif
15 
17 #include <log4cpp/Category.hh>
18 
19 namespace log4cpp {
20 
22  _category(category),
23  _priority(priority),
24  _buffer(NULL) {
25  }
26 
28  flush();
29  }
30 
32  if (_buffer) {
34  delete _buffer;
35  _buffer = NULL;
36  }
37  }
38 
40  {
41  if (getPriority() != Priority::NOTSET) {
42  if (!_buffer) {
43  if (!(_buffer = new std::ostringstream)) {
44  // XXX help help help
45  }
46  }
47  (*_buffer) << t;
48  }
49  return *this;
50  }
51 
52  std::streamsize CategoryStream::width(std::streamsize wide ) {
53  if (getPriority() != Priority::NOTSET) {
54  if (!_buffer) {
55  if (!(_buffer = new std::ostringstream)) {
56  // XXX help help help
57  }
58  }
59  }
60  return _buffer->width(wide);
61  }
63  return (*pf)(*this);
64  }
66  if (os._buffer) {
67  os.flush();
68  }
69  return os;
70  }
72  if (os._buffer) {
73  os._buffer->setf(std::ios::left);
74  }
75  return os;
76  }
77 }
78 
79 // MSVC6 bug in member templates instantiation
80 #if defined(_MSC_VER) && _MSC_VER < 1300
81 namespace
82 {
83  struct dummy
84  {
85  void instantiate()
86  {
87  using namespace log4cpp;
88 
90  t << static_cast<const char*>("")
92  << static_cast<char>(0)
93  << static_cast<unsigned char>(0)
94  << static_cast<signed char>(0)
95  << static_cast<short>(0)
96  << static_cast<unsigned short>(0)
97  << static_cast<int>(0)
98  << static_cast<unsigned int>(0)
99  << static_cast<long>(0)
100  << static_cast<unsigned long>(0)
101  << static_cast<float>(0.0)
102  << static_cast<double>(0.0)
103 #if LOG4CPP_HAS_WCHAR_T != 0
104  << std::wstring()
105 #endif
106  << std::string();
107  }
108  };
109 }
110 #endif
CategoryStream &(* cspf)(CategoryStream &)
virtual void log(Priority::Value priority, const char *stringFormat,...)
Definition: Category.cpp:267
static Category & getInstance(const std::string &name)
Definition: Category.cpp:35
CategoryStream(Category &category, Priority::Value priority)
Category & getCategory() const
CategoryStream & operator<<(const T &t)
LOG4CPP_EXPORT friend CategoryStream & eol(CategoryStream &os)
LOG4CPP_EXPORT CategoryStream & left(CategoryStream &os)
std::streamsize width(std::streamsize wide)
std::ostringstream * _buffer
Priority::Value getPriority() const
LOG4CPP_EXPORT friend CategoryStream & left(CategoryStream &os)


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:10:00