tonnot
tonnot

Reputation: 455

c++ streaming io / Design a stringstream+custom streambuf or use mem tools on char array?

I want to have a i/o system to store-retrieve info of any class into a char array. I can use stringstream seekg, seekp, read, write and casting from/to to do the work . I have discover that there is a fail with pubsetbuf on VC++ STL, and see that it is neccesary to implement a streambuf derived class. I ask myself if it can be easiest to implement a memcpy, memmove etc solution ? ( to do in/out operations on my char array + casting of course ). What do you think ? What about the performance? Thanks

Upvotes: 0

Views: 287

Answers (1)

Randall Cook
Randall Cook

Reputation: 6776

Generalized serialization frameworks like boost::serialization are good. But if your system deviates from what they expect, the effort you put into adapting to your library of choice might exceed that of creating your own serialization methods. Also, generalized serialization systems are necessarily heavier-weight than something you might make yourself, due to their generality. If you can specialize, you might realize a benefit. If you want something more robust and general, it is probably better to go with an established library.

Upvotes: 1

Related Questions