Questions tagged [streambuf]

std::streambuf is the stream buffer type used by C++ iostreams.

C++ iostreams use a stream buffer to do any buffering of characters, manage the stream position and transport characters to/from an external device such as a file.

Use this tag for questions about std::streambuf, the wide-character equivalent std::wstreambuf, or the class template std::basic_streambuf. The tag might also be relevant.

152 questions
3
votes
0 answers

Boost.Asio streambuf: How to copy data in streambuf

Possible Duplicate: Copy a streambuf's contents to a string Recently I am working around boost::asio::streambuf. Because of my poor English I cannot express what I mean. So first, please look at the code below. class bar { public: int…
xps_l502
  • 107
  • 1
  • 9
2
votes
2 answers

How to create customized ostream / streambuf classes for flexible output stream?

I found quite some info on output redirection, creation of streambuffers and ostream classes, but I did not manage to apply this succesfully yet for my purpose. This post has become quite lengthy because I wanted to describe my step by step…
f ckx
  • 49
  • 1
  • 6
2
votes
1 answer

Boost Asio: Strange when use streambuf and async_write in mutl-thread

My program has a buffer when sending data. Instead of directly calling async_write every time for send small packets, try to make the send method return quickly, use streambuf as the sending buffer, and try to send large packets. The problem…
junya
  • 21
  • 2
2
votes
3 answers

std::istreambuf_iterator "peek" with std::ifstream

When dealing with streams of data, I prefer to write the code in terms of templates and iterators. Often I need to "peek" at the next character. In order to make the code be able to deal no-bidirectional iterators, I have a snippet which looks like…
Evan Teran
  • 87,561
  • 32
  • 179
  • 238
2
votes
1 answer

Return boost streambuf from function

I am trying to wrap up a code that read gz files into a function, source code is taken from https://techoverflow.net/2013/11/03/c-iterating-lines-in-a-gz-file-using-boostiostreams/ My…
pythonRcpp
  • 2,042
  • 6
  • 26
  • 48
2
votes
1 answer

Using Boost asio to receive commands and execute them

I'm trying to make a boost server, which will receive commands and do certain things. Now I would like to create a function, that will receive a file and save it to a specific location. The problem is with serialization. I don't know how can I…
k-krakowski
  • 43
  • 1
  • 7
2
votes
2 answers

how read a stream into a Concurrency::streams::streambuf buffer; in C++

I'm working with cpprestsdk in a project as a server. I need to read the Body of a put request. the documentation uses message.body().read_to_end(buffer); I tried this without success. void MyProject::handle_post(http_request message) { …
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
2
votes
4 answers

Reading integers from a memory mapped formatted file

I have memory mapped a large formatted (text) file containing one integer per line like so: 123 345 34324 3232 ... So, I have a pointer to the memory at the first byte and also a pointer to the memory at the last byte. I am trying to read all those…
user153062
2
votes
1 answer

Is it safe to manipulated streambuf after doing boost::asio::async_read?

I know it's not safe to manipulated streambuf while async_write working as stated by asio author on boost mailing list. What I want to know is, is it safe to manipulated streambuf after async_read? Example: async_read(socket_, recv_streambuf_,…
flamemyst
  • 1,187
  • 7
  • 10
2
votes
3 answers

asio::async_read_until: robust and graceful way of handling multiple lines

I'm using asio::async_read_until with '\n' delimiter to support a TCP client that fetches character data from a server. This server continuously sends '\n' terminated lines; precisely, it can write at once either single lines or a concatenated…
mamahuhu
  • 311
  • 2
  • 10
2
votes
0 answers

Overloading std::streambuf for escaping data

I have an external library which is able to write a bunch of data by passing it a std::ostream* pointer. It writes in binary format I want to write this data inside a text file, which contains other stuff, by converting it to hexadecimal or…
galinette
  • 8,896
  • 2
  • 36
  • 87
2
votes
2 answers

std::ostream interface to an OLE IStream

I have a Visual Studio 2008 C++ application using IStreams. I would like to use the IStream connection in a std::ostream. Something like this: IStream* stream = /*create valid IStream instance...*/; IStreamBuf< WIN32_FIND_DATA > sb( stream…
PaulH
  • 7,759
  • 8
  • 66
  • 143
2
votes
1 answer

How to get part of a std::string into a streambuf without copying?

I'm using boost asio a lot lately and I find that I'm working with std::strings and asio::streambufs quite a bit. I find that I'm trying to get data back and forth between streambufs and strings a lot as part of parsing network data. In general, I…
Ted Middleton
  • 6,859
  • 10
  • 51
  • 71
2
votes
1 answer

Incompatible destructor compiler warning when from inheriting from std::streambuf

I get a ICL compiler warning when inheriting from std::streambuf saying that the destructor is not compatible, any ideas what I'm doing wrong here? Making it a virtual destructor does not work either. warning #809: exception specification for…
user152949
2
votes
1 answer

What is wrong with my implementation of overflow()?

I am trying to implement a stream buffer and I'm having trouble with making overflow() work. I resize the buffer by 10 more characters and reset the buffer using setp. Then I increment the pointer back where we left off. For some reason the output…
template boy
  • 10,230
  • 8
  • 61
  • 97