Buffer Class
Abstracts the NativeBuffer and the ClrBuffer.
Syntax
Remarks
- This class should be subclassed only with caution, it allows to change the behaviour of buffer allocations, this functionality should be used only by people who know exactly what they are doing.
- In order to achieve faster performance, the buffer should be allocated immediately with a decent size, so the renderer won't have to grow the buffer.
Requirements
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Members
See Also: Inherited members from object.
Protected Constructors
Public Fields
static readonly
|
DefaultUnitSize | int . The default unit size. |
Public Properties
[read-only] | AllocatedSize | IntPtr . The allocated size of the buffer. |
[read-only] | Data | IntPtr . Buffer allocation pointer. |
|
Encoding | System.Text.Encoding . Default encoding to use for when serializing between strings and the buffer. |
|
NativeHandle | IntPtr . The native buffer handle which is used by the sundown library. |
|
Size | IntPtr . The currently used size of the buffer. |
[read-only] | UnitSize | IntPtr . The unit size of the particular buffer. |
Public Methods
static
|
Create
()Creates a buffer using the default buffer implementation. |
|
static
|
Create
(int)Creates a buffer using the default buffer implementation. |
|
static
|
Create
(long)Creates a buffer using the default buffer implementation. |
|
static
|
Create
(IntPtr)Creates a buffer using the default buffer implementation. |
|
|
Dispose
()Releases the allocated buffer. |
|
|
Finalize
()Documentation for this section has not yet been entered. |
|
static
|
From
(IntPtr)Creates an instance of the default buffer implementation from a pointer pointing to a buf handle. |
|
|
GetBufferStream
()Wraps the current Buffer in a BufferStream. |
|
|
GetBytes
()Copies the content of the buffer into a newly allocated clr array. |
|
|
GetStream
()Creates an UnmanagedStream. |
|
|
Grow
(int)Grow the buffer size. |
|
|
Grow
(long)Grow the buffer size. |
|
|
Grow
(IntPtr)Grow the buffer size. |
|
|
Put
(Buffer)Documentation for this section has not yet been entered. |
|
|
Put
(byte)Documentation for this section has not yet been entered. |
|
|
Put
(byte[])Documentation for this section has not yet been entered. |
|
|
Put
(string)Documentation for this section has not yet been entered. |
|
|
Put
(byte[], int)Documentation for this section has not yet been entered. |
|
|
Put
(byte[], long)Documentation for this section has not yet been entered. |
|
|
Put
(byte[], IntPtr)Documentation for this section has not yet been entered. |
|
|
Put
(IntPtr, int)Documentation for this section has not yet been entered. |
|
|
Put
(IntPtr, long)Documentation for this section has not yet been entered. |
|
|
Put
(IntPtr, IntPtr)Documentation for this section has not yet been entered. |
|
|
Put
(string, params object[])Documentation for this section has not yet been entered. |
|
|
Put
(System.Text.Encoding, string)Documentation for this section has not yet been entered. |
|
|
Put
(byte[], int, int)Documentation for this section has not yet been entered. |
|
|
Put
(byte[], long, long)Documentation for this section has not yet been entered. |
|
|
Put
(byte[], IntPtr, IntPtr)Documentation for this section has not yet been entered. |
|
|
Put
(System.Text.Encoding, string, params object[])Documentation for this section has not yet been entered. |
|
|
Reset
()Clears the buffer. |
|
|
Slurp
(int)Removes a given number of bytes from the head of the buffer. |
|
|
Slurp
(long)Removes a given number of bytes from the head of the buffer. |
|
|
Slurp
(IntPtr)Removes a given number of bytes from the head of the buffer. |
Protected Methods
Member Details
Buffer Constructor
Allocates a new buffer or reuses an existing one.
Syntax
Parameters
- size
- Allocates a buffer of the size saved in the variable if the second argument alloc is true. If alloc is false, it will just use the value inside size as a pointer to the allocated buffer.
- alloc
- Determines how to treat the first argument IntPtr size of the constructor. If alloc is true, it will allocate a new buffer with the size saved in the 'IntPtr size' argument, if false, it will use the value in size as a pointer to the buffer.
Remarks
This class is a wrapper of the buf functionality provided sundown (a collection of methods dealing with a buffer struct). The class is unsafe, in the sense that it uses pointer aritmethic and c functions.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Alloc Method
Allocates the NativeHandle.
Syntax
Parameters
- size
- The size of the allocated buffer.
Remarks
bufnewcb should be called from the sundown library in order to use custom allocators.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
AllocatedSize Property
The allocated size of the buffer.
Syntax
public IntPtr AllocatedSize { get; }Value
The size of the allocated buffer.Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Create Method
Creates a buffer using the default buffer implementation.
Syntax
public static Buffer Create ()Returns
A new instance of the default buffer implementation.Remarks
Creates a buffer with the size of DefaultUnitSize(1024), which can lead to suboptimal behaviour, if the input is know to be bigger.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Create Method
Creates a buffer using the default buffer implementation.
Syntax
Parameters
- size
- The initial size of the buffer.
Returns
A new instance of the default buffer implementation.Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Create Method
Creates a buffer using the default buffer implementation.
Syntax
Parameters
- size
- The initial size of the buffer.
Returns
A new instance of the default buffer implementation.Remarks
Using values greater than 32bit on 32bit machines will result in errorneous program behaviour.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Create Method
Creates a buffer using the default buffer implementation.
Syntax
Parameters
- size
- The initial size of the buffer.
Returns
A new instance of the default buffer implementation.Remarks
Using values greater than 32bit on 32bit machines will result in errorneous program behaviour.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Data Property
Buffer allocation pointer.
Syntax
public IntPtr Data { get; }Value
A pointer to the allocated buffer.Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
DefaultUnitSize Field
The default unit size.
Syntax
public static readonly int DefaultUnitSizeRemarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Dispose Method
Releases the allocated buffer.
Syntax
public void Dispose ()Remarks
Using this on NativeBuffer will release the allocated memory immediately, while on ClrBuffer it will just release the pinhandle and wait for the byte array to be collected by the GC.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Dispose Method
The Dispose(bool) pattern.
Syntax
Parameters
- disposing
- true if the user called Dispose, false if the garbage collector initiated the dispose method.
Remarks
Override this in your sublcasses if you want to have specific release behaviour.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Encoding Property
Default encoding to use for when serializing between strings and the buffer.
Syntax
public System.Text.Encoding Encoding { get; set; }Value
Documentation for this section has not yet been entered.Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Finalize Method
Documentation for this section has not yet been entered.
Syntax
void Finalize ()Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
From Method
Creates an instance of the default buffer implementation from a pointer pointing to a buf handle.
Syntax
Parameters
- ptr
- Pointer pointing to the buf handle.
Returns
A new instance of the default buffer implementation.Remarks
Don't cross over ClrBuffer buf handles and NativeBuffer handles, because the allocated memory is allocated by GCHandle/byte[] and malloc accordingly.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
GetBufferStream Method
Wraps the current Buffer in a BufferStream.
Syntax
public BufferStream GetBufferStream ()Returns
A BufferStream which wraps the current Buffer.Remarks
The BufferStream let's you only write.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
GetBytes Method
Copies the content of the buffer into a newly allocated clr array.
Syntax
public byte[] GetBytes ()Returns
A CLR byte array containing all the information of the buffer.Remarks
The size is equal to the content size and not the buffer size. The entire content of the buffer gets copied and not just reused.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
GetStream Method
Creates an UnmanagedStream.
Syntax
public System.IO.Stream GetStream ()Returns
An UnmanagedStream pointing to the allocated buffer memory.Remarks
If you call this method and then call Grow on the buffer, the pointer to which the UnamangedStream is pointing might become invalid. Always drop the last Stream you got with this function if you are doing operations on the buffer which might increase the buffer(resize/realloc the memory).Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Grow Method
Grow the buffer size.
Syntax
Parameters
- size
- The amount of bytes which to grow.
Remarks
Growing passed 16MB will result in OutOfMemoryException. This is a sundown limitation.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Grow Method
Grow the buffer size.
Syntax
Parameters
- size
- The amount of bytes which to grow.
Remarks
Growing passed 16MB will result in OutOfMemoryException. This is a sundown limitation.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Grow Method
Grow the buffer size.
Syntax
Parameters
- size
- The amount of bytes which to grow.
Remarks
Growing passed 16MB will result in OutOfMemoryException. This is a sundown limitation.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
NativeHandle Property
The native buffer handle which is used by the sundown library.
Syntax
public IntPtr NativeHandle { get; protected set; }Value
Pointer to the native buffer handle.Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- buffer
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- c
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- bytes
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- str
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- bytes
- Documentation for this section has not yet been entered.
- size
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- bytes
- Documentation for this section has not yet been entered.
- size
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- bytes
- Documentation for this section has not yet been entered.
- size
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- data
- Documentation for this section has not yet been entered.
- size
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- data
- Documentation for this section has not yet been entered.
- size
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- data
- Documentation for this section has not yet been entered.
- size
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- str
- Documentation for this section has not yet been entered.
- param
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- encoding
- Documentation for this section has not yet been entered.
- str
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- bytes
- Documentation for this section has not yet been entered.
- offset
- Documentation for this section has not yet been entered.
- count
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- bytes
- Documentation for this section has not yet been entered.
- offset
- Documentation for this section has not yet been entered.
- count
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- bytes
- Documentation for this section has not yet been entered.
- offset
- Documentation for this section has not yet been entered.
- count
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Put Method
Documentation for this section has not yet been entered.
Syntax
Parameters
- encoding
- Documentation for this section has not yet been entered.
- str
- Documentation for this section has not yet been entered.
- param
- Documentation for this section has not yet been entered.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Reset Method
Clears the buffer.
Syntax
public void Reset ()Remarks
Doesn't release the memory, it only sets the seek pointer to 0.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Size Property
The currently used size of the buffer.
Syntax
public IntPtr Size { get; set; }Value
Documentation for this section has not yet been entered.Remarks
This returns how much content the buffer contains.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Slurp Method
Removes a given number of bytes from the head of the buffer.
Syntax
Parameters
- size
- Number of bytes to remove.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Slurp Method
Removes a given number of bytes from the head of the buffer.
Syntax
Parameters
- size
- Number of bytes to remove.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
Slurp Method
Removes a given number of bytes from the head of the buffer.
Syntax
Parameters
- size
- Number of bytes to remove.
Remarks
Documentation for this section has not yet been entered.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0
UnitSize Property
The unit size of the particular buffer.
Syntax
public IntPtr UnitSize { get; }Value
Documentation for this section has not yet been entered.Remarks
The bigger the default unit size is the more memory is allocated when growing the buffer when the size is not sufficient to hold the entire content, but less allocations are needed. The best way is to allocate immediately a sufficiently big enough buffer.Requirements
Namespace: Sundown
Assembly: SundownNet (in SundownNet.dll)
Assembly Versions: 1.15.12.0