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.NbtCompound Class Reference

A tag containing a set of other named tags. Order is not guaranteed. More...

Inheritance diagram for LibNbt.NbtCompound:
Collaboration diagram for LibNbt.NbtCompound:

Public Member Functions

 NbtCompound ()
 Creates an empty unnamed NbtByte tag.
 
 NbtCompound ([CanBeNull] string tagName)
 Creates an empty NbtByte tag with the given name.
 
 NbtCompound ([NotNull] IEnumerable< NbtTag > tags)
 Creates an unnamed NbtByte tag, containing the given tags.
 
 NbtCompound ([CanBeNull] string tagName,[NotNull] IEnumerable< NbtTag > tags)
 Creates an NbtByte tag with the given name, containing the given tags.
 
Get< T > ([NotNull] string tagName)
 Gets or sets the tag with the specified name. May return null.
 
NbtTag[] ToArray ()
 Copies all tags in this NbtCompound to an array.
 
string[] ToNameArray ()
 Copies names of all tags in this NbtCompound to an array.
 
void AddRange ([NotNull] IEnumerable< NbtTag > newTags)
 Adds all tags from the specified collection to this NbtCompound.
 
bool Contains ([NotNull] string tagName)
 Determines whether this NbtCompound contains a tag with a specific name.
 
bool Remove ([NotNull] string tagName)
 Removes the tag with the specified name from this NbtCompound.
 
void RenameTag ([NotNull] string oldName,[NotNull] string newName)
 Renames a child tags.
 
IEnumerator< NbtTagGetEnumerator ()
 Returns an enumerator that iterates through all tags in this NbtCompound.
 
void Add ([NotNull] NbtTag newTag)
 Adds a tag to this NbtCompound.
 
void Clear ()
 Removes all tags from this NbtCompound.
 
bool Contains ([NotNull] NbtTag tag)
 Determines whether this NbtCompound contains a specific NbtTag. Looks for exact object matches, not name matches.
 
void CopyTo (NbtTag[] array, int arrayIndex)
 Copies the tags of the NbtCompound to an array, starting at a particular array index.
 
bool Remove ([NotNull] NbtTag tag)
 Removes the first occurrence of a specific NbtTag from the NbtCompound. Looks for exact object matches, not name matches.
 
override string ToString ()
 Returns a String that represents the current NbtCompound object and its contents. Format: TAG_Compound("Name"): { ...contents... }
 
- Public Member Functions inherited from LibNbt.NbtTag
string ToString ([NotNull] string indentString)
 Prints contents of this tag, and any child tags, to a string. Indents the string using multiples of the given indentation string.
 

Properties

override NbtTagType TagType [get]
 Type of this tag (Compound).
 
