Struct ReadLimits
- Namespace
- CStructSharp
- Assembly
- CStructSharp.dll
The limits of one read as a value: the same bounds as the matching ReadOptions members, without an object to allocate. A reader that parses many small records builds one ReadLimits (or none, for the defaults) instead of a ReadOptions per call.
public readonly struct ReadLimits : IEquatable<ReadLimits>
- Implements
- Inherited Members
Remarks
A value with nothing set, including default, has the same limits as a new
ReadOptions. Only the limits a generated Parse over bytes in memory needs are here: the
array, string, total-byte and nesting budgets, TrimFixedText, InvalidText and the
cancellation token. Pointer policy (DereferencePointers, the depth and target limits,
the addressing mode and the origin) keeps its defaults; a read that needs another policy uses
ReadOptions.
Every limit means what it means on ReadOptions, and a generated reader enforces it exactly as it
enforces the same limit on ReadOptions: a read that reaches an unusable value (a negative limit, a
nesting depth below one) fails with CStructReadLimitException, while a read that never
meets that limit (a negative array limit and a record without arrays) is not affected. Only the runtime entry
points (CStruct.Parse and the like) reject such a value up front with ArgumentOutOfRangeException.
A call that passes the default literal (Parse(bytes, default)) is ambiguous between the
ReadOptions and the ReadLimits overload; write null or new ReadLimits().
Views and the stream and sequence readers take ReadOptions, because a view's ToObject() and a
stream read need the pointer policy and the buffering that only the options carry.
Fields
MaxOffsetBase
The greatest OffsetBase: 2^48 - 1.
public const long MaxOffsetBase = 281474976710655
Field Value
Properties
CancellationToken
Gets the token a long read observes; see CancellationToken.
public CancellationToken CancellationToken { get; init; }
Property Value
Constraints
Gets whether the read evaluates the @expect and @supports constraints of its layout; see
Constraints and ConstraintPolicy. The default, Enforce, evaluates them.
public ConstraintPolicy Constraints { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not a member of ConstraintPolicy.
InvalidText
Gets what the read does with text that is not valid in its encoding; see InvalidText.
public InvalidTextHandling InvalidText { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is not a member of InvalidTextHandling.
MaxArrayElements
Gets the greatest number of elements a single traversed array field may contain; see MaxArrayElements.
public int MaxArrayElements { get; init; }
Property Value
MaxNestingDepth
Gets the greatest active struct depth one read may reach; see MaxNestingDepth.
public int MaxNestingDepth { get; init; }
Property Value
MaxStringBytes
Gets the greatest encoded-byte length of one terminated string including its terminator; see MaxStringBytes.
public long MaxStringBytes { get; init; }
Property Value
MaxTotalBytesRead
Gets the greatest total bytes one read may consume; see MaxTotalBytesRead.
public long MaxTotalBytesRead { get; init; }
Property Value
OffsetBase
Gets the position of the source's first byte in the larger input it was cut from, added to the offset every failure reports; see OffsetBase. At most MaxOffsetBase (2^48 - 1, about 281 TB), which keeps this value at 40 bytes.
public long OffsetBase { get; init; }
Property Value
Exceptions
- ArgumentOutOfRangeException
The value is negative or greater than MaxOffsetBase.
TrimFixedText
Gets whether fixed-capacity text drops its trailing NUL padding; see TrimFixedText.
public bool TrimFixedText { get; init; }
Property Value
Methods
Equals(ReadLimits)
public bool Equals(ReadLimits other)
Parameters
otherReadLimits
Returns
Equals(object)
public override bool Equals(object obj)
Parameters
objobject
Returns
From(ReadOptions?)
Copies the limits of a ReadOptions, dropping its pointer policy.
public static ReadLimits From(ReadOptions? options)
Parameters
optionsReadOptionsThe options, or null for the defaults.
Returns
- ReadLimits
The limits.
GetHashCode()
public override int GetHashCode()
Returns
ToOptions()
Builds the equivalent ReadOptions, with the default pointer policy.
public ReadOptions ToOptions()
Returns
- ReadOptions
New options with these limits.
ToString()
public override string ToString()
Returns
Operators
operator ==(ReadLimits, ReadLimits)
public static bool operator ==(ReadLimits left, ReadLimits right)
Parameters
leftReadLimitsrightReadLimits
Returns
operator !=(ReadLimits, ReadLimits)
public static bool operator !=(ReadLimits left, ReadLimits right)
Parameters
leftReadLimitsrightReadLimits