Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like Python's StringIO/CStringIO for C++?

I'm serializing a large amount of data to send over a network with Boost's serialization libraries.

Boost's serialization libraries require an intermediate file for serialization and deserialization. The volume of data being transmitted makes it awkward to do all of this. Keeping things in memory would be much better.

Is there anything at all in C++ similar to Python's cStringIO/StringIO that I can use to fake out Boost's serialization?

Thanks in advance.

like image 733
deathweasel Avatar asked Feb 14 '12 17:02

deathweasel


People also ask

Is StringIO a file-like object Python?

The StringIO module is an in-memory file-like object. This object can be used as input or output to the most function that would expect a standard file object. When the StringIO object is created it is initialized by passing a string to the constructor.

What is StringIO used for?

This module implements a file-like class, StringIO, that reads and writes a string buffer (also known as memory files). See the description of file objects for operations (section File Objects). (For standard strings, see str and unicode.)

What is io StringIO ()?

It is the StringIO module is an in-memory, file-like object. It can be used to input or output the majority of functions users can expect from an ordinary file object. Once the user creates the StringIO objects, it is initially created by providing a string to the constructor.


1 Answers

Yes, it's called stringstream.

like image 184
Sven Marnach Avatar answered Oct 13 '22 00:10

Sven Marnach