RawMemoryExport
RawMemoryExport[expr]
exports a raw memory representation of expr.
RawMemoryExport[expr,type]
uses the specified element type when returning an array.
Details and Options
- RawMemoryExport returns a managed RawPointer object.
- type can be omitted if expr is a string, ByteArray or NumericArray.
- Possible element types and their corresponding C types include:
-
"UnsignedInteger8" uint8_t unsigned 8-bit integer "Integer8" int8_t signed 8-bit integer "UnsignedInteger16" uint16_t unsigned 16-bit integer "Integer16" int16_t signed 16-bit integer "UnsignedInteger32" uint32_t unsigned 32-bit integer "Integer32" int32_t signed 32-bit integer "UnsignedInteger64" uint64_t unsigned 64-bit integer "Integer64" int64_t signed 64-bit integer "CUnsignedChar" unsigned char C-compatible unsigned char "CSignedChar" signed char C-compatible signed char "CUnsignedShort" unsigned short C-compatible unsigned short "CShort" short C-compatible short "CUnsignedInt" unsigned int C-compatible unsigned int "CInt" int C-compatible int "CUnsignedLong" unsigned long C-compatible unsigned long "CLong" long C-compatible long "CSizeT" size_t C-compatible size_t "CFloat" float C-compatible float "CDouble" double C-compatible double "OpaqueRawPointer" void* opaque pointer "RawPointer"::[t] t* typed pointer {ty1,ty2,…} struct {ty1 f1; ty2 f2; …} struct or product type "Void" void no output (only in output types) - If expr is a ByteArray or a NumericArray, only integral and real types are allowed as the element type.
- The following options are supported:
-
CharacterEncoding "UTF-8" character encoding
Examples
open allclose allBasic Examples (2)
Scope (3)
Use the second argument of RawMemoryExport to specify the element type of the exported raw memory:
The element type can be omitted if the exported expression is a string, a ByteArray or a NumericArray:
The raw memory is null-terminated when a string is exported:
Options (1)
CharacterEncoding (1)
Specify what CharacterEncoding should be used when exporting a string:
Properties & Relations (3)
By default, RawMemoryExport returns a RawPointer wrapped in ManagedObject:
Use UnmanageObject to unmanage the pointer:
RawMemoryImport is the inverse operation of RawMemoryExport:
Use ForeignFunctionLoad to load a function that computes the sum of the elements of a raw memory:
Export a list as a raw memory of "CLong" objects:
Possible Issues (5)
Strings can only be exported as a raw memory of "UnsignedInteger8" objects:
The element type of the raw memory cannot be automatically determined if the inputted expression is a list:
Specify the target element type:
RawMemoryExport will return $Failed if the element type is not supported:
RawMemoryExport will return $Failed if an element does not match the specified element type:
If the exported expression is a ByteArray or a NumericArray, the element type can only be integral and real types:
Text
Wolfram Research (2023), RawMemoryExport, Wolfram Language function, https://reference.wolfram.com/language/ref/RawMemoryExport.html.
CMS
Wolfram Language. 2023. "RawMemoryExport." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RawMemoryExport.html.
APA
Wolfram Language. (2023). RawMemoryExport. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RawMemoryExport.html