I have a situation where I have an object of a class in C++, which needs to be send across process boundaries (process 1 to process 2) using Linux pipes. I searched online on how to do serialization in C++. I found boost, but it requires some changes in the class. In my situation I cannot change the class.
This class has a lot of pointers, and the nesting continues to 3 levels (Class 1 has pointer 1 of type Class 2-> Class 2 has pointer 2 of type Class 3 -> Class 3 has pointer 3 of type class 4 -> Class 4). Is there any way I can send this object using pipes so that it can be recreated in the second process ?
Thanks.
You’ll need to serialize the class somehow. How exactly is your choice, but you can do so in a format like
JSON, orXML, or some kind of binary format you decide on. Without seeing any more details on your class, there’s not much else to add.Another option might be to use Shared memory segments to store the class, but that comes with issues with pointer math, concurrency and other complications.