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

A tag containing a list of unnamed tags, all of the same kind. More...

Inheritance diagram for LibNbt.NbtList:
Collaboration diagram for LibNbt.NbtList:

Public Member Functions

 NbtList ()
 Creates an unnamed NbtList with empty contents and undefined ListType.
 
 NbtList ([CanBeNull] string tagName)
 Creates an NbtList with given name, empty contents, and undefined ListType.
 
 NbtList ([NotNull] IEnumerable< NbtTag > tags)
 Creates an unnamed NbtList with the given contents, and inferred ListType. If given tag array is empty, NbtTagType remains Unknown.
 
 NbtList (NbtTagType givenListType)
 Creates an unnamed NbtList with empty contents and an explicitly specified ListType. If ListType is Unknown, it will be inferred from the type of the first added tag. Otherwise, all tags added to this list are expected to be of the given type.
 
 NbtList ([CanBeNull] string tagName,[NotNull] IEnumerable< NbtTag > tags)
 Creates an NbtList with the given name and contents, and inferred ListType. If given tag array is empty, NbtTagType remains Unknown.
 
 NbtList ([NotNull] IEnumerable< NbtTag > tags, NbtTagType givenListType)
 Creates an unnamed NbtList with the given contents, and an explicitly specified ListType.
 
 NbtList ([CanBeNull] string tagName, NbtTagType givenListType)
 Creates an NbtList with the given name, empty contents, and an explicitly specified ListType.
 
 NbtList ([CanBeNull] string tagName,[CanBeNull] IEnumerable< NbtTag > tags, NbtTagType givenListType)
 Creates an NbtList with the given name and contents, and an explicitly specified ListType.
 
Get< T > (int tagIndex)
 Gets or sets the tag with the specified name.
 
void AddRange ([NotNull] IEnumerable< NbtTag > newTags)
 Adds all tags from the specified collection to the end of this NbtList.
 
NbtTag[] ToArray ()
 Copies all tags in this NbtList to an array.
 
T[] ToArray< T > ()
 Copies all tags in this NbtList to an array, and casts it to the desired type.
 
IEnumerator< NbtTagGetEnumerator ()
 Returns an enumerator that iterates through all tags in this NbtList.
 
int IndexOf ([NotNull] NbtTag tag)
 Determines the index of a specific tag in this NbtList
 
void Insert (int tagIndex,[NotNull] NbtTag newTag)
 Inserts an item to this NbtList at the specified index.
 
void RemoveAt (int index)
 Removes a tag at the specified index from this NbtList.
 
void Add ([NotNull] NbtTag newTag)
 Adds a tag to this NbtList.
 
void Clear ()
 Removes all tags from this NbtList.
 
bool Contains ([NotNull] NbtTag item)
 Determines whether this NbtList contains a specific tag.
 
