473,506 Members | 17,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

std::streambuf::setp and std::streambuf::epptr()

I am trying to empty and reset my internal buffer in my derived sync method.

Am I correct in assuming I can call setp( std::streambuf::pbase(),
std::streambuf::pbase()); to reset the internal buffer?

Also, I am unsure whether the pointer returned by epptr() is supposed to
point just beyond the end of the sequence or at the last element of the
sequence? As such, should the second argument to my setp call be
std::streambuf::pbase() + 1?

Thanks. I've got a book on streams coming for Christmas by the way. Yay!
References on the topic seem to be scarce, yet it is such a huge topic. I
guess most people ignore it as much as they can.
Dec 12 '07 #1
1 2930
On Dec 12, 9:12 am, "Christopher Pisz" <some...@somewhere.netwrote:
I am trying to empty and reset my internal buffer in my
derived sync method.
Am I correct in assuming I can call setp( std::streambuf::pbase(),
std::streambuf::pbase()); to reset the internal buffer?
It depends on what you want to do. If you simply want to clear
the buffer, making sure that the next attempt to write will end
up calling overflow() (where presumably, you'll reinitialize
it), then setting both pointers to NULL is the simplest
solution. If you want to initialize a new (empty) buffer, the
first pointer should be the address of the buffer, and the
second the address one past the end of the buffer.
Also, I am unsure whether the pointer returned by epptr() is
supposed to point just beyond the end of the sequence or at
the last element of the sequence?
One past the end. epptr() - pbase() is the length of the
buffer.
As such, should the second argument to my setp call be
std::streambuf::pbase() + 1?
That would provide a buffer of size 1.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Dec 12 '07 #2

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

Similar topics

9
2695
by: Fred Ma | last post by:
Hello, I posted previously under the thread: How to break this up into streambuf/ostream I've asked our library to get "C++ IOStreams and Locales..." by A. Langer et al. Meantime, I've...
6
1571
by: William Payne | last post by:
Hi, I have a function declared as: void foo(const std::string& s, std::ostream& verbose_output); I want foo() to write a lot of data to the ostream if it's a valid stream. If it's valid or not...
1
2058
by: Peter Jansson | last post by:
Dear newsgroup, I have implemented a class that inherits from std::streambuf (in order to create a stream for some specialized I/O). In the constructor, I have the following code (bufferSize is...
7
9973
by: Lee | last post by:
Hi, I'm a stream virgin and am attempting to output strings to a file. My approach is to write the string initially to a 'stringstream' and only when complete write the stringstream to the file...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7023
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7479
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...
0
5617
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,...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
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...
0
3188
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...
1
757
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
410
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...

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.