About
Using MemoryFileStruct one can read/write from/into memory using a file class.
- Note
- The MAXON API equivalent is maxon::IoMemoryInterface.
Typical use cases:
A general example on writing into a HyperFile in memory:
if (hf == nullptr || mfs == nullptr)
hf->WriteInt32(123);
hf->WriteString("foo"_s);
hf->WriteString("bar"_s);
hf->WriteInt32(456);
hf->Close();
void* rawData = nullptr;
mfs->GetData(rawData, rawDataSize, false);
Definition: ge_autoptr.h:37
Manages file and path names.
Definition: c4d_file.h:94
void SetMemoryWriteMode(MemoryFileStruct *mfs)
maxon::Int Int
Definition: ge_sys_math.h:64
@ NONE
Never show an error dialog.
#define MAXON_SOURCE_LOCATION
Definition: memoryallocationbase.h:67
This is how one can easily transfer an object (or a complete hierarchy) via network:
if (mfs == nullptr)
void* rawData = nullptr;
mfs->GetData(rawData, rawDataSize, false);
Definition: c4d_baseobject.h:248
FILEERROR WriteHyperFile(BaseDocument *doc, GeListNode *node, const Filename &filename, Int32 ident)
const char * doc
Definition: pyerrors.h:226
#define iferr_return
Definition: resultbase.h:1521
PyObject * op
Definition: object.h:520
void* rawData = nullptr;
ReceiveFromNetwork(rawData, rawDataSize);
if (!rawData || rawDataSize == 0)
doc->InsertObject(
op.Release(),
nullptr,
nullptr,
false);
void SetMemoryReadMode(void *adr, Int size=-1, Bool transferOwnership=false)
Definition: c4d_string.h:39
PyObject * error
Definition: codecs.h:206
return OK
Definition: apibase.h:2747
#define Onull
Null.
Definition: ge_prepass.h:1074
FILEERROR ReadHyperFile(BaseDocument *doc, GeListNode *node, const Filename &filename, Int32 ident, maxon::String *warning_string)
Allocation/Deallocation
MemoryFileStruct objects are created with the usual tools, see Entity Creation and Destruction Manual (Classic).
Writing Data to a File in Memory and Accessing the Raw Data
Reading Data From a File in Memory
Further Reading