17 Aug
2005
17 Aug
'05
3:23 p.m.
I have a parser and there is one big object that holds the whole file being parsed as a dynamic array class File { public char * ptr; }; File file; file.ptr = new char[very_big_number_like_100000]; The parser creates a lot of objects that keep pointers into this dynamic array. class A { char* internalPtr1; }; class B { char* internalPtr2; }; class C { char* internalPtr3; }; A a; B b; C c; a.internalPtr1 = file.ptr + 234; b.internalPtr2 = file.ptr + 10673; c.internalPtr3 = file.ptr + 9583; How could I serialize the file object and these numerous small objects? I could write separate save/load for each of these A, B, C and so on but I'll need access to File::ptr inside the save/load funcs and this would be an ugly solution. Any ideas?