Reflection in C++ - Load In Place

I played a little bit with my Load-In-Place system. It used to only support vectors of PODs (stored by value). Now it handles also vectors of pointers & vectors of classes. Sample structure that’ll be saved/loaded automatically:

struct IntContainer
	int*	pInt;
struct SuperBar 
	unsigned long	i;
	// [Hidden]
	float*			p;
	bool			b;
	signed char		s;
	Color			color;
	SuperBar*		psb;
	typedef rde::vector tVec;
	tVec			v;
	rde::vector<Color*> someColors;
	rde::vector<SuperBar*> superBars;
	rde::vector containers;
	IntContainer	ic;
// (fill sb)
// Code to save this.
SaveObject(sb, ofstream, typeRegistry);
// Code to load:
SuperBar* psb = LoadObject(ifstream, typeRegistry);
Cool thing is, fixup cost for loading is roughly linear (it’s constant per-pointer, no recursion), only saving gets more complicated as structure complexity increases (so it’s still good to be careful, of course). I’ve updated download package.

comments powered by Disqus