Class NbtOptions
- Namespace
- fNbt
- Assembly
- fNbt.dll
Settings for reading and writing NBT: the flavor, validation toggles, and limits.
Every consumer snapshots the values at its own construction, so changing an options
instance later does not affect objects already created from it. Application-wide defaults
live on the static Default* properties; configure those during startup, before any
NBT work.
public sealed class NbtOptions
- Inheritance
-
NbtOptions
- Inherited Members
Constructors
NbtOptions()
Creates options initialized from the current defaults
(DefaultFlavor and the other Default* properties).
Later changes to the defaults do not affect this instance.
public NbtOptions()
NbtOptions(NbtFlavor)
Creates options for the given flavor, with the current default policy settings. Any flavor is accepted here; the named-root entry points reject flavors without a root name themselves.
public NbtOptions(NbtFlavor flavor)
Parameters
flavorNbtFlavorThe wire encoding to read and write.
Exceptions
- ArgumentNullException
flavorisnull.
Properties
DefaultFlavor
The flavor used by entry points constructed without one: NbtFile,
NbtReader, NbtWriter, and NbtFile.ReadRootTagName.
Initially Java. Every such entry point works with named roots,
so flavors without a root name are rejected here; pass those to NbtCodec
explicitly.
public static NbtFlavor DefaultFlavor { get; set; }
Property Value
Exceptions
- ArgumentNullException
value is
null.- ArgumentException
value is a flavor without a root name.
DefaultMaxAllocation
Initial MaxAllocation value for new options and for entry points constructed without options. Initially MaxValue, meaning no limit.
public static long DefaultMaxAllocation { get; set; }
Property Value
Exceptions
- ArgumentOutOfRangeException
value is zero or negative.
DefaultValidateOnRead
Initial ValidateOnRead value for new options and for entry
points constructed without options. Initially false. Enabling it process-wide
makes documents that merely bend a flavor's rules throw where they previously loaded,
even in code that did not opt in.
public static bool DefaultValidateOnRead { get; set; }
Property Value
DefaultValidateOnWrite
Initial ValidateOnWrite value for new options and for entry
points constructed without options. Initially true. Turning it off process-wide
trades conformance checking away for restricted flavors: writes that relied on the
refusal start producing nonconformant documents silently.
public static bool DefaultValidateOnWrite { get; set; }
Property Value
Flavor
The wire encoding to read and write. Initialized from DefaultFlavor.
public NbtFlavor Flavor { get; set; }
Property Value
MaxAllocation
Maximum size, in bytes, of any single allocation made on behalf of a length declared in the input: array payloads, list-as-array reads, strings, and the array of references a loaded list holds its elements in (one pointer per element; the element objects themselves are not counted). Guards against tiny corrupt or hostile documents declaring huge lengths, which matters most on compressed and non-seekable streams where declared lengths cannot be checked against the bytes actually available. Per-allocation, not a total document quota. Initialized from DefaultMaxAllocation; MaxValue means no limit, and the value must be positive when the options are used.
public long MaxAllocation { get; set; }
Property Value
ValidateOnRead
Whether reads enforce the flavor's conformance rules (permitted tag types, string ceilings, and for NbtCodec the root tag type) in addition to parsing. Initialized from DefaultValidateOnRead. When off, reads accept anything parseable, so files that merely bend the rules still load.
public bool ValidateOnRead { get; set; }
Property Value
ValidateOnWrite
Whether writes enforce the flavor's conformance rules, refusing to produce a document the flavor's own readers would reject. Initialized from DefaultValidateOnWrite. Flavors without restrictions (like Java) pay no cost either way.
public bool ValidateOnWrite { get; set; }