From: Peter V. <pet...@ya...> - 2005-06-10 07:10:29
|
> One (very disruptive, not entirely serious, but something to think > about) suggestion, is to follow the serialisation library design in > boost. There they have separated the serialisation format, from the > IO code itself. I'm also in favour of something along these lines. In any case, something uniform and not too complex to understand. And indeed, in reply to Joe's suggestions, it would be good to have << and >> implemented such that they are each other's inverse: reading back in the output of << should reconstruct the object. And << should not be too verbose. In this respect, since we don't have RTTI, including the object name would only serve a validation purpose. Which is nevertheless useful, so I would still include, say, <vgl_point_2d> in the output of <<, but silently skip this entry in the implementation of >>, unless of course it's the wrong name in which case a warning message is printed and nothing is overwritten. So my choice would be for: - all vgl objects have similar-looking << output, and similar >> input structure requirements. - operator<< writing out the object name followed by the necessary data components (which may include other vgl objects); all surrounded by <...> - full output of a single object appears on a single line without \n. - operator<< able to read back in the output of operator>>, but also a single line of bare numeric values, separated by whatever non-numeric tokens (like blanks, comma's, text, etc.) And why not extend this design to all container classes of vxl, like vnl (vectors and matrices), vbl (arrays, bounding_box), and even vil (image header info, not the data of course). Other parts (vsol, ...) will then follow. -- Peter. |