Boost Users :
Subject: [Boost-users] [iostreams] Is it possible for a sink to get notified when the stream is closed?
From: Bob van Manen (bobm75_at_[hidden])
Date: 2009-03-27 13:43:48
I am trying out the Boost iostreams library to build a sink, text sent to
this sink is split up in to lines of text and each line is then being send
over to our logging server (the function I'm calling to do this is static).
So far I've built the write method as mentioned in the documentation for my
sink, and push all the characters I receive in a buffer inside my sink
class. Then I look for the end of line characters and figure out the lines
of text. The problem I'm having is when there is no end of line character
and the stream gets closed.
Is there a way to get notified when the stream gets closed? Is there a
better way to do this?
Here is the code I have:
typedef char char_type;
typedef boost::iostreams::sink_tag category;
std::streamsize write(const char* s, std::streamsize n)
// loop over buffer and find end of lines, send them to logging
// close is never called
class logging_stream : public boost::iostreams::stream<logging_sink>
s << "Hello World";
Thank you for your help,
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net