NbtLib2012  0.3.4
A continuation of libnbt project, originally by Erik Davidson (aphistic). A C# library for reading and writing Named Binary Tag (NBT) format files.
 All Classes Namespaces Files Functions Enumerations Properties
LibNbt.NbtFile Class Reference

Represents a complete NBT file. More...

Public Member Functions

void RenameRootTag (string newTagName)
 Renames the root tag.
 
 NbtFile ([NotNull] NbtCompound rootTag)
 Creates a new NBT file with the given root tag.
 
 NbtFile ([NotNull] string fileName)
 Loads NBT data from a file. Automatically detects compression.
 
 NbtFile ([NotNull] string fileName, NbtCompression compression,[CanBeNull] TagSelector selector)
 Loads NBT data from a file.
 
 NbtFile ([NotNull] Stream stream, NbtCompression compression,[CanBeNull] TagSelector selector)
 Loads NBT data from a stream.
 
void LoadFromFile ([NotNull] string fileName)
 Loads NBT data from a file. Existing RootTag will be replaced. Compression will be auto-detected.
 
void LoadFromFile ([NotNull] string fileName, NbtCompression compression,[CanBeNull] TagSelector selector)
 Loads NBT data from a file. Existing RootTag will be replaced.
 
void LoadFromStream ([NotNull] Stream stream, NbtCompression compression,[CanBeNull] TagSelector selector)
 Loads NBT data from a stream. Existing RootTag will be replaced
 
void SaveToFile ([NotNull] string fileName, NbtCompression compression)
 Saves this NBT file to a stream. Nothing is written to stream if RootTag is null.
 
void SaveToStream ([NotNull] Stream stream, NbtCompression compression)
 Saves this NBT file to a stream. Nothing is written to stream if RootTag is null.
 

Static Public Member Functions

static string ReadRootTagName ([NotNull] string fileName)
 Reads the root name from the given NBT file. Automatically detects compression.
 
static string ReadRootTagName ([NotNull] string fileName, NbtCompression compression)
 Reads the root name from the given NBT file.
 
static string ReadRootTagName ([NotNull] Stream stream, NbtCompression compression)
 Reads the root name from the given stream of NBT data.
 

Properties

string FileName [get, set]
 Gets the file name used for most recent loading/saving of this file. May be null, if this NbtFile instance has not been loaded from, or saved to, a file.
 
NbtCompression FileCompression [get, set]
 Gets the compression method used for most recent loading/saving of this file. Defaults to AutoDetect.
 
NbtCompound RootTag [get, set]
 Root tag of this file. Must be a named CompoundTag. Defaults to null.
 

Detailed Description

Represents a complete NBT file.

Constructor & Destructor Documentation

LibNbt.NbtFile.NbtFile ( [NotNull] NbtCompound  rootTag)

Creates a new NBT file with the given root tag.

Parameters
rootTagCompound tag to set as the root tag. May be null.
Exceptions
ArgumentExceptionIf given rootTag is unnamed.
LibNbt.NbtFile.NbtFile ( [NotNull] string  fileName)

Loads NBT data from a file. Automatically detects compression.

Parameters
fileNameName of the file from which data will be loaded.
Exceptions
ArgumentNullExceptionfileName is null.
FileNotFoundExceptionIf given file was not found.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, or decompressing failed.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
IOExceptionIf an I/O error occurred while reading the file.
LibNbt.NbtFile.NbtFile ( [NotNull] string  fileName,
NbtCompression  compression,
[CanBeNull] TagSelector  selector 
)

Loads NBT data from a file.

Parameters
fileNameName of the file from which data will be loaded.
compressionCompression method to use for loading/saving this file.
selectorOptional callback to select which tags to load into memory. Root may not be skipped. May be null.
Exceptions
ArgumentNullExceptionfileName is null.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression .
FileNotFoundExceptionIf given file was not found.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, or decompressing failed.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
IOExceptionIf an I/O error occurred while reading the file.
LibNbt.NbtFile.NbtFile ( [NotNull] Stream  stream,
NbtCompression  compression,
[CanBeNull] TagSelector  selector 
)

Loads NBT data from a stream.

Parameters
streamStream from which data will be loaded. If compression is set to AutoDetect, this stream must support seeking.
compressionCompression method to use for loading/saving this file.
selectorOptional callback to select which tags to load into memory. Root may not be skipped. May be null.
Exceptions
ArgumentNullExceptionstream is null.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression .
FileNotFoundExceptionIf given file was not found.
NotSupportedExceptionIf compression is set to AutoDetect, but the stream is not seekable.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, decompressing failed, or given stream does not support reading.
NbtFormatExceptionIf an error occured while parsing data in NBT format.

Member Function Documentation

void LibNbt.NbtFile.LoadFromFile ( [NotNull] string  fileName)

Loads NBT data from a file. Existing RootTag will be replaced. Compression will be auto-detected.

Parameters
fileNameName of the file from which data will be loaded.
Exceptions
ArgumentNullExceptionfileName is null.
FileNotFoundExceptionIf given file was not found.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, or decompressing failed.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
IOExceptionIf an I/O error occurred while reading the file.
void LibNbt.NbtFile.LoadFromFile ( [NotNull] string  fileName,
NbtCompression  compression,
[CanBeNull] TagSelector  selector 
)

