1 #region Copyright notice and license 2 // Protocol Buffers - Google's data interchange format 3 // Copyright 2008 Google Inc. All rights reserved. 4 // 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file or at 7 // https://developers.google.com/open-source/licenses/bsd 8 #endregion 9 10 namespace Google.Protobuf 11 { 12 // warning: this is a mutable struct, so it needs to be only passed as a ref! 13 internal struct ParserInternalState 14 { 15 // NOTE: the Span representing the current buffer is kept separate so that this doesn't have to be a ref struct and so it can 16 // be included in CodedInputStream's internal state 17 18 /// <summary> 19 /// The position within the current buffer (i.e. the next byte to read) 20 /// </summary> 21 internal int bufferPos; 22 23 /// <summary> 24 /// Size of the current buffer 25 /// </summary> 26 internal int bufferSize; 27 28 /// <summary> 29 /// If we are currently inside a length-delimited block, this is the number of 30 /// bytes in the buffer that are still available once we leave the delimited block. 31 /// </summary> 32 internal int bufferSizeAfterLimit; 33 34 /// <summary> 35 /// The absolute position of the end of the current length-delimited block (including totalBytesRetired) 36 /// </summary> 37 internal int currentLimit; 38 39 /// <summary> 40 /// The total number of consumed before the start of the current buffer. The 41 /// total bytes read up to the current position can be computed as 42 /// totalBytesRetired + bufferPos. 43 /// </summary> 44 internal int totalBytesRetired; 45 46 internal int recursionDepth; // current recursion depth 47 48 internal SegmentedBufferHelper segmentedBufferHelper; 49 50 /// <summary> 51 /// The last tag we read. 0 indicates we've read to the end of the stream 52 /// (or haven't read anything yet). 53 /// </summary> 54 internal uint lastTag; 55 56 /// <summary> 57 /// The next tag, used to store the value read by PeekTag. 58 /// </summary> 59 internal uint nextTag; 60 internal bool hasNextTag; 61 62 // these fields are configuration, they should be readonly 63 internal int sizeLimit; 64 internal int recursionLimit; 65 66 // If non-null, the top level parse method was started with given coded input stream as an argument 67 // which also means we can potentially fallback to calling MergeFrom(CodedInputStream cis) if needed. 68 internal CodedInputStream CodedInputStream => segmentedBufferHelper.CodedInputStream; 69 70 /// <summary> 71 /// Internal-only property; when set to true, unknown fields will be discarded while parsing. 72 /// </summary> 73 internal bool DiscardUnknownFields { get; set; } 74 75 /// <summary> 76 /// Internal-only property; provides extension identifiers to compatible messages while parsing. 77 /// </summary> 78 internal ExtensionRegistry ExtensionRegistry { get; set; } 79 } 80 }