Struct BinaryParser
Ref struct to hide unsafe pointer logic
Inherited Members
Namespace: Unity.Logging
Assembly: Unity.Logging.dll
Syntax
public readonly ref struct BinaryParser
Constructors
BinaryParser(void*, int)
Creates the ref struct
Declaration
public BinaryParser(void* ptrContextData, int payloadBufferLength)
Parameters
Type | Name | Description |
---|---|---|
void* | ptrContextData | Pointer to the data |
int | payloadBufferLength | Length of the data in bytes |
Fields
LengthInBytes
Length of the data in bytes
Declaration
public readonly int LengthInBytes
Field Value
Type | Description |
---|---|
int |
Properties
IsValid
True if Pointer is not null and length is bigger than 0
Declaration
public bool IsValid { get; }
Property Value
Type | Description |
---|---|
bool |
Pointer
Safe IntPtr wrapper for the internal pointer
Declaration
public IntPtr Pointer { get; }
Property Value
Type | Description |
---|---|
Int |
Methods
AppendToUnsafeText<T>(ref UnsafeText, ref FormatterStruct, ref LogMemoryManager, ref ArgumentInfo)
Reads the pointer as T that implements ILoggableMirrorStruct, and appends it to the Unsafe
Declaration
public bool AppendToUnsafeText<T>(ref UnsafeText hstring, ref FormatterStruct formatter, ref LogMemoryManager memAllocator, ref ArgumentInfo currArgSlot) where T : unmanaged, ILoggableMirrorStruct
Parameters
Type | Name | Description |
---|---|---|
Unsafe |
hstring | UnsafeText where to append |
Formatter |
formatter | Current formatter |
Log |
memAllocator | Memory manager that holds binary representation of the mirror struct |
Argument |
currArgSlot | Hole that was used to describe the struct in the log message, for instance |
Returns
Type | Description |
---|---|
bool | True if append was successful |
Type Parameters
Name | Description |
---|---|
T | Unmanaged struct that implements ILoggableMirrorStruct |
AppendUTF8StringToUnsafeText(ref UnsafeText, ref FormatterStruct, int, ref ArgumentInfo)
Reads the pointer as a UTF8 string and appends it to the Unsafe
Declaration
public bool AppendUTF8StringToUnsafeText(ref UnsafeText hstring, ref FormatterStruct formatter, int stringLengthInBytes, ref ArgumentInfo currArgSlot)
Parameters
Type | Name | Description |
---|---|---|
Unsafe |
hstring | UnsafeText where to append |
Formatter |
formatter | Current formatter |
int | stringLengthInBytes | Length of the UTF8 string in bytes |
Argument |
currArgSlot | Hole that was used to describe the struct in the log message, for instance |
Returns
Type | Description |
---|---|
bool | True if append was successful |
Peek<T>()
Reads the pointer as T. Checks out of bound read if debug checks are present
Declaration
public T Peek<T>() where T : unmanaged
Returns
Type | Description |
---|---|
T | T representation of binary data under Ptr |
Type Parameters
Name | Description |
---|---|
T | Unmanaged type |
Skip(int)
Creates new BinaryParser that is a slice of the current one, but 'bytes' are skipped
Declaration
public BinaryParser Skip(int bytes)
Parameters
Type | Name | Description |
---|---|---|
int | bytes | Bytes to skip |
Returns
Type | Description |
---|---|
Binary |
Slice of the current BinaryParser |
Skip<T>()
Creates new BinaryParser that is a slice of the current one, but SizeOf are skipped
Declaration
public BinaryParser Skip<T>() where T : unmanaged
Returns
Type | Description |
---|---|
Binary |
Slice of the current BinaryParser |
Type Parameters
Name | Description |
---|---|
T | Unmanaged type, its size will be used to skip |