I'm trying to take a complex, nested structure and store it directly in a .cpp file as static data. The approach I'd like to take is to take my object (which already supports Boost serialization) and serialize it as a binary archive into a byte array. I could then take that byte array, and walk through it to autogenerate the required .cpp code to hold the binary array. Then, I'd like to deserialize from that byte array back into the object.
So basically, at the end of the day I'd like something like this:
unsigned char* my_obj = { 10, 48, 48, 30, 20 ... }
When I want to use that data, I'd just wrap it in the "byte stream" and pass it into Boost again to deserialize back into my actual object.
My question is: is there some easy way to pass byte arrays around as streams? Boost deals with istreams and ostreams for reading and writing the archives. I don't want to use a stringstream or a filestream, but rather what I suppose may be a custom stream that just acts as a giant byte array for whatever is passed to it.
I feel like there should be a great way to create this custom stream and have it seamlessly work with the Boost serialization... I'm just not really sure where to begin?