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...
Busse asked 28/1, 2016 at 16:0

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...
Electronarcosis asked 22/7, 2020 at 12:43

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...
Biramous asked 19/7, 2009 at 20:41

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...
Anywheres asked 15/5, 2018 at 23:33

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...
Periscope asked 31/3, 2018 at 19:19

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...
Outflow asked 26/12, 2017 at 17:45

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...
Chronopher asked 6/5, 2016 at 15:26

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 ...
Depolymerize asked 12/5, 2012 at 13:6

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...
Meson asked 6/11, 2014 at 11:48

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...
Breathing asked 24/12, 2013 at 7:48

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 ...
Corinnacorinne asked 7/11, 2013 at 23:55

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...
Pork asked 20/3, 2013 at 13:32

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...
Squire asked 9/12, 2009 at 10:3

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...
Hauteur asked 23/7, 2011 at 13:51

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:...
Stere asked 20/7, 2011 at 14:37

© 2022 - 2024 — McMap. All rights reserved.