BYML

  • v2, v3 and v4 binary documents are supported. Those versions are used by The Legend of Zelda: Breath of the Wild, Super Mario Odyssey and other recent games.

  • All parameter types are supported. This includes 64-bit node types that are used in Super Mario Odyssey.

  • Both little endian and big endian are supported. Switch assets are little-endian.

  • The YAML output is fully compatible with the pure Python byml-v2 library.

#include <oead/byml.h>

Reference

class Byml

BYML value class. This represents a generic value (array, dict, bool, float, u32, etc.)

Public Types

enum Type

Values:

Null = 0
String
Binary
Array
Hash
Bool
Int
Float
UInt
Int64
UInt64
Double
using Null = std::nullptr_t
using String = std::string
using Array = std::vector<Byml>
using Hash = absl::btree_map<std::string, Byml>
using Value = util::Variant<Type, Null, std::unique_ptr<String>, std::unique_ptr<std::vector<u8>>, std::unique_ptr<Array>, std::unique_ptr<Hash>, bool, S32, F32, U32, S64, U64, F64>

Public Functions

Byml()
Byml(const Byml &other)
Byml(Byml &&other)
template<typename T, std::enable_if_t<std::is_constructible_v<Value, T>> * = nullptr>
Byml(T value)
Byml &operator=(const Byml &other)
Byml &operator=(Byml &&other)
OEAD_DEFINE_FIELDS(Byml, m_value)
Type GetType() const
template<Type type>
const auto &Get() const
template<Type type>
auto &Get()
auto &GetVariant()
const auto &GetVariant() const
template<Type Type, typename T>
Reference<const T> Get(std::string_view key, T default_) const
template<Type Type, typename T>
Reference<T> Get(std::string_view key, T default_)
std::vector<u8> ToBinary(bool big_endian, int version = 2) const

Serialize the document to BYML with the specified endianness and version number. This can only be done for Null, Array or Hash nodes.

std::string ToText() const

Serialize the document to YAML. This can only be done for Null, Array or Hash nodes.

Hash &GetHash()
Array &GetArray()
String &GetString()
std::vector<u8> &GetBinary()
const Hash &GetHash() const
const Array &GetArray() const
const String &GetString() const
const std::vector<u8> &GetBinary() const
bool GetBool() const
s32 GetInt() const
u32 GetUInt() const
f32 GetFloat() const
s64 GetInt64() const
u64 GetUInt64() const
f64 GetDouble() const

Public Static Functions

static Byml FromBinary(tcb::span<const u8> data)

Load a document from binary data.

static Byml FromText(std::string_view yml_text)

Load a document from YAML text.

template<typename T>
struct Reference

Get an item from a map/hash.

Public Functions

Reference(T value)
Reference(std::reference_wrapper<T> value)
T *operator->() const
T &operator*() const

Note

The typed getters mirror the behaviour of Nintendo’s BYML library. Some of them will perform type conversions automatically. If value types are incorrect, a TypeError exception is thrown.