override NbtTag this[[NotNull]
string 
tagName [get, set]
 Gets or sets the tag with the specified name. May return null.
 
IEnumerable< string > Names [get]
 Gets a collection containing all tag names in this NbtCompound.
 
IEnumerable< NbtTagTags [get]
 Gets a collection containing all tags in this NbtCompound.
 
int Count [get]
 Gets the number of tags contained in the NbtCompound.
 
- Properties inherited from LibNbt.NbtTag
NbtTag Parent [get, set]
 Parent compound tag, either NbtList or NbtCompound, if any.
 
virtual NbtTagType TagType [get]
 Type of this tag.
 
string Name [get, set]
 Name of this tag. Immutable, and set by the constructor. May be null.
 
string Path [get]
 Gets the full name of this tag, including all parent tag names, separated by dots. Unnamed tags show up as empty strings.
 
virtual NbtTag this[string tagName] [get, set]
 Gets or sets the tag with the specified name. May return null.
 
virtual NbtTag this[int tagIndex] [get, set]
 Gets or sets the tag at the specified index.
 
byte ByteValue [get]
 Returns the value of this tag, cast as a byte. Only supported by NbtByte tags.
 
short ShortValue [get]
 Returns the value of this tag, cast as a short (16-bit signed integer). Only supported by NbtByte and NbtShort.
 
int IntValue [get]
 Returns the value of this tag, cast as an int (32-bit signed integer). Only supported by NbtByte, NbtShort, and NbtInt.
 
long LongValue [get]
 Returns the value of this tag, cast as a long (64-bit signed integer). Only supported by NbtByte, NbtShort, NbtInt, and NbtLong.
 
float FloatValue [get]
 Returns the value of this tag, cast as a long (64-bit signed integer). Only supported by NbtFloat and, with loss of precision, by NbtDouble, NbtByte, NbtShort, NbtInt, and NbtLong.
 
double DoubleValue [get]
 Returns the value of this tag, cast as a long (64-bit signed integer). Only supported by NbtFloat, NbtDouble, and, with loss of precision, by NbtByte, NbtShort, NbtInt, and NbtLong.
 
byte[] ByteArrayValue [get]
 Returns the value of this tag, cast as a byte array. Only supported by NbtByteArray tags.
 
int[] IntArrayValue [get]
 Returns the value of this tag, cast as an int array. Only supported by NbtIntArray tags.
 
string StringValue [get]
 Returns the value of this tag, cast as a string. Returns exact value for NbtString, and stringified (using InvariantCulture) value for NbtByte, NbtDouble, NbtFloat, NbtInt, NbtLong, and NbtShort. Not supported by NbtCompound, NbtList, NbtByteArray, or NbtIntArray.
 

Additional Inherited Members

- Static Public Member Functions inherited from LibNbt.NbtTag
static string GetCanonicalTagName (NbtTagType type)
 Returns a canonical (Notchy) name for the given NbtTagType, e.g. "TAG_Byte_Array" for NbtTagType.ByteArray
 

Detailed Description

A tag containing a set of other named tags. Order is not guaranteed.

Constructor & Destructor Documentation

LibNbt.NbtCompound.NbtCompound ( )

Creates an empty unnamed NbtByte tag.

LibNbt.NbtCompound.NbtCompound ( [CanBeNull] string  tagName)

Creates an empty NbtByte tag with the given name.

Parameters
tagNameName to assign to this tag. May be null.
LibNbt.NbtCompound.NbtCompound ( [NotNull] IEnumerable< NbtTag tags)

Creates an unnamed NbtByte tag, containing the given tags.

Parameters
tagsCollection of tags to assign to this tag's Value. May not be null
Exceptions
ArgumentNullExceptiontags is null, or one of the tags is null.
ArgumentExceptionIf some of the given tags were not named, or two tags with the same name were given.
LibNbt.NbtCompound.NbtCompound ( [CanBeNull] string  tagName,
[NotNull] IEnumerable< NbtTag tags 
)

Creates an NbtByte tag with the given name, containing the given tags.

Parameters
tagNameName to assign to this tag. May be null.
tagsCollection of tags to assign to this tag's Value. May not be null
Exceptions
ArgumentNullExceptiontags is null, or one of the tags is null.
ArgumentExceptionIf some of the given tags were not named, or two tags with the same name were given.

Member Function Documentation

void LibNbt.NbtCompound.Add ( [NotNull] NbtTag  newTag)

Adds a tag to this NbtCompound.

Parameters
newTagThe object to add to this NbtCompound.
Exceptions
ArgumentNullExceptionnewTag is null.
ArgumentExceptionIf the given tag is unnamed; or if a tag with the given name already exists in this NbtCompound.
void LibNbt.NbtCompound.AddRange ( [NotNull] IEnumerable< NbtTag newTags)

Adds all tags from the specified collection to this NbtCompound.

Parameters
newTagsThe collection whose elements should be added to this NbtCompound.
Exceptions
ArgumentNullExceptionnewTags is null, or one of the tags in newTags is null.
ArgumentExceptionIf one of the given tags was unnamed, or if a tag with the given name already exists in this NbtCompound.
void LibNbt.NbtCompound.Clear ( )

Removes all tags from this NbtCompound.

bool LibNbt.NbtCompound.Contains ( [NotNull] string  tagName)

Determines whether this NbtCompound contains a tag with a specific name.

Parameters
tagNameTag name to search for. May not be null.
Returns
true if a tag with given name was found; otherwise, false.
Exceptions
ArgumentNullExceptiontagName is null.
bool LibNbt.NbtCompound.Contains ( [NotNull] NbtTag  tag)

Determines whether this NbtCompound contains a specific NbtTag. Looks for exact object matches, not name matches.

Returns
true if tag is found; otherwise, false.
Parameters
tagThe object to locate in this NbtCompound. May not be null.
Exceptions
ArgumentNullExceptiontag is null.
void LibNbt.NbtCompound.CopyTo ( NbtTag[]  array,
int  arrayIndex 
)

Copies the tags of the NbtCompound to an array, starting at a particular array index.

Parameters
arrayThe one-dimensional array that is the destination of the tag copied from NbtCompound. The array must have zero-based indexing.
arrayIndexThe zero-based index in array at which copying begins.
Exceptions
ArgumentNullExceptionarray is null.
ArgumentOutOfRangeExceptionarrayIndex is less than 0.
ArgumentExceptionGiven array is multidimensional; arrayIndex is equal to or greater than the length of array; the number of tags in this NbtCompound is greater than the available space from arrayIndex to the end of the destination array; or type NbtTag cannot be cast automatically to the type of the destination array.
T LibNbt.NbtCompound.Get< T > ( [NotNull] string  tagName)

Gets or sets the tag with the specified name. May return null.

Parameters
tagNameThe name of the tag to get.
Template Parameters
TType to cast the result to. Must derive from NbtTag.
Returns
The tag with the specified key. Null if tag with the given name was not found.
Exceptions
ArgumentNullExceptiontagName is null.
InvalidCastExceptionIf tag could not be cast to the desired tag.
Type Constraints
T :NbtTag 
IEnumerator<NbtTag> LibNbt.NbtCompound.GetEnumerator ( )

Returns an enumerator that iterates through all tags in this NbtCompound.

Returns
An IEnumerator>NbtTag< that can be used to iterate through the collection.
bool LibNbt.NbtCompound.Remove ( [NotNull] string  tagName)

Removes the tag with the specified name from this NbtCompound.

Parameters
tagNameThe name of the tag to remove.
Returns
true if the tag is successfully found and removed; otherwise, false. This method returns false if name is not found in the NbtCompound.
Exceptions
ArgumentNullExceptiontagName is null.
bool LibNbt.NbtCompound.Remove ( [NotNull] NbtTag  tag)

Removes the first occurrence of a specific NbtTag from the NbtCompound. Looks for exact object matches, not name matches.

Returns
true if tag was successfully removed from the NbtCompound; otherwise, false. This method also returns false if tag is not found.
Parameters
tagThe tag to remove from the NbtCompound.
Exceptions
ArgumentNullExceptiontag is null.
ArgumentExceptionIf the given tag is unnamed
void LibNbt.NbtCompound.RenameTag ( [NotNull] string  oldName,
[NotNull] string  newName 
)

Renames a child tags.

Parameters
oldNameCurrent name of the tag that's being renamed.
newNameDesired new name for the renamed tag.
Exceptions
ArgumentNullExceptionoldName or newName is null.
ArgumentExceptionNo tag found for oldName ; or tag with the same name as newName already exists in this compound.
NbtTag [] LibNbt.NbtCompound.ToArray ( )

Copies all tags in this NbtCompound to an array.

Returns
Array of NbtTags.
string [] LibNbt.NbtCompound.ToNameArray ( )

Copies names of all tags in this NbtCompound to an array.

Returns
Array of strings (tag names).
override string LibNbt.NbtCompound.ToString ( )

Returns a String that represents the current NbtCompound object and its contents. Format: TAG_Compound("Name"): { ...contents... }

Returns
A String that represents the current NbtCompound object and its contents.

Property Documentation

int LibNbt.NbtCompound.Count
get

Gets the number of tags contained in the NbtCompound.

Returns
The number of tags contained in the NbtCompound.
IEnumerable<string> LibNbt.NbtCompound.Names
get

Gets a collection containing all tag names in this NbtCompound.

override NbtTag this[[NotNull] string LibNbt.NbtCompound.tagName
getset

Gets or sets the tag with the specified name. May return null.

Returns
The tag with the specified key. Null if tag with the given name was not found.
Parameters
tagNameThe name of the tag to get or set. Must match tag's actual name.
Exceptions
ArgumentNullExceptiontagName is null; or if trying to assign null value.
ArgumentExceptiontagName does not match the given tag's actual name; or given tag already has a Parent.
IEnumerable<NbtTag> LibNbt.NbtCompound.Tags
get

Gets a collection containing all tags in this NbtCompound.

override NbtTagType LibNbt.NbtCompound.TagType
get

Type of this tag (Compound).


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