Space Engineers
|
Stream which writes data based on bits. When writing, buffer must be reset to zero to write values correctly, this is done by ResetWrite() methods or SetPositionAndClearForward() More...
Public Member Functions | |
BitStream (int defaultByteSize=1536) | |
void | Dispose () |
void | ReleaseInternalBuffer () |
void | ResetRead () |
Resets stream for reading (reads what was written so far). More... | |
void | ResetRead (byte[] data, int bitLength) |
Resets stream for reading and copies data. More... | |
void | ResetRead (byte[] data, int byteOffset, int bitLength, bool copy=true) |
Resets stream for reading and copies data. More... | |
void | ResetRead (IntPtr buffer, int bitLength, bool copy) |
Resets stream for reading. More... | |
void | ResetWrite () |
Resets stream for writing. Uses internal buffer for writing, it's available as DataPointer. More... | |
void | ResetWrite (BitStream stream) |
void | Serialize (ref double value) |
void | Serialize (ref float value) |
void | Serialize (ref decimal value) |
void | Serialize (ref bool value) |
void | Serialize (ref sbyte value, int bitCount=sizeof(sbyte)*8) |
void | Serialize (ref short value, int bitCount=sizeof(short)*8) |
void | Serialize (ref int value, int bitCount=sizeof(int)*8) |
void | Serialize (ref long value, int bitCount=sizeof(long)*8) |
void | Serialize (ref byte value, int bitCount=sizeof(byte)*8) |
void | Serialize (ref ushort value, int bitCount=sizeof(ushort)*8) |
void | Serialize (ref uint value, int bitCount=sizeof(uint)*8) |
void | Serialize (ref ulong value, int bitCount=sizeof(ulong)*8) |
void | SerializeVariant (ref int value) |
Efficiently serializes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8 192 to 8 191 (inclusive), 16 bits. From -1 048 576 to 1 048 575, 24 bits. From -134 217 728 to 134 217 727, 32 bits. Otherwise 40 bits. More... | |
void | SerializeVariant (ref long value) |
Efficiently serializes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8192 to 8191 (inclusive), 16 bits. From -1048576 to 1048575, 24 bits. From -134217728 to 134217727, 32 bits. Etc... More... | |
void | SerializeVariant (ref uint value) |
Efficiently serializes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Otherwise 40 bits. More... | |
void | SerializeVariant (ref ulong value) |
Efficiently serializes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Etc... More... | |
void | Serialize (ref char value) |
Writes char as UTF16, 2-byte value. For ASCII or different encoding, use SerializeByte() or SerializeBytes(). More... | |
void | Serialize (StringBuilder value, ref char[] tmpArray, Encoding encoding) |
void | SerializeMemory (IntPtr ptr, int bitSize) |
Serializes fixed size memory region. More... | |
unsafe void | SerializeMemory (void *ptr, int bitSize) |
Serializes fixed size memory region. More... | |
void | SerializePrefixString (ref string str, Encoding encoding) |
Serializes string length (as UInt32 variant) and string itself in defined encoding. More... | |
void | SerializePrefixStringAscii (ref string str) |
Serializes string length (as UInt32 variant) and string itself encoded with ASCII encoding. More... | |
void | SerializePrefixStringUtf8 (ref string str) |
Serializes string length (as UInt32 variant) and string itself encoded with UTF8 encoding. More... | |
void | SerializePrefixBytes (ref byte[] bytes) |
Serializes byte array length (as UInt32 variant) and bytes. More... | |
void | SerializeBytes (ref byte[] bytes, int start, int count) |
Serializes fixed-size byte array or it's part (length is NOT serialized). More... | |
void | Terminate () |
void | CheckTerminator () |
Type | ReadDynamicType (Type baseType, DynamicSerializerDelegate typeResolver) |
void | WriteDynamicType (Type baseType, Type obj, DynamicSerializerDelegate typeResolver) |
void | SetBitPositionRead (int newReadBitPosition) |
double | ReadDouble () |
float | ReadHalf () |
float | ReadFloat () |
float | ReadNormalizedSignedFloat (int bits) |
Reads uniform-spaced float within -1,1 range with specified number of bits. More... | |
decimal | ReadDecimal () |
bool | ReadBool () |
sbyte | ReadSByte (int bitCount=sizeof(sbyte)*8) |
short | ReadInt16 (int bitCount=sizeof(short)*8) |
int | ReadInt32 (int bitCount=sizeof(int)*8) |
long | ReadInt64 (int bitCount=sizeof(long)*8) |
byte | ReadByte (int bitCount=sizeof(byte)*8) |
ushort | ReadUInt16 (int bitCount=sizeof(ushort)*8) |
uint | ReadUInt32 (int bitCount=sizeof(uint)*8) |
ulong | ReadUInt64 (int bitCount=sizeof(ulong)*8) |
int | ReadInt32Variant () |
long | ReadInt64Variant () |
uint | ReadUInt32Variant () |
ulong | ReadUInt64Variant () |
char | ReadChar (int bitCount=sizeof(char)*8) |
void | ReadMemory (IntPtr ptr, int bitSize) |
void | ReadMemory (void *ptr, int bitSize) |
string | ReadPrefixLengthString (Encoding encoding) |
int | ReadPrefixLengthString (ref char[] value, Encoding encoding) |
Reads prefixed length string, returns nubmer of characters read. Passed array is automatically resized when needed. More... | |
void | ReadBytes (byte[] bytes, int start, int count) |
byte[] | ReadPrefixBytes () |
void | SetBitPositionWrite (int newBitPosition) |
Use when you need to overwrite part of the data. Sets new bit position and clears everything from min(old position, new position) to end of stream. More... | |
void | WriteDouble (double value) |
void | WriteHalf (float value) |
void | WriteFloat (float value) |
void | WriteNormalizedSignedFloat (float value, int bits) |
Writes uniform-spaced float within -1,1 range with specified number of bits. More... | |
void | WriteDecimal (decimal value) |
void | WriteBool (bool value) |
void | WriteSByte (sbyte value, int bitCount=sizeof(sbyte)*8) |
void | WriteInt16 (short value, int bitCount=sizeof(short)*8) |
void | WriteInt32 (int value, int bitCount=sizeof(int)*8) |
void | WriteInt64 (long value, int bitCount=sizeof(long)*8) |
void | WriteByte (byte value, int bitCount=sizeof(byte)*8) |
void | WriteUInt16 (ushort value, int bitCount=sizeof(ushort)*8) |
void | WriteUInt32 (uint value, int bitCount=sizeof(uint)*8) |
void | WriteUInt64 (ulong value, int bitCount=sizeof(ulong)*8) |
void | WriteVariantSigned (int value) |
Efficiently writes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8 192 to 8 191 (inclusive), 16 bits. From -1 048 576 to 1 048 575, 24 bits. From -134 217 728 to 134 217 727, 32 bits. Otherwise 40 bits. More... | |
void | WriteVariantSigned (long value) |
Efficiently writes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8192 to 8191 (inclusive), 16 bits. From -1048576 to 1048575, 24 bits. From -134217728 to 134217727, 32 bits. Etc... More... | |
void | WriteVariant (uint value) |
Efficiently writes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Otherwise 40 bits. More... | |
void | WriteVariant (ulong value) |
Efficiently writes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Etc... More... | |
void | WriteChar (char value, int bitCount=sizeof(char)*8) |
void | WriteBitStream (BitStream readStream) |
void | WriteMemory (IntPtr ptr, int bitSize) |
void | WriteMemory (void *ptr, int bitSize) |
unsafe void | WritePrefixLengthString (string str, int characterStart, int characterCount, Encoding encoding) |
unsafe void | WritePrefixLengthString (char[] str, int characterStart, int characterCount, Encoding encoding) |
void | WriteBytes (byte[] bytes, int start, int count) |
void | WritePrefixBytes (byte[] bytes, int start, int count) |
Properties | |
int | BitPosition [get] |
Read/write bit position in stream. More... | |
int | BitLength [get] |
Length of valid data (when reading) or buffer (when writing) in bits. More... | |
int | BytePosition [get] |
Position in stream round up to whole bytes. More... | |
int | ByteLength [get] |
Length of valid data (when reading) or buffer (when writing) round up to whole bytes More... | |
bool | OwnsBuffer [get] |
Returns true when owns buffers, always true when writing. May or may not own buffer when reading. More... | |
bool | Reading [get] |
bool | Writing [get] |
True when stream is for writing. More... | |
IntPtr | DataPointer [get] |
Stream which writes data based on bits. When writing, buffer must be reset to zero to write values correctly, this is done by ResetWrite() methods or SetPositionAndClearForward()
Definition at line 20 of file BitStream.cs.
|
inline |
Definition at line 73 of file BitStream.cs.
|
inline |
Definition at line 477 of file BitStream.cs.
|
inline |
Definition at line 79 of file BitStream.cs.
|
inline |
Definition at line 88 of file BitStream.Read.cs.
|
inline |
Definition at line 113 of file BitStream.Read.cs.
|
inline |
Definition at line 327 of file BitStream.Read.cs.
|
inline |
Definition at line 227 of file BitStream.Read.cs.
|
inline |
Definition at line 80 of file BitStream.Read.cs.
|
inline |
Definition at line 55 of file BitStream.Read.cs.
|
inline |
Definition at line 10 of file BitStream.Dynamic.cs.
|
inline |
Definition at line 66 of file BitStream.Read.cs.
|
inline |
Definition at line 61 of file BitStream.Read.cs.
|
inline |
Definition at line 98 of file BitStream.Read.cs.
|
inline |
Definition at line 103 of file BitStream.Read.cs.
|
inline |
Definition at line 145 of file BitStream.Read.cs.
|
inline |
Definition at line 108 of file BitStream.Read.cs.
|
inline |
Definition at line 150 of file BitStream.Read.cs.
|
inline |
Definition at line 232 of file BitStream.Read.cs.
|
inline |
Definition at line 237 of file BitStream.Read.cs.
|
inline |
Reads uniform-spaced float within -1,1 range with specified number of bits.
Definition at line 75 of file BitStream.Read.cs.
|
inline |
Definition at line 335 of file BitStream.Read.cs.
|
inline |
Definition at line 256 of file BitStream.Read.cs.
|
inline |
Reads prefixed length string, returns nubmer of characters read. Passed array is automatically resized when needed.
Definition at line 290 of file BitStream.Read.cs.
|
inline |
Definition at line 93 of file BitStream.Read.cs.
|
inline |
Definition at line 118 of file BitStream.Read.cs.
|
inline |
Definition at line 123 of file BitStream.Read.cs.
|
inline |
Definition at line 155 of file BitStream.Read.cs.
|
inline |
Definition at line 128 of file BitStream.Read.cs.
|
inline |
Definition at line 180 of file BitStream.Read.cs.
|
inline |
Definition at line 119 of file BitStream.cs.
|
inline |
Resets stream for reading (reads what was written so far).
Definition at line 137 of file BitStream.cs.
|
inline |
Resets stream for reading and copies data.
Definition at line 148 of file BitStream.cs.
|
inline |
Resets stream for reading and copies data.
Definition at line 156 of file BitStream.cs.
|
inline |
Resets stream for reading.
Definition at line 167 of file BitStream.cs.
|
inline |
Resets stream for writing. Uses internal buffer for writing, it's available as DataPointer.
Definition at line 205 of file BitStream.cs.
|
inline |
Definition at line 223 of file BitStream.cs.
|
inline |
Definition at line 244 of file BitStream.cs.
|
inline |
Definition at line 250 of file BitStream.cs.
|
inline |
Definition at line 256 of file BitStream.cs.
|
inline |
Definition at line 262 of file BitStream.cs.
|
inline |
Definition at line 268 of file BitStream.cs.
|
inline |
Definition at line 274 of file BitStream.cs.
|
inline |
Definition at line 280 of file BitStream.cs.
|
inline |
Definition at line 286 of file BitStream.cs.
|
inline |
Definition at line 292 of file BitStream.cs.
|
inline |
Definition at line 298 of file BitStream.cs.
|
inline |
Definition at line 304 of file BitStream.cs.
|
inline |
Definition at line 310 of file BitStream.cs.
|
inline |
Writes char as UTF16, 2-byte value. For ASCII or different encoding, use SerializeByte() or SerializeBytes().
Definition at line 376 of file BitStream.cs.
|
inline |
Definition at line 382 of file BitStream.cs.
|
inline |
Serializes fixed-size byte array or it's part (length is NOT serialized).
Definition at line 464 of file BitStream.cs.
|
inline |
Serializes fixed size memory region.
Definition at line 402 of file BitStream.cs.
|
inline |
Serializes fixed size memory region.
Definition at line 411 of file BitStream.cs.
|
inline |
Serializes byte array length (as UInt32 variant) and bytes.
Definition at line 446 of file BitStream.cs.
|
inline |
Serializes string length (as UInt32 variant) and string itself in defined encoding.
Definition at line 420 of file BitStream.cs.
|
inline |
Serializes string length (as UInt32 variant) and string itself encoded with ASCII encoding.
Definition at line 429 of file BitStream.cs.
|
inline |
Serializes string length (as UInt32 variant) and string itself encoded with UTF8 encoding.
str |
Definition at line 438 of file BitStream.cs.
|
inline |
Efficiently serializes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8 192 to 8 191 (inclusive), 16 bits. From -1 048 576 to 1 048 575, 24 bits. From -134 217 728 to 134 217 727, 32 bits. Otherwise 40 bits.
Definition at line 324 of file BitStream.cs.
|
inline |
Efficiently serializes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8192 to 8191 (inclusive), 16 bits. From -1048576 to 1048575, 24 bits. From -134217728 to 134217727, 32 bits. Etc...
Definition at line 338 of file BitStream.cs.
|
inline |
Efficiently serializes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Otherwise 40 bits.
Definition at line 352 of file BitStream.cs.
|
inline |
Efficiently serializes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Etc...
Definition at line 366 of file BitStream.cs.
|
inline |
Definition at line 49 of file BitStream.Read.cs.
|
inline |
Use when you need to overwrite part of the data. Sets new bit position and clears everything from min(old position, new position) to end of stream.
Definition at line 56 of file BitStream.Write.cs.
|
inline |
Definition at line 471 of file BitStream.cs.
|
inline |
Definition at line 233 of file BitStream.Write.cs.
|
inline |
Definition at line 94 of file BitStream.Write.cs.
|
inline |
Definition at line 119 of file BitStream.Write.cs.
|
inline |
Definition at line 306 of file BitStream.Write.cs.
|
inline |
Definition at line 228 of file BitStream.Write.cs.
|
inline |
Definition at line 88 of file BitStream.Write.cs.
|
inline |
Definition at line 64 of file BitStream.Write.cs.
|
inline |
Definition at line 17 of file BitStream.Dynamic.cs.
|
inline |
Definition at line 75 of file BitStream.Write.cs.
|
inline |
Definition at line 69 of file BitStream.Write.cs.
|
inline |
Definition at line 104 of file BitStream.Write.cs.
|
inline |
Definition at line 109 of file BitStream.Write.cs.
|
inline |
Definition at line 114 of file BitStream.Write.cs.
|
inline |
Definition at line 246 of file BitStream.Write.cs.
|
inline |
Definition at line 251 of file BitStream.Write.cs.
|
inline |
Writes uniform-spaced float within -1,1 range with specified number of bits.
Definition at line 83 of file BitStream.Write.cs.
|
inline |
Definition at line 314 of file BitStream.Write.cs.
|
inline |
Definition at line 270 of file BitStream.Write.cs.
|
inline |
Definition at line 278 of file BitStream.Write.cs.
|
inline |
Definition at line 99 of file BitStream.Write.cs.
|
inline |
Definition at line 124 of file BitStream.Write.cs.
|
inline |
Definition at line 129 of file BitStream.Write.cs.
|
inline |
Definition at line 134 of file BitStream.Write.cs.
|
inline |
Efficiently writes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Otherwise 40 bits.
Definition at line 183 of file BitStream.Write.cs.
|
inline |
Efficiently writes small integers. Closer to zero, less bytes. 0 - 127, 8 bits. 128 - 16383, 16 bits. 16384 - 2097151, 24 bits. 2097152 - 268435455, 32 bits. Etc...
Definition at line 206 of file BitStream.Write.cs.
|
inline |
Efficiently writes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8 192 to 8 191 (inclusive), 16 bits. From -1 048 576 to 1 048 575, 24 bits. From -134 217 728 to 134 217 727, 32 bits. Otherwise 40 bits.
Definition at line 157 of file BitStream.Write.cs.
|
inline |
Efficiently writes small integers. Closer to zero, less bytes. From -64 to 63 (inclusive), 8 bits. From -8192 to 8191 (inclusive), 16 bits. From -1048576 to 1048575, 24 bits. From -134217728 to 134217727, 32 bits. Etc...
Definition at line 170 of file BitStream.Write.cs.
|
get |
Length of valid data (when reading) or buffer (when writing) in bits.
Definition at line 43 of file BitStream.cs.
|
get |
Read/write bit position in stream.
Definition at line 38 of file BitStream.cs.
|
get |
Length of valid data (when reading) or buffer (when writing) round up to whole bytes
Definition at line 53 of file BitStream.cs.
|
get |
Position in stream round up to whole bytes.
Definition at line 48 of file BitStream.cs.
|
get |
Definition at line 69 of file BitStream.cs.
|
get |
Returns true when owns buffers, always true when writing. May or may not own buffer when reading.
Definition at line 59 of file BitStream.cs.
|
get |
Definition at line 61 of file BitStream.cs.
|
get |
True when stream is for writing.
Definition at line 66 of file BitStream.cs.