Boost logo

Boost Users :

Subject: [Boost-users] boost::asio buffer questions, and boost::bind question
From: Littlefield, Tyler (tyler_at_[hidden])
Date: 2012-09-06 23:17:38


Hello:
I had a couple of questions.
I'm really confused about how the buffers in boost::asio work. I'm using
async_read_until, and it wants a streambuf. so I looked at that, and
it's a typedef for basic_streambuf. so I'm looking at how to set one of
these up, and stackoverflow shows something like:
   boost::asio::streambuf streamBuffer;
   boost::asio::streambuf::mutable_buffers_type mutableBuffer =
       streamBuffer.prepare(max_length);
so I'm curious what the mutable buffer is, and how it wraps around
streambuf. I'm also curious how people generally handle buffers in their
classes. I have a Session class, which will hold a buffer of data to be
read, so that when I call HandleRead, it can just look at that buffer
for the last line read in. Do I need to store a mutable_buffer and a
streambuf? Or is the streambuf ok (and can I pull the data out of it
somehow). Also, in that article it shows that it wraps the mutableBuffer
in a boost::asio::buffer(what's the point in that?)

Finally, my boost::bind question.
I was curious how that worked out. When I use _1, _2 as placeholders,
does the templating get substituted in somehow? Does it somehow
construct an object that just has a () operator to take arguments? Also,
if I wanted to write something to let me pull in the errors like
placeholders, how do placeholders work/get translated out?
Thanks,

-- 
Take care,
Ty
http://tds-solutions.net
The aspen project: a barebones light-weight mud engine:
http://code.google.com/p/aspenmud
He that will not reason is a bigot; he that cannot reason is a fool; he that dares not reason is a slave.

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