C# Class CK.Core.CKBinaryWriter

Specializes BinaryWriter to expose helpers.
Inheritance: System.IO.BinaryWriter
Datei anzeigen Open project: Invenietis/ck-core Class Usage Examples

Public Methods

Method Description
CKBinaryWriter ( Stream output ) : System

Initializes a new CKBinaryWriter based on the specified stream and using UTF-8 encoding.

CKBinaryWriter ( Stream output, Encoding encoding ) : System

Initializes a new CKBinaryWriter based on the specified stream and character encoding.

CKBinaryWriter ( Stream output, Encoding encoding, bool leaveOpen ) : System

Initializes a new CKBinaryWriter based on the specified stream and character encoding.

WriteNonNegativeSmallInt32 ( int value ) : void

Writes a 32-bit 0 or positive integer in compressed format. See remarks.

Using this method to write a negative integer is the same as using ot with a large positive number: the storage will actually require more than 4 bytes. It is perfectly valid, except that it is more "expansion" than "compression" :).

WriteNullableString ( string s ) : void

Writes a potentially null string.

WriteSmallInt32 ( int value, int minNegativeValue = -1 ) : void

Writes a 32-bit integer in compressed format, accomodating rooms for some negative values. The minNegativeValue simply offsets the written value. Use CKBinaryReader.ReadNonNegativeSmallInt32(int,int) with the same minNegativeValue to read it back.

Writing a negative value lower than the minNegativeValue is totally possible, however more than 4 bytes will be required for them.

The default value of -1 is perfect to write small integers that are greater or equal to -1.

Method Details

CKBinaryWriter() public method

Initializes a new CKBinaryWriter based on the specified stream and using UTF-8 encoding.
public CKBinaryWriter ( Stream output ) : System
output Stream The output stream.
return System

CKBinaryWriter() public method

Initializes a new CKBinaryWriter based on the specified stream and character encoding.
public CKBinaryWriter ( Stream output, Encoding encoding ) : System
output Stream The output stream.
encoding System.Text.Encoding The character encoding to use.
return System

CKBinaryWriter() public method

Initializes a new CKBinaryWriter based on the specified stream and character encoding.
public CKBinaryWriter ( Stream output, Encoding encoding, bool leaveOpen ) : System
output Stream The output stream.
encoding System.Text.Encoding The character encoding to use.
leaveOpen bool true to leave the stream open after this writer object is disposed; otherwise, false.
return System

WriteNonNegativeSmallInt32() public method

Writes a 32-bit 0 or positive integer in compressed format. See remarks.
Using this method to write a negative integer is the same as using ot with a large positive number: the storage will actually require more than 4 bytes. It is perfectly valid, except that it is more "expansion" than "compression" :).
public WriteNonNegativeSmallInt32 ( int value ) : void
value int A 32-bit integer (should not be negative).
return void

WriteNullableString() public method

Writes a potentially null string.
public WriteNullableString ( string s ) : void
s string String to write.
return void

WriteSmallInt32() public method

Writes a 32-bit integer in compressed format, accomodating rooms for some negative values. The minNegativeValue simply offsets the written value. Use CKBinaryReader.ReadNonNegativeSmallInt32(int,int) with the same minNegativeValue to read it back.

Writing a negative value lower than the minNegativeValue is totally possible, however more than 4 bytes will be required for them.

The default value of -1 is perfect to write small integers that are greater or equal to -1.

public WriteSmallInt32 ( int value, int minNegativeValue = -1 ) : void
value int A 32-bit integer (greater or equal to ).
minNegativeValue int Lowest possible negative value.
return void