Struct MemoryPointer
A pointer to a contiguous region of memory.
Inherited Members
Namespace: OnixS.SimpleBinaryEncoding
Assembly: OnixS.SimpleBinaryEncoding.dll
Syntax
public struct MemoryPointer : IDisposable, IEquatable<MemoryPointer>
Constructors
MemoryPointer(Memory<byte>)
Constructs the instance that points to the given managed memory region.
WARNING: The given memory region will be pinned. To un-pin the region, call Dispose().
Declaration
public MemoryPointer(Memory<byte> memory)
Parameters
| Type | Name | Description |
|---|---|---|
| Memory<byte> | memory | The managed memory region, which will be pinned. |
MemoryPointer(void*, int)
Constructs the instance pointing to the given unmanaged memory region owned by external code.
Declaration
public MemoryPointer(void* unmanagedPointer, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| void* | unmanagedPointer | The unmanaged memory region owned by external code. |
| int | length | The length of the umanaged memory region. |
Properties
IsEmpty
Declaration
public readonly bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Length
Declaration
public readonly int Length { get; }
Property Value
| Type | Description |
|---|---|
| int | The buffer length. |
Span
Declaration
public readonly Span<byte> Span { get; }
Property Value
| Type | Description |
|---|---|
| Span<byte> | A span created from the current object. |
Methods
Dispose()
Unpins the referenced managed memory region (if required).
Declaration
public readonly void Dispose()
Equals(MemoryPointer)
Indicates whether the current object is equal to another object of the same type.
Declaration
public bool Equals(MemoryPointer other)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryPointer | other | An object to compare with this object |
Returns
| Type | Description |
|---|---|
| bool | true if the current object is equal to the other parameter; otherwise, false |
Equals(object)
Indicates whether the current object is equal to another object of the same type.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | An object to compare with this object |
Returns
| Type | Description |
|---|---|
| bool | true if the current object is equal to the other parameter; otherwise, false |
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A hash code for the current object |
Overrides
Reset(IMemoryPointer)
Sets with a new value.
Declaration
public void Reset(MemoryPointer.IMemoryPointer pointer)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryPointer.IMemoryPointer | pointer |
Slice(int)
Forms a slice out of the current memory that begins at a specified index.
Declaration
public readonly MemoryPointer.UnmanagedPointer Slice(int start)
Parameters
| Type | Name | Description |
|---|---|---|
| int | start | The index at which to begin the slice. |
Returns
| Type | Description |
|---|---|
| MemoryPointer.UnmanagedPointer | The pointer to the memory region that contains all elements of the current instance from |
ToString()
Returns the text representation.
Declaration
public override readonly string ToString()
Returns
| Type | Description |
|---|---|
| string | The text representation. |
Overrides
Operators
operator ==(MemoryPointer, MemoryPointer)
Declaration
public static bool operator ==(MemoryPointer left, MemoryPointer right)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryPointer | left | |
| MemoryPointer | right |
Returns
| Type | Description |
|---|---|
| bool |
implicit operator MemoryPointer(byte[])
Declaration
public static implicit operator MemoryPointer(byte[] array)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | array |
Returns
| Type | Description |
|---|---|
| MemoryPointer |
implicit operator MemoryPointer(Memory<byte>)
Declaration
public static implicit operator MemoryPointer(Memory<byte> memory)
Parameters
| Type | Name | Description |
|---|---|---|
| Memory<byte> | memory |
Returns
| Type | Description |
|---|---|
| MemoryPointer |
operator !=(MemoryPointer, MemoryPointer)
Declaration
public static bool operator !=(MemoryPointer left, MemoryPointer right)
Parameters
| Type | Name | Description |
|---|---|---|
| MemoryPointer | left | |
| MemoryPointer | right |
Returns
| Type | Description |
|---|---|
| bool |