You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The ByteArrayPacker tracks buffer usage (used bytes, current index of the list and offset of the current array).
87
-
// In general, you bookkeep CurrentBufferIndex and CurrentBufferOffset for next Packer.Create call's startIndex and startOffset respectively.
88
-
Console.WriteLine("Packed {0:#,0}bytes. Now buffer position is index:{1}, offset:{2}",bytePacker.BytesUsed,bytePacker.CurrentBufferIndex,bytePacker.CurrentBufferOffset);
// The ByteArrayUnpacker tracks buffer usage (used bytes, current index of the list and offset of the current array).
94
-
Console.WriteLine("Unpacked {0:#,0}bytes. Now buffer position is index:{1}, offset:{2}",byteUnpacker.BytesUsed,byteUnpacker.CurrentSourceIndex,byteUnpacker.CurrentSourceOffset);
Copy file name to clipboardExpand all lines: src/MsgPack/ByteArrayPacker.cs
+15-90Lines changed: 15 additions & 90 deletions
Original file line number
Diff line number
Diff line change
@@ -39,37 +39,16 @@ public abstract class ByteArrayPacker : Packer
39
39
/// <value>
40
40
/// The bytes used by this instance. The initial state is <c>0</c>.
41
41
/// </value>
42
-
publicabstractlongBytesUsed{get;}
42
+
publicabstractintBytesUsed{get;}
43
43
44
44
/// <summary>
45
-
/// Gets the initial index of destination buffers.
45
+
/// Gets the initial offset of the destination buffer.
46
46
/// </summary>
47
47
/// <value>
48
-
/// The initial index of destination buffers.
49
-
/// This value is greater than or equal to <c>0</c>,
50
-
/// and less than the <see cref="ICollection{T}.Count"/> of the result of <see cref="GetFinalBuffers()"/>.
48
+
/// The initial index of the destination buffer.
49
+
/// This value is greater than or equal to <c>0</c> and less than the destination buffer's length.
51
50
/// </value>
52
-
publicabstractintInitialBufferIndex{get;}
53
-
54
-
/// <summary>
55
-
/// Gets the current index of destination buffers.
56
-
/// </summary>
57
-
/// <value>
58
-
/// The current index of destination buffers.
59
-
/// This value is greater than or equal to <c>0</c>,
60
-
/// and less than the <see cref="ICollection{T}.Count"/> of the result of <see cref="GetFinalBuffers()"/>.
61
-
/// </value>
62
-
publicabstractintCurrentBufferIndex{get;}
63
-
64
-
/// <summary>
65
-
/// Gets the current offset of the current destination buffer.
66
-
/// </summary>
67
-
/// <value>
68
-
/// The current offset of the current destination buffer.
69
-
/// This value is greater than or equal to <see cref="ArraySegment{T}.Offset"/> of an item of <see cref="GetFinalBuffers()"/> in index <see cref="CurrentBufferIndex"/>
70
-
/// and less than the length of the <see cref="ArraySegment{T}.Array"/> of it.
71
-
/// </value>
72
-
publicabstractintCurrentBufferOffset{get;}
51
+
publicabstractintInitialBufferOffset{get;}
73
52
74
53
/// <summary>
75
54
/// Initializes a new instance of the <see cref="ByteArrayPacker"/> class.
/// Gets the final effective (written) bytes as single array.
66
+
/// Gets the final effective (written) bytes as single array segment.
88
67
/// </summary>
89
-
/// <returns>The final buffers as single array. Its size will be <see cref="BytesUsed"/>.</returns>
90
-
/// <exception cref="InvalidOperationException">Buffer is too large for single array.</exception>
68
+
/// <returns>The final buffers as single <see cref="ArraySegment{T}"/>. Its size will be <see cref="BytesUsed"/>.</returns>
91
69
/// <remarks>
92
-
/// If the packer was allowed re-allocation, you can get final byte array from this method.
93
-
/// Otherwise, the returned buffer contains only last successful operation.
94
-
/// Note that there are no guarantee about the returned array is copied from the original buffer.
70
+
/// The result segment contains the array returned from <see cref="GetFinalBuffer()"/>, and reflects <see cref="InitialBufferOffset"/> and <see cref="BytesUsed"/>.
0 commit comments