Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Encode()

static bool System.Net.Http.HPack.IntegerEncoder.Encode ( int value,
int numBits,
Span< byte > destination,
out int bytesWritten )
inlinestatic

Definition at line 5 of file IntegerEncoder.cs.

6 {
7 if (destination.Length == 0)
8 {
9 bytesWritten = 0;
10 return false;
11 }
12 destination[0] &= MaskHigh(8 - numBits);
13 if (value < (1 << numBits) - 1)
14 {
15 destination[0] |= (byte)value;
16 bytesWritten = 1;
17 return true;
18 }
19 destination[0] |= (byte)((1 << numBits) - 1);
20 if (1 == destination.Length)
21 {
22 bytesWritten = 0;
23 return false;
24 }
25 value -= (1 << numBits) - 1;
26 int num = 1;
27 while (value >= 128)
28 {
29 destination[num++] = (byte)(value % 128 + 128);
30 if (num >= destination.Length)
31 {
32 bytesWritten = 0;
33 return false;
34 }
35 value /= 128;
36 }
37 destination[num++] = (byte)value;
38 bytesWritten = num;
39 return true;
40 }

References System.destination, System.Net.Http.HPack.IntegerEncoder.MaskHigh(), and System.value.

Referenced by System.Net.Http.HPack.HPackEncoder.EncodeIndexedHeaderField(), System.Net.Http.HPack.HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexing(), System.Net.Http.HPack.HPackEncoder.EncodeLiteralHeaderFieldWithoutIndexing(), System.Net.Http.QPack.QPackEncoder.EncodeLiteralHeaderFieldWithStaticNameReference(), System.Net.Http.QPack.QPackEncoder.EncodeLiteralHeaderFieldWithStaticNameReferenceToArray(), System.Net.Http.HPack.HPackEncoder.EncodeLiteralHeaderName(), System.Net.Http.QPack.QPackEncoder.EncodeNameString(), System.Net.Http.QPack.QPackEncoder.EncodeStaticIndexedHeaderField(), System.Net.Http.HPack.HPackEncoder.EncodeStringLiteral(), System.Net.Http.HPack.HPackEncoder.EncodeStringLiterals(), System.Net.Http.QPack.QPackEncoder.EncodeValueString(), and System.Net.Http.QPack.QPackEncoder.EncodeValueString().