Loads NBT data from a file. Existing RootTag will be replaced.

Parameters
fileNameName of the file from which data will be loaded.
compressionCompression method to use for loading/saving this file.
selectorOptional callback to select which tags to load into memory. Root may not be skipped. No reference is stored to this callback after loading (don't worry about implicitly captured closures). May be null.
Exceptions
ArgumentNullExceptionfileName is null.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression .
FileNotFoundExceptionIf given file was not found.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, or decompressing failed.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
IOExceptionIf an I/O error occurred while reading the file.
void LibNbt.NbtFile.LoadFromStream ( [NotNull] Stream  stream,
NbtCompression  compression,
[CanBeNull] TagSelector  selector 
)

Loads NBT data from a stream. Existing RootTag will be replaced

Parameters
streamStream from which data will be loaded. If compression is set to AutoDetect, this stream must support seeking.
compressionCompression method to use for loading/saving this file.
selectorOptional callback to select which tags to load into memory. Root may not be skipped. No reference is stored to this callback after loading (don't worry about implicitly captured closures). May be null.
Exceptions
ArgumentNullExceptionstream is null.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression .
NotSupportedExceptionIf compression is set to AutoDetect, but the stream is not seekable.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, decompressing failed, or given stream does not support reading.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
static string LibNbt.NbtFile.ReadRootTagName ( [NotNull] string  fileName)
static

Reads the root name from the given NBT file. Automatically detects compression.

Parameters
fileNameName of the file from which first tag will be read.
Exceptions
ArgumentNullExceptionfileName is null.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression.
FileNotFoundExceptionIf given file was not found.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, or decompressing failed.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
IOExceptionIf an I/O error occurred while reading the file.
static string LibNbt.NbtFile.ReadRootTagName ( [NotNull] string  fileName,
NbtCompression  compression 
)
static

Reads the root name from the given NBT file.

Parameters
fileNameName of the file from which data will be loaded.
compressionFormat in which the given file is compressed.
Exceptions
ArgumentNullExceptionfileName is null.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression.
FileNotFoundExceptionIf given file was not found.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, or decompressing failed.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
IOExceptionIf an I/O error occurred while reading the file.
static string LibNbt.NbtFile.ReadRootTagName ( [NotNull] Stream  stream,
NbtCompression  compression 
)
static

Reads the root name from the given stream of NBT data.

Parameters
streamStream from which data will be loaded. If compression is set to AutoDetect, this stream must support seeking.
compressionCompression method to use for loading/saving this file.
Exceptions
ArgumentNullExceptionstream is null.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression.
NotSupportedExceptionIf compression is set to AutoDetect, but the stream is not seekable.
EndOfStreamExceptionIf file ended earlier than expected.
InvalidDataExceptionIf file compression could not be detected, decompressing failed, or given stream does not support reading.
NbtFormatExceptionIf an error occured while parsing data in NBT format.
void LibNbt.NbtFile.RenameRootTag ( string  newTagName)

Renames the root tag.

Parameters
newTagNameNew name to give to the root tag. May be null.
void LibNbt.NbtFile.SaveToFile ( [NotNull] string  fileName,
NbtCompression  compression 
)

Saves this NBT file to a stream. Nothing is written to stream if RootTag is null.

Parameters
fileNameFile to write data to. May not be null.
compressionCompression mode to use for saving. May not be AutoDetect.
Exceptions
ArgumentNullExceptionfileName is null.
ArgumentExceptionIf AutoDetect was given as the compression mode.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression.
InvalidDataExceptionIf given stream does not support writing.
IOExceptionIf an I/O error occurred while creating the file.
UnauthorizedAccessExceptionSpecified file is read-only, or a permission issue occurred.
NbtFormatExceptionIf one of the NbtCompound tags contained unnamed tags; or if an NbtList tag had Unknown list type and no elements.
void LibNbt.NbtFile.SaveToStream ( [NotNull] Stream  stream,
NbtCompression  compression 
)

Saves this NBT file to a stream. Nothing is written to stream if RootTag is null.

Parameters
streamStream to write data to. May not be null.
compressionCompression mode to use for saving. May not be AutoDetect.
Exceptions
ArgumentNullExceptionstream is null.
ArgumentExceptionIf AutoDetect was given as the compression mode.
ArgumentOutOfRangeExceptionIf an unrecognized/unsupported value was given for compression.
InvalidDataExceptionIf given stream does not support writing.
NbtFormatExceptionIf one of the NbtCompound tags contained unnamed tags; or if an NbtList tag had Unknown list type and no elements.

Property Documentation

NbtCompression LibNbt.NbtFile.FileCompression
getset

Gets the compression method used for most recent loading/saving of this file. Defaults to AutoDetect.

string LibNbt.NbtFile.FileName
getset

Gets the file name used for most recent loading/saving of this file. May be null, if this NbtFile instance has not been loaded from, or saved to, a file.

NbtCompound LibNbt.NbtFile.RootTag
getset

Root tag of this file. Must be a named CompoundTag. Defaults to null.

Exceptions
ArgumentExceptionIf given tag is unnamed.

The documentation for this class was generated from the following file: