Files
2026-06-04 11:42:34 +02:00

775 lines
20 KiB
C#

using System;
using System.IO;
using System.Text;
namespace Google.Protobuf
{
// Token: 0x02000005 RID: 5
public sealed class CodedOutputStream : IDisposable
{
// Token: 0x06000054 RID: 84 RVA: 0x0000322E File Offset: 0x0000142E
public static int ComputeDoubleSize(double value)
{
return 8;
}
// Token: 0x06000055 RID: 85 RVA: 0x00003231 File Offset: 0x00001431
public static int ComputeFloatSize(float value)
{
return 4;
}
// Token: 0x06000056 RID: 86 RVA: 0x00003234 File Offset: 0x00001434
public static int ComputeUInt64Size(ulong value)
{
return CodedOutputStream.ComputeRawVarint64Size(value);
}
// Token: 0x06000057 RID: 87 RVA: 0x00003234 File Offset: 0x00001434
public static int ComputeInt64Size(long value)
{
return CodedOutputStream.ComputeRawVarint64Size((ulong)value);
}
// Token: 0x06000058 RID: 88 RVA: 0x0000323C File Offset: 0x0000143C
public static int ComputeInt32Size(int value)
{
if (value >= 0)
{
return CodedOutputStream.ComputeRawVarint32Size((uint)value);
}
return 10;
}
// Token: 0x06000059 RID: 89 RVA: 0x0000322E File Offset: 0x0000142E
public static int ComputeFixed64Size(ulong value)
{
return 8;
}
// Token: 0x0600005A RID: 90 RVA: 0x00003231 File Offset: 0x00001431
public static int ComputeFixed32Size(uint value)
{
return 4;
}
// Token: 0x0600005B RID: 91 RVA: 0x0000324B File Offset: 0x0000144B
public static int ComputeBoolSize(bool value)
{
return 1;
}
// Token: 0x0600005C RID: 92 RVA: 0x00003250 File Offset: 0x00001450
public static int ComputeStringSize(string value)
{
int byteCount = CodedOutputStream.Utf8Encoding.GetByteCount(value);
return CodedOutputStream.ComputeLengthSize(byteCount) + byteCount;
}
// Token: 0x0600005D RID: 93 RVA: 0x00003271 File Offset: 0x00001471
public static int ComputeGroupSize(IMessage value)
{
return value.CalculateSize();
}
// Token: 0x0600005E RID: 94 RVA: 0x0000327C File Offset: 0x0000147C
public static int ComputeMessageSize(IMessage value)
{
int num = value.CalculateSize();
return CodedOutputStream.ComputeLengthSize(num) + num;
}
// Token: 0x0600005F RID: 95 RVA: 0x00003298 File Offset: 0x00001498
public static int ComputeBytesSize(ByteString value)
{
return CodedOutputStream.ComputeLengthSize(value.Length) + value.Length;
}
// Token: 0x06000060 RID: 96 RVA: 0x000032AC File Offset: 0x000014AC
public static int ComputeUInt32Size(uint value)
{
return CodedOutputStream.ComputeRawVarint32Size(value);
}
// Token: 0x06000061 RID: 97 RVA: 0x000032B4 File Offset: 0x000014B4
public static int ComputeEnumSize(int value)
{
return CodedOutputStream.ComputeInt32Size(value);
}
// Token: 0x06000062 RID: 98 RVA: 0x00003231 File Offset: 0x00001431
public static int ComputeSFixed32Size(int value)
{
return 4;
}
// Token: 0x06000063 RID: 99 RVA: 0x0000322E File Offset: 0x0000142E
public static int ComputeSFixed64Size(long value)
{
return 8;
}
// Token: 0x06000064 RID: 100 RVA: 0x000032BC File Offset: 0x000014BC
public static int ComputeSInt32Size(int value)
{
return CodedOutputStream.ComputeRawVarint32Size(CodedOutputStream.EncodeZigZag32(value));
}
// Token: 0x06000065 RID: 101 RVA: 0x000032C9 File Offset: 0x000014C9
public static int ComputeSInt64Size(long value)
{
return CodedOutputStream.ComputeRawVarint64Size(CodedOutputStream.EncodeZigZag64(value));
}
// Token: 0x06000066 RID: 102 RVA: 0x000032AC File Offset: 0x000014AC
public static int ComputeLengthSize(int length)
{
return CodedOutputStream.ComputeRawVarint32Size((uint)length);
}
// Token: 0x06000067 RID: 103 RVA: 0x000032D6 File Offset: 0x000014D6
public static int ComputeRawVarint32Size(uint value)
{
if ((value & 4294967168U) == 0U)
{
return 1;
}
if ((value & 4294950912U) == 0U)
{
return 2;
}
if ((value & 4292870144U) == 0U)
{
return 3;
}
if ((value & 4026531840U) == 0U)
{
return 4;
}
return 5;
}
// Token: 0x06000068 RID: 104 RVA: 0x00003304 File Offset: 0x00001504
public static int ComputeRawVarint64Size(ulong value)
{
if ((value & 18446744073709551488UL) == 0UL)
{
return 1;
}
if ((value & 18446744073709535232UL) == 0UL)
{
return 2;
}
if ((value & 18446744073707454464UL) == 0UL)
{
return 3;
}
if ((value & 18446744073441116160UL) == 0UL)
{
return 4;
}
if ((value & 18446744039349813248UL) == 0UL)
{
return 5;
}
if ((value & 18446739675663040512UL) == 0UL)
{
return 6;
}
if ((value & 18446181123756130304UL) == 0UL)
{
return 7;
}
if ((value & 18374686479671623680UL) == 0UL)
{
return 8;
}
if ((value & 9223372036854775808UL) == 0UL)
{
return 9;
}
return 10;
}
// Token: 0x06000069 RID: 105 RVA: 0x0000338C File Offset: 0x0000158C
public static int ComputeTagSize(int fieldNumber)
{
return CodedOutputStream.ComputeRawVarint32Size(WireFormat.MakeTag(fieldNumber, WireFormat.WireType.Varint));
}
// Token: 0x0600006A RID: 106 RVA: 0x0000339A File Offset: 0x0000159A
public CodedOutputStream(byte[] flatArray)
: this(flatArray, 0, flatArray.Length)
{
}
// Token: 0x0600006B RID: 107 RVA: 0x000033A7 File Offset: 0x000015A7
private CodedOutputStream(byte[] buffer, int offset, int length)
{
this.output = null;
this.buffer = buffer;
this.position = offset;
this.limit = offset + length;
this.leaveOpen = true;
}
// Token: 0x0600006C RID: 108 RVA: 0x000033D4 File Offset: 0x000015D4
private CodedOutputStream(Stream output, byte[] buffer, bool leaveOpen)
{
this.output = ProtoPreconditions.CheckNotNull<Stream>(output, "output");
this.buffer = buffer;
this.position = 0;
this.limit = buffer.Length;
this.leaveOpen = leaveOpen;
}
// Token: 0x0600006D RID: 109 RVA: 0x0000340B File Offset: 0x0000160B
public CodedOutputStream(Stream output)
: this(output, CodedOutputStream.DefaultBufferSize, false)
{
}
// Token: 0x0600006E RID: 110 RVA: 0x0000341A File Offset: 0x0000161A
public CodedOutputStream(Stream output, int bufferSize)
: this(output, new byte[bufferSize], false)
{
}
// Token: 0x0600006F RID: 111 RVA: 0x0000342A File Offset: 0x0000162A
public CodedOutputStream(Stream output, bool leaveOpen)
: this(output, CodedOutputStream.DefaultBufferSize, leaveOpen)
{
}
// Token: 0x06000070 RID: 112 RVA: 0x00003439 File Offset: 0x00001639
public CodedOutputStream(Stream output, int bufferSize, bool leaveOpen)
: this(output, new byte[bufferSize], leaveOpen)
{
}
// Token: 0x1700000B RID: 11
// (get) Token: 0x06000071 RID: 113 RVA: 0x00003449 File Offset: 0x00001649
public long Position
{
get
{
if (this.output != null)
{
return this.output.Position + (long)this.position;
}
return (long)this.position;
}
}
// Token: 0x06000072 RID: 114 RVA: 0x0000346E File Offset: 0x0000166E
public void WriteDouble(double value)
{
this.WriteRawLittleEndian64((ulong)BitConverter.DoubleToInt64Bits(value));
}
// Token: 0x06000073 RID: 115 RVA: 0x0000347C File Offset: 0x0000167C
public void WriteFloat(float value)
{
byte[] bytes = BitConverter.GetBytes(value);
if (!BitConverter.IsLittleEndian)
{
ByteArray.Reverse(bytes);
}
if (this.limit - this.position >= 4)
{
byte[] array = this.buffer;
int num = this.position;
this.position = num + 1;
array[num] = bytes[0];
byte[] array2 = this.buffer;
num = this.position;
this.position = num + 1;
array2[num] = bytes[1];
byte[] array3 = this.buffer;
num = this.position;
this.position = num + 1;
array3[num] = bytes[2];
byte[] array4 = this.buffer;
num = this.position;
this.position = num + 1;
array4[num] = bytes[3];
return;
}
this.WriteRawBytes(bytes, 0, 4);
}
// Token: 0x06000074 RID: 116 RVA: 0x00003523 File Offset: 0x00001723
public void WriteUInt64(ulong value)
{
this.WriteRawVarint64(value);
}
// Token: 0x06000075 RID: 117 RVA: 0x00003523 File Offset: 0x00001723
public void WriteInt64(long value)
{
this.WriteRawVarint64((ulong)value);
}
// Token: 0x06000076 RID: 118 RVA: 0x0000352C File Offset: 0x0000172C
public void WriteInt32(int value)
{
if (value >= 0)
{
this.WriteRawVarint32((uint)value);
return;
}
this.WriteRawVarint64((ulong)((long)value));
}
// Token: 0x06000077 RID: 119 RVA: 0x00003542 File Offset: 0x00001742
public void WriteFixed64(ulong value)
{
this.WriteRawLittleEndian64(value);
}
// Token: 0x06000078 RID: 120 RVA: 0x0000354B File Offset: 0x0000174B
public void WriteFixed32(uint value)
{
this.WriteRawLittleEndian32(value);
}
// Token: 0x06000079 RID: 121 RVA: 0x00003554 File Offset: 0x00001754
public void WriteBool(bool value)
{
this.WriteRawByte(value ? 1 : 0);
}
// Token: 0x0600007A RID: 122 RVA: 0x00003564 File Offset: 0x00001764
public void WriteString(string value)
{
int byteCount = CodedOutputStream.Utf8Encoding.GetByteCount(value);
this.WriteLength(byteCount);
if (this.limit - this.position >= byteCount)
{
if (byteCount == value.Length)
{
for (int i = 0; i < byteCount; i++)
{
this.buffer[this.position + i] = (byte)value[i];
}
}
else
{
CodedOutputStream.Utf8Encoding.GetBytes(value, 0, value.Length, this.buffer, this.position);
}
this.position += byteCount;
return;
}
byte[] bytes = CodedOutputStream.Utf8Encoding.GetBytes(value);
this.WriteRawBytes(bytes);
}
// Token: 0x0600007B RID: 123 RVA: 0x00003603 File Offset: 0x00001803
public void WriteMessage(IMessage value)
{
this.WriteLength(value.CalculateSize());
value.WriteTo(this);
}
// Token: 0x0600007C RID: 124 RVA: 0x00003618 File Offset: 0x00001818
public void WriteBytes(ByteString value)
{
this.WriteLength(value.Length);
value.WriteRawBytesTo(this);
}
// Token: 0x0600007D RID: 125 RVA: 0x0000362D File Offset: 0x0000182D
public void WriteUInt32(uint value)
{
this.WriteRawVarint32(value);
}
// Token: 0x0600007E RID: 126 RVA: 0x00003636 File Offset: 0x00001836
public void WriteEnum(int value)
{
this.WriteInt32(value);
}
// Token: 0x0600007F RID: 127 RVA: 0x0000354B File Offset: 0x0000174B
public void WriteSFixed32(int value)
{
this.WriteRawLittleEndian32((uint)value);
}
// Token: 0x06000080 RID: 128 RVA: 0x00003542 File Offset: 0x00001742
public void WriteSFixed64(long value)
{
this.WriteRawLittleEndian64((ulong)value);
}
// Token: 0x06000081 RID: 129 RVA: 0x0000363F File Offset: 0x0000183F
public void WriteSInt32(int value)
{
this.WriteRawVarint32(CodedOutputStream.EncodeZigZag32(value));
}
// Token: 0x06000082 RID: 130 RVA: 0x0000364D File Offset: 0x0000184D
public void WriteSInt64(long value)
{
this.WriteRawVarint64(CodedOutputStream.EncodeZigZag64(value));
}
// Token: 0x06000083 RID: 131 RVA: 0x0000362D File Offset: 0x0000182D
public void WriteLength(int length)
{
this.WriteRawVarint32((uint)length);
}
// Token: 0x06000084 RID: 132 RVA: 0x0000365B File Offset: 0x0000185B
public void WriteTag(int fieldNumber, WireFormat.WireType type)
{
this.WriteRawVarint32(WireFormat.MakeTag(fieldNumber, type));
}
// Token: 0x06000085 RID: 133 RVA: 0x0000362D File Offset: 0x0000182D
public void WriteTag(uint tag)
{
this.WriteRawVarint32(tag);
}
// Token: 0x06000086 RID: 134 RVA: 0x0000366A File Offset: 0x0000186A
public void WriteRawTag(byte b1)
{
this.WriteRawByte(b1);
}
// Token: 0x06000087 RID: 135 RVA: 0x00003673 File Offset: 0x00001873
public void WriteRawTag(byte b1, byte b2)
{
this.WriteRawByte(b1);
this.WriteRawByte(b2);
}
// Token: 0x06000088 RID: 136 RVA: 0x00003683 File Offset: 0x00001883
public void WriteRawTag(byte b1, byte b2, byte b3)
{
this.WriteRawByte(b1);
this.WriteRawByte(b2);
this.WriteRawByte(b3);
}
// Token: 0x06000089 RID: 137 RVA: 0x0000369A File Offset: 0x0000189A
public void WriteRawTag(byte b1, byte b2, byte b3, byte b4)
{
this.WriteRawByte(b1);
this.WriteRawByte(b2);
this.WriteRawByte(b3);
this.WriteRawByte(b4);
}
// Token: 0x0600008A RID: 138 RVA: 0x000036B9 File Offset: 0x000018B9
public void WriteRawTag(byte b1, byte b2, byte b3, byte b4, byte b5)
{
this.WriteRawByte(b1);
this.WriteRawByte(b2);
this.WriteRawByte(b3);
this.WriteRawByte(b4);
this.WriteRawByte(b5);
}
// Token: 0x0600008B RID: 139 RVA: 0x000036E0 File Offset: 0x000018E0
internal void WriteRawVarint32(uint value)
{
if (value < 128U && this.position < this.limit)
{
byte[] array = this.buffer;
int num = this.position;
this.position = num + 1;
array[num] = (byte)value;
return;
}
while (value > 127U)
{
if (this.position >= this.limit)
{
break;
}
byte[] array2 = this.buffer;
int num = this.position;
this.position = num + 1;
array2[num] = (byte)((value & 127U) | 128U);
value >>= 7;
}
while (value > 127U)
{
this.WriteRawByte((byte)((value & 127U) | 128U));
value >>= 7;
}
if (this.position < this.limit)
{
byte[] array3 = this.buffer;
int num = this.position;
this.position = num + 1;
array3[num] = (byte)value;
return;
}
this.WriteRawByte((byte)value);
}
// Token: 0x0600008C RID: 140 RVA: 0x000037A8 File Offset: 0x000019A8
internal void WriteRawVarint64(ulong value)
{
while (value > 127UL)
{
if (this.position >= this.limit)
{
break;
}
byte[] array = this.buffer;
int num = this.position;
this.position = num + 1;
array[num] = (byte)((value & 127UL) | 128UL);
value >>= 7;
}
while (value > 127UL)
{
this.WriteRawByte((byte)((value & 127UL) | 128UL));
value >>= 7;
}
if (this.position < this.limit)
{
byte[] array2 = this.buffer;
int num = this.position;
this.position = num + 1;
array2[num] = (byte)value;
return;
}
this.WriteRawByte((byte)value);
}
// Token: 0x0600008D RID: 141 RVA: 0x00003848 File Offset: 0x00001A48
internal void WriteRawLittleEndian32(uint value)
{
if (this.position + 4 > this.limit)
{
this.WriteRawByte((byte)value);
this.WriteRawByte((byte)(value >> 8));
this.WriteRawByte((byte)(value >> 16));
this.WriteRawByte((byte)(value >> 24));
return;
}
byte[] array = this.buffer;
int num = this.position;
this.position = num + 1;
array[num] = (byte)value;
byte[] array2 = this.buffer;
num = this.position;
this.position = num + 1;
array2[num] = (byte)(value >> 8);
byte[] array3 = this.buffer;
num = this.position;
this.position = num + 1;
array3[num] = (byte)(value >> 16);
byte[] array4 = this.buffer;
num = this.position;
this.position = num + 1;
array4[num] = (byte)(value >> 24);
}
// Token: 0x0600008E RID: 142 RVA: 0x00003900 File Offset: 0x00001B00
internal void WriteRawLittleEndian64(ulong value)
{
if (this.position + 8 > this.limit)
{
this.WriteRawByte((byte)value);
this.WriteRawByte((byte)(value >> 8));
this.WriteRawByte((byte)(value >> 16));
this.WriteRawByte((byte)(value >> 24));
this.WriteRawByte((byte)(value >> 32));
this.WriteRawByte((byte)(value >> 40));
this.WriteRawByte((byte)(value >> 48));
this.WriteRawByte((byte)(value >> 56));
return;
}
byte[] array = this.buffer;
int num = this.position;
this.position = num + 1;
array[num] = (byte)value;
byte[] array2 = this.buffer;
num = this.position;
this.position = num + 1;
array2[num] = (byte)(value >> 8);
byte[] array3 = this.buffer;
num = this.position;
this.position = num + 1;
array3[num] = (byte)(value >> 16);
byte[] array4 = this.buffer;
num = this.position;
this.position = num + 1;
array4[num] = (byte)(value >> 24);
byte[] array5 = this.buffer;
num = this.position;
this.position = num + 1;
array5[num] = (byte)(value >> 32);
byte[] array6 = this.buffer;
num = this.position;
this.position = num + 1;
array6[num] = (byte)(value >> 40);
byte[] array7 = this.buffer;
num = this.position;
this.position = num + 1;
array7[num] = (byte)(value >> 48);
byte[] array8 = this.buffer;
num = this.position;
this.position = num + 1;
array8[num] = (byte)(value >> 56);
}
// Token: 0x0600008F RID: 143 RVA: 0x00003A58 File Offset: 0x00001C58
internal void WriteRawByte(byte value)
{
if (this.position == this.limit)
{
this.RefreshBuffer();
}
byte[] array = this.buffer;
int num = this.position;
this.position = num + 1;
array[num] = value;
}
// Token: 0x06000090 RID: 144 RVA: 0x00003A92 File Offset: 0x00001C92
internal void WriteRawByte(uint value)
{
this.WriteRawByte((byte)value);
}
// Token: 0x06000091 RID: 145 RVA: 0x00003A9C File Offset: 0x00001C9C
internal void WriteRawBytes(byte[] value)
{
this.WriteRawBytes(value, 0, value.Length);
}
// Token: 0x06000092 RID: 146 RVA: 0x00003AAC File Offset: 0x00001CAC
internal void WriteRawBytes(byte[] value, int offset, int length)
{
if (this.limit - this.position >= length)
{
ByteArray.Copy(value, offset, this.buffer, this.position, length);
this.position += length;
return;
}
int num = this.limit - this.position;
ByteArray.Copy(value, offset, this.buffer, this.position, num);
offset += num;
length -= num;
this.position = this.limit;
this.RefreshBuffer();
if (length <= this.limit)
{
ByteArray.Copy(value, offset, this.buffer, 0, length);
this.position = length;
return;
}
this.output.Write(value, offset, length);
}
// Token: 0x06000093 RID: 147 RVA: 0x00003B58 File Offset: 0x00001D58
internal static uint EncodeZigZag32(int n)
{
return (uint)((n << 1) ^ (n >> 31));
}
// Token: 0x06000094 RID: 148 RVA: 0x00003B62 File Offset: 0x00001D62
internal static ulong EncodeZigZag64(long n)
{
return (ulong)((n << 1) ^ (n >> 63));
}
// Token: 0x06000095 RID: 149 RVA: 0x00003B6C File Offset: 0x00001D6C
private void RefreshBuffer()
{
if (this.output == null)
{
throw new CodedOutputStream.OutOfSpaceException();
}
this.output.Write(this.buffer, 0, this.position);
this.position = 0;
}
// Token: 0x06000096 RID: 150 RVA: 0x00003B9B File Offset: 0x00001D9B
public void Dispose()
{
this.Flush();
if (!this.leaveOpen)
{
this.output.Dispose();
}
}
// Token: 0x06000097 RID: 151 RVA: 0x00003BB6 File Offset: 0x00001DB6
public void Flush()
{
if (this.output != null)
{
this.RefreshBuffer();
}
}
// Token: 0x06000098 RID: 152 RVA: 0x00003BC6 File Offset: 0x00001DC6
public void CheckNoSpaceLeft()
{
if (this.SpaceLeft != 0)
{
throw new InvalidOperationException("Did not write as much data as expected.");
}
}
// Token: 0x1700000C RID: 12
// (get) Token: 0x06000099 RID: 153 RVA: 0x00003BDB File Offset: 0x00001DDB
public int SpaceLeft
{
get
{
if (this.output == null)
{
return this.limit - this.position;
}
throw new InvalidOperationException("SpaceLeft can only be called on CodedOutputStreams that are writing to a flat array.");
}
}
// Token: 0x04000015 RID: 21
private const int LittleEndian64Size = 8;
// Token: 0x04000016 RID: 22
private const int LittleEndian32Size = 4;
// Token: 0x04000017 RID: 23
internal static readonly Encoding Utf8Encoding = Encoding.UTF8;
// Token: 0x04000018 RID: 24
public static readonly int DefaultBufferSize = 4096;
// Token: 0x04000019 RID: 25
private readonly bool leaveOpen;
// Token: 0x0400001A RID: 26
private readonly byte[] buffer;
// Token: 0x0400001B RID: 27
private readonly int limit;
// Token: 0x0400001C RID: 28
private int position;
// Token: 0x0400001D RID: 29
private readonly Stream output;
// Token: 0x02000074 RID: 116
public sealed class OutOfSpaceException : IOException
{
// Token: 0x06000671 RID: 1649 RVA: 0x00016268 File Offset: 0x00014468
internal OutOfSpaceException()
: base("CodedOutputStream was writing to a flat byte array and ran out of space.")
{
}
}
}
}