473,569 Members | 3,043 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unbuffered basic_streambuf Implementation

Is this even possible? I've found some references to specific "unbuffered "
type methods that exist in older incarnations of basic_streambuf but not in
newer ones.

Info please. :P
Jul 22 '05 #1
1 2874

<ye**@twenty.ne t> wrote in message news:EJeYc.5428 4$S55.26683@clg rps12...
Is this even possible? I've found some references to specific "unbuffered "
type methods that exist in older incarnations of basic_streambuf but not in
newer ones.


It's easy to write a stream buffer which performs unbuffered output. Simply
refrain from using the put-area pointer manipulation function setp, etc., and
override overflow (and possibly xsputn) to write directly to the underlying data
sink.

For input, you need a small buffer to support peeking at the next character
without consuming it and putting back a character that has already been
consumed.

Angelika Langer and Kluas Kreft present an unbuffered streambuf implementation
in their text 'Standard C++ Iostreams and Locales', p. 299. Their implementation
uses a buffer of size 1. I believe I found that this implementation does not
work with STLPort, which routinely peeks at the next character internally so
that the putback buffer is always full. So for 'unbuffered' input I always use a
buffer of size at least 2.

I have written an iostreams library which makes it easy to define new streams
and stream buffers. It's up for review for includion in Boost right now. I
encourage anyone who is interested to participate in the review process on the
Boost developers list (see http://www.boost.org/more/mailing_lists.htm#main).

Jonathan
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
5143
by: Rich | last post by:
Does anyone know the correct way of opening an unbuffered output file using STL? I attempted: ofstream myfile("fname.txt", ios::binary); myfile.setbuf(NULL, 0); and I was informed that setbuf is not a member of
3
3440
by: | last post by:
I can not seem to get this to compile with either gcc 3.4 or MSVC++ .NET 2003... (source follows first): ---= BEGIN MyStreamBuffer.h =--- // #IFDEF redundancy left out. #include <streambuf> template< class MyElem > class MyStreamBuffer : public std::basic_streambuf< MyElem > { protected:
0
1249
by: | last post by:
I was hoping that someone (after my own failures) might post a very mininal unbuffered derivation of basic_streambuf. My problem is that (even leaving the buffer pointers to their defaults) uflow() never gets called unless I define an underflow(). overflow() works as expected but I'm just trying to start small and I can't even get that done....
3
3164
by: Steven T. Hatton | last post by:
I'm a bit confused about a statement in TC++ST §13.10. It's in reference to this example: /* The following code example is taken from the book * "The C++ Standard Library - A Tutorial and Reference" * by Nicolai M. Josuttis, Addison-Wesley, 1999 * * (C) Copyright Nicolai M. Josuttis 1999. * Permission to copy, use, modify, sell and...
11
3235
by: Lonnie Princehouse | last post by:
>From the cmd shell on both Windows 2k and XP, I'm getting this weird syntax error in conjunction with the unbuffered flag. It works fine without -u. Has anyone else encountered it? This didn't happen with Python 2.2... C:\>python -u Python 2.4.1 (#65, Mar 30 2005, 09:13:57) on win32 Type "help", "copyright", "credits" or "license"...
4
4162
by: pank7 | last post by:
hi everyone, I have a program here to test the file IO(actually output) with buffer turned on and off. What I want to see is that there will be obvious differece in time. Here I have an input file scales 1.1M, what I did is just copy it to another output file(ten times). But I don't think I see any difference. My file system is ext3, with...
2
1749
by: sri | last post by:
Dear All, I would like to implement file buffer class to make avialable buffering mechanism to ifstream or own customized file stream. My question is what are the semantics for seekoff, overflow, and underflow. When I see MS VC++6.0 STL code's basic_filebuf implementation, I observed that it is not maintaining any buffering mechanism,...
1
4628
by: Yang Zhang | last post by:
Hi, is there any way to get unbuffered stdout/stderr without relying on the -u flag to python or calling .flush() on each print (including indirect hacks like replacing sys.stdout with a wrapper that succeeds each write() with a flush())? Thanks in advance! -- Yang Zhang http://www.mit.edu/~y_z/
8
14722
by: zeeshan708 | last post by:
what is the difference between the buffered and unbuffered stream ??(e.g we say that cout is buffered and cerr is unbuffered stream) does that mean that the output sent to buffered stream have to go through a buffer (i.e a temporary storage registers) ,, if so then what is the big deal in unbuffered stream??
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.