Converted serializer from c-style to c++