RE: [boost] Re: Re: Re: Iostreams Question: Bestwaytooutputtowin32debugger\outwindow ?

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Jonathan Turkanis Sent: Monday, February 28, 2005 10:26 PM To: boost@lists.boost.org Subject: [boost] Re: Re: Re: Iostreams Question: Bestwaytooutputtowin32debugger\outwindow ?
Reid Sweatman wrote:
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Jonathan Turkanis
Okay Brian,
The following apparently works, but when OutputDebugString is called I don't see any output. I'm not sure if the previous version worked or not; I've run out of time for now.
I didn't see most of this thread, and may be totally off-base here, but you need to use a tool that can intercept the output from OutputDebugString(), as that function assumes there's a debugger attached to its process; if there's no attached debugger, it attempts to use the Windows system debugger, which must be both installed and active. However, I like SysInternals' DebugView, both because it's well-written and easy to use, and because it's free. Very lightweight alternative to invoking a full debugger when that would be overkill. It can do kernel-mode debugging, too, which is a major plus, if you need that; got a copy running on my other machine right now. www.sysinternals.com. And if this is not to the point, or you already know all this, bear in mind that I only had this post available, and skimmed it pretty cursorily, and please just disregard my post.
Thanks for the info.
The main point of the thread was to show how to write a sink with a built- in line-ending filter, so the user doesn't always have to add one explicitly.
Jonathan
[Brian Braatz Writes:] Yes. (sorry if I got off base)- the question relevant to boost \ iostreams was this- Given a device which has different line termination than \n, how do you handle it in such a way that allows for that device to be able to interpret std::endl so it works as the user would expect. (and so the code you write using the sink makes sense to the user) I happen to be using win32's outputdebugstring, but the same issue applies for "printing" to a windows edit control. The same issue might also apply to a daisy wheel printer. And, personally, I think boost should support daisy wheel printers (grin)....

Brian Braatz wrote:
On Behalf Of Jonathan Turkanis
The main point of the thread was to show how to write a sink with a built-in line-ending filter, so the user doesn't always have to add one explicitly.
Jonathan
[Brian Braatz Writes:] Yes. (sorry if I got off base)- the question relevant to boost \ iostreams was this-
You weren't off base -- I was summarizing the thread for Reid Sweatman, who asked what the thread was about.
Given a device which has different line termination than \n, how do you handle it in such a way that allows for that device to be able to interpret std::endl so it works as the user would expect. (and so the code you write using the sink makes sense to the user)
I happen to be using win32's outputdebugstring, but the same issue applies for "printing" to a windows edit control. The same issue might also apply to a daisy wheel printer. And, personally, I think boost should support daisy wheel printers (grin)....
I think this accurately describes the question -- now here's my question: are you satisfied with my answer? I had to correct my first answer, so let me restate it for clarity: 1. Implement the device as if it had no special line-endings requirements. If the final device will be called xxx, you might call this intermediate class xxx_impl. 2. Your final device should have a member yyy of type detail::chain<mode>. If you want to avoid details, a member of type filtering_stream<mode> or filtering_streambuf<mode> will do, but you have to wrap them so they are copy-constructible, perhaps using share_ptr< filtering_streambuf<mode> >. 3. In the constructor of your device, push a newline filter onto yyy's chain, then push an instance of xxx_impl. 4. implement the i/o functions (read, write, seek, ...) by delegation to yyy. For example: struct win32_debug_sink_impl : boost::iostreams::sink { ... }; struct win32_debug_sink : boost::iostreams::sink { win32_debug_sink() { using namespace boost::iostreams; chain_.push(newline_filter(newline::windows)); chain_.push(win32_debug_sink_impl); } void write(const char* s, std::streamsize n) { chain_.write(x, n); } boost::iostreams::detail::chain<output> chain_; }; Best, Jonathan
participants (2)
-
Brian Braatz
-
Jonathan Turkanis