From cb64a6c4d7dfcb8104f7ce3fca63d01f1b0f028d Mon Sep 17 00:00:00 2001 From: Tom Quinn Date: Fri, 17 Jun 2022 17:12:21 -0700 Subject: [PATCH] Allow TipsyWriter class to be constructed on a memory buffer. This will allow the class to work with the charm CkIO module. Change-Id: Ie2e61ead1d81ca38df4488ca28a0226102776793 --- structures/TipsyReader.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/structures/TipsyReader.h b/structures/TipsyReader.h index 7c14e7e..a53d9bf 100644 --- a/structures/TipsyReader.h +++ b/structures/TipsyReader.h @@ -298,6 +298,23 @@ class TipsyWriter { ok = true; set_sizes(); } + + /// Write to a buffer + TipsyWriter(void *buffer, size_t size, header &parh, + bool pnative=false, bool _bDP = false, bool _bDV = false) + : native(pnative), ok(false), h(parh), bDoublePos(_bDP), + bDoubleVel(_bDV) { + tipsyFp = fmemopen(buffer, size, "rb+"); + if(tipsyFp == NULL) { + ok = false; + assert(0); + return; + } + if(!native) + xdrstdio_create(&xdrs, tipsyFp, XDR_ENCODE); + ok = true; + set_sizes(); + } ~TipsyWriter() { if(tipsyFp == NULL)