void CopyTo (NbtTag[] array, int arrayIndex)
 Copies the tags of this NbtList 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 NbtList object and its contents. Format: TAG_List("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 (List).
 
NbtTagType ListType [get, set]
 Gets or sets the tag type of this list. All tags in this NbtTag must be of the same type.
 
override NbtTag this[int tagIndex] [get, set]
 Gets or sets the tag at the specified index.
 
int Count [get]
 Gets the number of tags contained in the NbtList.
 
- 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 list of unnamed tags, all of the same kind.

Constructor & Destructor Documentation

LibNbt.NbtList.NbtList ( )

Creates an unnamed NbtList with empty contents and undefined ListType.

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

Creates an NbtList with given name, empty contents, and undefined ListType.

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

Creates an unnamed NbtList with the given contents, and inferred ListType. If given tag array is empty, NbtTagType remains Unknown.

Parameters
tagsCollection of tags to insert into the list. All tags are expected to be of the same type. ListType is inferred from the first tag. List may be empty, but may not be null.
Exceptions
ArgumentNullExceptiontags is null.
ArgumentExceptionIf given tags are of mixed types.
LibNbt.NbtList.NbtList ( NbtTagType  givenListType)

Creates an unnamed NbtList with empty contents and an explicitly specified ListType. If ListType is Unknown, it will be inferred from the type of the first added tag. Otherwise, all tags added to this list are expected to be of the given type.

Parameters
givenListTypeName to assign to this tag. May be Unknown.
Exceptions
ArgumentOutOfRangeExceptiongivenListType is not a recognized tag type.
LibNbt.NbtList.NbtList ( [CanBeNull] string  tagName,
[NotNull] IEnumerable< NbtTag tags 
)

Creates an NbtList with the given name and contents, and inferred ListType. If given tag array is empty, NbtTagType remains Unknown.

Parameters
tagNameName to assign to this tag. May be null.
tagsCollection of tags to insert into the list. All tags are expected to be of the same type. ListType is inferred from the first tag. List may be empty, but may not be null.
Exceptions
ArgumentNullExceptiontags is null.
ArgumentExceptionIf given tags are of mixed types.
LibNbt.NbtList.NbtList ( [NotNull] IEnumerable< NbtTag tags,
NbtTagType  givenListType 
)

Creates an unnamed NbtList with the given contents, and an explicitly specified ListType.

Parameters
tagsCollection of tags to insert into the list. All tags are expected to be of the same type (matching givenListType). List may be empty, but may not be null.
givenListTypeName to assign to this tag. May be Unknown (to infer type from the first element of tags).
Exceptions
ArgumentNullExceptiontags is null.
ArgumentOutOfRangeExceptiongivenListType is not a recognized tag type.
ArgumentExceptionIf given tags do not match givenListType , or are of mixed types.
LibNbt.NbtList.NbtList ( [CanBeNull] string  tagName,
NbtTagType  givenListType 
)

Creates an NbtList with the given name, empty contents, and an explicitly specified ListType.

Parameters
tagNameName to assign to this tag. May be null.
givenListTypeName to assign to this tag. If givenListType is Unknown, ListType will be infered from the first tag added to this NbtList.
Exceptions
ArgumentOutOfRangeExceptiongivenListType is not a recognized tag type.
LibNbt.NbtList.NbtList ( [CanBeNull] string  tagName,
[CanBeNull] IEnumerable< NbtTag tags,
NbtTagType  givenListType 
)

Creates an NbtList with the given name and contents, and an explicitly specified ListType.

Parameters
tagNameName to assign to this tag. May be null.
tagsCollection of tags to insert into the list. All tags are expected to be of the same type (matching givenListType). May be empty or null.
givenListTypeName to assign to this tag. May be Unknown (to infer type from the first element of tags).
Exceptions
ArgumentOutOfRangeExceptiongivenListType is not a recognized tag type.
ArgumentExceptionIf given tags do not match givenListType , or are of mixed types.

Member Function Documentation

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

Adds a tag to this NbtList.

Parameters
newTagThe tag to add to this NbtList.
Exceptions
ArgumentNullExceptionnewTag is null.
ArgumentExceptionIf newTag does not match ListType.
void LibNbt.NbtList.AddRange ( [NotNull] IEnumerable< NbtTag newTags)

Adds all tags from the specified collection to the end of this NbtList.

Parameters
newTagsThe collection whose elements should be added to this NbtList.
Exceptions
ArgumentNullExceptionnewTags is null.
ArgumentExceptionIf given tags do not match ListType, or are of mixed types.
void LibNbt.NbtList.Clear ( )

Removes all tags from this NbtList.

bool LibNbt.NbtList.Contains ( [NotNull] NbtTag  item)

Determines whether this NbtList contains a specific tag.

Returns
true if given tag is found in this NbtList; otherwise, false.
Parameters
itemThe tag to locate in this NbtList.
void LibNbt.NbtList.CopyTo ( NbtTag[]  array,
int  arrayIndex 
)

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

Parameters
arrayThe one-dimensional array that is the destination of the tag copied from NbtList. 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 NbtList 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.NbtList.Get< T > ( int  tagIndex)

Gets or sets the tag with the specified name.

Parameters
tagIndexThe zero-based index of the tag to get or set.
Template Parameters
TType to cast the result to. Must derive from NbtTag.
Returns
The tag with the specified key.
Exceptions
ArgumentOutOfRangeExceptiontagIndex is not a valid index in the NbtList.
InvalidCastExceptionIf tag could not be cast to the desired tag.
Type Constraints
T :NbtTag 
IEnumerator<NbtTag> LibNbt.NbtList.GetEnumerator ( )

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

Returns
An IEnumerator>NbtTag< that can be used to iterate through the list.
int LibNbt.NbtList.IndexOf ( [NotNull] NbtTag  tag)

Determines the index of a specific tag in this NbtList

Returns
The index of tag if found in the list; otherwise, -1.
Parameters
tagThe tag to locate in this NbtList.
void LibNbt.NbtList.Insert ( int  tagIndex,
[NotNull] NbtTag  newTag 
)

Inserts an item to this NbtList at the specified index.

Parameters
tagIndexThe zero-based index at which newTag should be inserted.
newTagThe tag to insert into this NbtList.
Exceptions
ArgumentOutOfRangeExceptiontagIndex is not a valid index in this NbtList.
ArgumentNullExceptionnewTag is null.
bool LibNbt.NbtList.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 this NbtList; otherwise, false. This method also returns false if tag is not found.
Parameters
tagThe tag to remove from this NbtList.
Exceptions
ArgumentNullExceptiontag is null.
void LibNbt.NbtList.RemoveAt ( int  index)

Removes a tag at the specified index from this NbtList.

Parameters
indexThe zero-based index of the item to remove.
Exceptions
ArgumentOutOfRangeExceptionindex is not a valid index in the NbtList.
NbtTag [] LibNbt.NbtList.ToArray ( )

Copies all tags in this NbtList to an array.

Returns
Array of NbtTags.
T [] LibNbt.NbtList.ToArray< T > ( )

Copies all tags in this NbtList to an array, and casts it to the desired type.

Template Parameters
TType to cast every member of NbtList to. Must derive from NbtTag.
Returns
Array of NbtTags cast to the desired type.
Exceptions
InvalidCastExceptionIf contents of this list cannot be cast to the given type.
Type Constraints
T :NbtTag 
override string LibNbt.NbtList.ToString ( )

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

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

Property Documentation

int LibNbt.NbtList.Count
get

Gets the number of tags contained in the NbtList.

Returns
The number of tags contained in the NbtList.
NbtTagType LibNbt.NbtList.ListType
getset

Gets or sets the tag type of this list. All tags in this NbtTag must be of the same type.

Exceptions
ArgumentExceptionIf the given NbtTagType does not match the type of existing list items (for non-empty lists).
ArgumentOutOfRangeExceptionIf the given NbtTagType is not among recognized tag types.
override NbtTagType LibNbt.NbtList.TagType
get

Type of this tag (List).

override NbtTag LibNbt.NbtList.this[int tagIndex]
getset

Gets or sets the tag at the specified index.

Returns
The tag at the specified index.
Parameters
tagIndexThe zero-based index of the tag to get or set.
Exceptions
ArgumentOutOfRangeExceptiontagIndex is not a valid index in the NbtList.
ArgumentNullExceptionvalue is null.
ArgumentExceptionGiven tag's type does not match ListType.

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