Skip to content

Namespace endstone::nbt

Namespace List > endstone > nbt

Namespaces

Type Name
namespace detail

Classes

Type Name
class ArrayTag <typename T>
An NBT tag holding a contiguous array of fixed-width values (e.g.
class Tag
A single NBT tag that may hold any of the supported payload types.
struct TagBase
Common base for all NBT tag types.
class ValueTag <typename T>
An NBT tag wrapping a single scalar payload of type T (e.g.

Public Types

Type Name
enum std::uint8_t Type
Identifies the kind of payload an NBT tag holds.

Public Functions

Type Name
std::string dump (const Tag & tag, std::endian byte_order=std::endian::little, bool network=false)
Serialize an NBT tag to binary format with an empty name.
std::string dump (const Tag & tag, const std::string & name, std::endian byte_order=std::endian::little, bool network=false)
Serialize an NBT tag to binary format with a name.
Tag load (std::string_view data, std::string & name, std::endian byte_order=std::endian::little, bool network=false)
Deserialize binary NBT data into a Tag , populating the root tag name.
Tag load (std::string_view data, std::endian byte_order=std::endian::little, bool network=false)
Deserialize binary NBT data into a Tag , discarding the root tag name.

Public Types Documentation

enum Type

Identifies the kind of payload an NBT tag holds.

enum endstone::nbt::Type {
    End = 0,
    Byte = 1,
    Short = 2,
    Int = 3,
    Long = 4,
    Float = 5,
    Double = 6,
    ByteArray = 7,
    String = 8,
    List = 9,
    Compound = 10,
    IntArray = 11
};

The numeric values match the tag ids used in the binary NBT format.


Public Functions Documentation

function dump

Serialize an NBT tag to binary format with an empty name.

inline std::string endstone::nbt::dump (
    const  Tag & tag,
    std::endian byte_order=std::endian::little,
    bool network=false
) 

Parameters:

  • tag The tag to serialize.
  • byte_order Byte order: std::endian::little (Bedrock) or std::endian::big (Java).
  • network If true, use Bedrock network varint encoding for lengths and Int/Long values.

Returns:

Binary NBT data as [type:1][name:""][payload].


function dump

Serialize an NBT tag to binary format with a name.

inline std::string endstone::nbt::dump (
    const  Tag & tag,
    const std::string & name,
    std::endian byte_order=std::endian::little,
    bool network=false
) 

Parameters:

  • tag The tag to serialize.
  • name The root tag name (e.g. "" for Bedrock level.dat, or a descriptive name).
  • byte_order Byte order: std::endian::little (Bedrock) or std::endian::big (Java).
  • network If true, use Bedrock network varint encoding for lengths and Int/Long values.

Returns:

Binary NBT data as [type:1][name:string][payload].


function load

Deserialize binary NBT data into a Tag , populating the root tag name.

inline Tag endstone::nbt::load (
    std::string_view data,
    std::string & name,
    std::endian byte_order=std::endian::little,
    bool network=false
) 

Parameters:

  • data Binary NBT data. Consumed from front via string_view.
  • name The deserialized root tag name.
  • byte_order Byte order used in the binary data.
  • network If true, expect Bedrock network varint encoding.

Returns:

The deserialized tag.

Exception:

  • std::runtime_error If the data is truncated or malformed.

function load

Deserialize binary NBT data into a Tag , discarding the root tag name.

inline Tag endstone::nbt::load (
    std::string_view data,
    std::endian byte_order=std::endian::little,
    bool network=false
) 

Parameters:

  • data Binary NBT data.
  • byte_order Byte order used in the binary data.
  • network If true, expect Bedrock network varint encoding.

Returns:

The deserialized tag.

Exception:

  • std::runtime_error If the data is truncated or malformed.


The documentation for this class was generated from the following file include/endstone/nbt/array.h