C# Class devTool.PacketWriter

Provides functionality for writing primitive binary data.
Datei anzeigen Open project: vans163/LKEmu Class Usage Examples

Public Methods

Method Description
CreateInstance ( ) : PacketWriter
CreateInstance ( int capacity ) : PacketWriter
Fill ( ) : void

Fills the stream from the current position up to (capacity) with 0x00's

Fill ( int length ) : void

Writes a number of 0x00 byte values to the underlying stream.

PacketWriter ( ) : System

Instantiates a new PacketWriter instance with the default capacity of 4 bytes.

PacketWriter ( int capacity ) : System

Instantiates a new PacketWriter instance with a given capacity.

ReleaseInstance ( PacketWriter pw ) : void
Seek ( long offset, SeekOrigin origin ) : long

Offsets the current position from an origin.

ToArray ( ) : byte[]

Gets the entire stream content as a byte array.

Write ( bool value ) : void

Writes a 1-byte boolean value to the underlying stream. False is represented by 0, true by 1.

Write ( byte value ) : void

Writes a 1-byte unsigned integer value to the underlying stream.

Write ( byte buffer, int offset, int size ) : void

Writes a sequence of bytes to the underlying stream

Write ( int value ) : void

Writes a 4-byte signed integer value to the underlying stream.

Write ( sbyte value ) : void

Writes a 1-byte signed integer value to the underlying stream.

Write ( short value ) : void

Writes a 2-byte signed integer value to the underlying stream.

Write ( uint value ) : void

Writes a 4-byte unsigned integer value to the underlying stream.

Write ( ushort value ) : void

Writes a 2-byte unsigned integer value to the underlying stream.

WriteAsciiFixed ( string value, int size ) : void

Writes a fixed-length ASCII-encoded string value to the underlying stream. To fit (size), the string content is either truncated or padded with null characters.

WriteAsciiNull ( string value ) : void

Writes a dynamic-length ASCII-encoded string value to the underlying stream, followed by a 1-byte null character.

WriteBigUniFixed ( string value, int size ) : void

Writes a fixed-length big-endian unicode string value to the underlying stream. To fit (size), the string content is either truncated or padded with null characters.

WriteBigUniNull ( string value ) : void

Writes a dynamic-length big-endian unicode string value to the underlying stream, followed by a 2-byte null character.

WriteLittleUniFixed ( string value, int size ) : void

Writes a fixed-length little-endian unicode string value to the underlying stream. To fit (size), the string content is either truncated or padded with null characters.

WriteLittleUniNull ( string value ) : void

Writes a dynamic-length little-endian unicode string value to the underlying stream, followed by a 2-byte null character.

WriteUTF8Null ( string value ) : void

Writes a dynamic-length UTF8-encoded string value to the underlying stream, followed by a 1-byte null character.

Method Details

CreateInstance() public static method

public static CreateInstance ( ) : PacketWriter
return PacketWriter

CreateInstance() public static method

public static CreateInstance ( int capacity ) : PacketWriter
capacity int
return PacketWriter

Fill() public method

Fills the stream from the current position up to (capacity) with 0x00's
public Fill ( ) : void
return void

Fill() public method

Writes a number of 0x00 byte values to the underlying stream.
public Fill ( int length ) : void
length int
return void

PacketWriter() public method

Instantiates a new PacketWriter instance with the default capacity of 4 bytes.
public PacketWriter ( ) : System
return System

PacketWriter() public method

Instantiates a new PacketWriter instance with a given capacity.
public PacketWriter ( int capacity ) : System
capacity int Initial capacity for the internal stream.
return System

ReleaseInstance() public static method

public static ReleaseInstance ( PacketWriter pw ) : void
pw PacketWriter
return void

Seek() public method

Offsets the current position from an origin.
public Seek ( long offset, SeekOrigin origin ) : long
offset long
origin SeekOrigin
return long

ToArray() public method

Gets the entire stream content as a byte array.
public ToArray ( ) : byte[]
return byte[]

Write() public method

Writes a 1-byte boolean value to the underlying stream. False is represented by 0, true by 1.
public Write ( bool value ) : void
value bool
return void

Write() public method

Writes a 1-byte unsigned integer value to the underlying stream.
public Write ( byte value ) : void
value byte
return void

Write() public method

Writes a sequence of bytes to the underlying stream
public Write ( byte buffer, int offset, int size ) : void
buffer byte
offset int
size int
return void

Write() public method

Writes a 4-byte signed integer value to the underlying stream.
public Write ( int value ) : void
value int
return void

Write() public method

Writes a 1-byte signed integer value to the underlying stream.
public Write ( sbyte value ) : void
value sbyte
return void

Write() public method

Writes a 2-byte signed integer value to the underlying stream.
public Write ( short value ) : void
value short
return void

Write() public method

Writes a 4-byte unsigned integer value to the underlying stream.
public Write ( uint value ) : void
value uint
return void

Write() public method

Writes a 2-byte unsigned integer value to the underlying stream.
public Write ( ushort value ) : void
value ushort
return void

WriteAsciiFixed() public method

Writes a fixed-length ASCII-encoded string value to the underlying stream. To fit (size), the string content is either truncated or padded with null characters.
public WriteAsciiFixed ( string value, int size ) : void
value string
size int
return void

WriteAsciiNull() public method

Writes a dynamic-length ASCII-encoded string value to the underlying stream, followed by a 1-byte null character.
public WriteAsciiNull ( string value ) : void
value string
return void

WriteBigUniFixed() public method

Writes a fixed-length big-endian unicode string value to the underlying stream. To fit (size), the string content is either truncated or padded with null characters.
public WriteBigUniFixed ( string value, int size ) : void
value string
size int
return void

WriteBigUniNull() public method

Writes a dynamic-length big-endian unicode string value to the underlying stream, followed by a 2-byte null character.
public WriteBigUniNull ( string value ) : void
value string
return void

WriteLittleUniFixed() public method

Writes a fixed-length little-endian unicode string value to the underlying stream. To fit (size), the string content is either truncated or padded with null characters.
public WriteLittleUniFixed ( string value, int size ) : void
value string
size int
return void

WriteLittleUniNull() public method

Writes a dynamic-length little-endian unicode string value to the underlying stream, followed by a 2-byte null character.
public WriteLittleUniNull ( string value ) : void
value string
return void

WriteUTF8Null() public method

Writes a dynamic-length UTF8-encoded string value to the underlying stream, followed by a 1-byte null character.
public WriteUTF8Null ( string value ) : void
value string
return void