Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//--------------------------------------------------------------------------
// File and Version Information:
// $Id: ErrStreamBuffer.cc,v 1.1.1.1 2005/03/29 17:04:19 steinke Exp $
//
// Description:
// ErrStreamBuffer implementation
//
// Environment:
// Software developed for the BaBar Detector at the SLAC B-Factory.
//
// Author List:
// Gregory Dubois-Felsmann (originator)
//
// Copyright Information:
// Copyright (C) 2004 California Institute of Technology
//
//------------------------------------------------------------------------
//-----------------------
// This Class's Header --
//-----------------------
#include "ErrLogger/ErrStreamBuffer.hh"
//-----------------
// C/C++ Headers --
//-----------------
//-------------------------------
// Collaborating Class Headers --
//-------------------------------
#include "ErrLogger/ErrLog.hh"
using std::ends;
//-----------------------------------------------------------------------
// Local Macros, Typedefs, Structures, Unions and Forward Declarations --
//-----------------------------------------------------------------------
// ----------------------------------------
// -- Public Function Member Definitions --
// ----------------------------------------
//----------------
// Constructors --
//----------------
ErrStreamBuffer::ErrStreamBuffer( ErrLog* logger )
: ErrStream( 0, logger )
{
// Initialization-order constraints prohibited establishing the
// connection between the base class stream pointer and the ostringstream
// above. Instead we set it now that we know the ostringstream is initialized.
setStream( &_bufferStream );
}
//--------------
// Destructor --
//--------------
ErrStreamBuffer::~ErrStreamBuffer()
{ }
//-------------
// Methods --
//-------------
void
ErrStreamBuffer::doEndmsg()
{
if ( logger() != 0 ) {
// We require that we be tied back to a real ErrLog implementation.
// (If not, we do nothing except reset the buffer.)
// Make sure the buffer is null-terminated.
_bufferStream << ends;
// Extract the string from the buffer and hand it to the ErrLog.
// Note that this freezes the buffer and relinquishes ownership of the
// string.
const char* text = _bufferStream.str().c_str();
loggerEndmsg( text );
// Unfreeze the buffer.
// _bufferStream.rdbuf()->freeze(false) ;
}
// Reset the buffer for the next message.
_bufferStream.clear() ;
_bufferStream.seekp(0) ;
}