streambuf Questions
3
Solved
I have the following implementation based on e.g. this question and answer
struct membuf : std::streambuf
{
membuf(char* begin, char* end)
{
this->setg(begin, begin, end);
}
protected:
vi...
11
Solved
Apparently boost::asio::async_read doesn't like strings, as the only overload of boost::asio::buffer allows me to create const_buffers, so I'm stuck with reading everything into a streambuf.
Now I ...
Countess asked 18/5, 2009 at 13:7
1
Solved
I'm trying to make a class that will be both input and output stream (like std::cout and std::cin ). I tried to overload operator << and >>, but then, I understood that writing such cod...
5
I've been writing a binary version of iostreams. It essentially allows you to write binary files, but gives you much control over the format of the file. Example usage:
my_file << binary::u3...
3
Solved
I'd like an interface for writing to an automatically resizing array. One way to do this is with a generic std::ostream *.
Then consider if ostringstream is the target:
void WritePNG(ostream *out...
1
Solved
From http://www.cplusplus.com/reference/ios/ios/rdbuf/:
Some derived stream classes (such as stringstream and fstream) maintain their own internal stream buffer, to which they are associated on co...
2
Solved
I am working on a project that uses libzip. I'm working in c++14 and I wrote a tiny wrapper around libzip to make my life easier.
I have an std::ostream object built around custom class that inher...
1
Solved
I would like to write a logging library of my own that provides abstraction for wherever the log entries are sent to.
The IO library of C++ already provides that kind of abstraction with std::stri...
Conditional asked 20/1, 2017 at 23:14
1
Solved
I would like to copy data efficiently between std::streambuf instances. That is, I would like to shovel blocks of data between them, as opposed to perform character-by-character copying. For exampl...
2
Solved
What is the difference between istreambuf_iterator and istream_iterator?
And in general what is the difference between streams and streambufs?
I really can't find any clear explanation for this so ...
1
Solved
I have a serialized structure, which is being sent via socket. I need to read it in chunks, since one of its fields contains the size of the data remaining: I need to read first few bytes, find out...
Harwood asked 8/3, 2015 at 17:38
1
Looking for a boost::asio (and with himself boost) decided to write asynchronous server. To store incoming data I use boost::asio::streambuf.
Here I have a problem. When I receive a second message ...
Habitforming asked 12/2, 2015 at 13:7
1
Solved
I can't seem to find a good explanation of what consume() and commit() really means, actually I don't understand streambuf at all.
My understanding is that a streambuf is just a character array. B...
Miquelon asked 28/9, 2014 at 9:18
3
Suppose I have a function that takes an ostream & parameter o and writes to that ostream. An operator << implementation would be a good example.
ostream& operator << (ostream&a...
2
Solved
I try the following code:
ostringstream oss;
streambuf *psbuf, *backup;
backup = oss.rdbuf();
psbuf = cout.rdbuf();
oss.rdbuf(psbuf);
oss << things << endl;
oss.rdbuf(backup);
...
Cradlesong asked 7/3, 2014 at 6:35
2
Solved
I have class Writer that has two ofstream members.
Both streams are associated with the same output file. I'd like to use both streams in Writer::write method, but to make sure that each stream wri...
1
Solved
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 ...
1
Solved
I use the C++ streambuf class for a compiler project and need a convenient way to get the current position in the stream.
There are two member functions, streambuf::pubseekpos and a streambuf::pub...
1
Solved
I've written a custom stream class that outputs indented text and that has manipulators that can change the indent level. All of the indenting work is implemented in a custom stream buffer class, w...
Exploratory asked 24/2, 2013 at 16:20
3
Solved
The author presented this code under the title A bus error on my platform
#include <fstream>
#include <iostream>
int main()
{
std::ofstream log("oops.log");
std::cout.rdbuf(log.rdbu...
Garnett asked 13/2, 2013 at 18:17
1
Solved
I'm using this code for reading
socket_.async_read_some(boost::asio::buffer(data_, max_length),
boost::bind(&session::handle_read, this,
boost::asio::placeholders::error,
boost::asio::pla...
Softy asked 26/5, 2012 at 9:8
2
Solved
I'm want to check for incoming data packages on the serial port, using boost.asio. Each data packet will start with a header that is one byte long, and will specify what type of the message has bee...
Factor asked 10/5, 2010 at 23:11
4
Solved
I want to implement a simple class for logging from multiple threads. The idea there is, that each object that wants to log stuff, receives an ostream-object that it can write messages to using the...
2
Solved
27.6.3.4.2 Buffer management and positioning
pos_type seekoff(off_type off, ios_base::seekdir way,
ios_base::openmode which = ios_base::in | ios_base::out);
Effects: Alters the stream pos...
1
Solved
I'm trying to create an istream that reads directly from a raw memory buffer.
I found a nice way to do this in another post on here:
class membuf : public basic_streambuf<char>
{
public:...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.