general pourpose serializer/deserializer for C++