Common types

Numbers

In order to preserve type information – which matters for binary formats such as BYML – when passing types between oead and Python code, several number wrapper classes are used.

In C++, using the wrappers requires no special treatment since they are constructible from and implicitly convertible to numbers.

template<typename T>
struct Number

Strongly typed wrapper around arithmetic types to make types clear especially for Python bindings.

Public Functions

constexpr Number()
constexpr Number(T v)
constexpr operator T() const
constexpr Number &operator=(T v)
constexpr Number &operator++(int)
constexpr Number &operator--(int)
constexpr Number &operator++()
constexpr Number &operator--()
constexpr Number &operator+=(T rhs)
constexpr Number &operator-=(T rhs)
constexpr Number &operator*=(T rhs)
constexpr Number &operator/=(T rhs)
constexpr Number &operator%=(T rhs)
template<>
constexpr Number &operator&=(T rhs)
constexpr Number &operator|=(T rhs)
constexpr Number &operator<<=(T rhs)
constexpr Number &operator>>=(T rhs)
OEAD_DEFINE_FIELDS(Number, value)

Public Members

T value
using oead::U8 = Number<std::uint8_t>
using oead::U16 = Number<std::uint16_t>
using oead::U32 = Number<std::uint32_t>
using oead::U64 = Number<std::uint64_t>
using oead::S8 = Number<std::int8_t>
using oead::S16 = Number<std::int16_t>
using oead::S32 = Number<std::int32_t>
using oead::S64 = Number<std::int64_t>
using oead::F32 = Number<float>
using oead::F64 = Number<double>

Utils

template<typename T>
struct Vector2

2D vector.

Public Functions

OEAD_DEFINE_FIELDS(Vector2, x, y)

Public Members

T x
T y
using oead::Vector2f = Vector2<float>
template<typename T>
struct Vector3

3D vector.

Public Functions

OEAD_DEFINE_FIELDS(Vector3, x, y, z)

Public Members

T x
T y
T z
using oead::Vector3f = Vector3<float>
template<typename T>
struct Vector4

4D vector.

Public Functions

OEAD_DEFINE_FIELDS(Vector4, x, y, z, t)

Public Members

T x
T y
T z
T t
using oead::Vector4f = Vector4<float>
template<typename T>
struct Quat

Quaternion.

Public Functions

OEAD_DEFINE_FIELDS(Quat, a, b, c, d)

Public Members

T a
T b
T c
T d
using oead::Quatf = Quat<float>
struct Color4f

RGBA color (Red/Green/Blue/Alpha).

Public Functions

OEAD_DEFINE_FIELDS(Color4f, r, g, b, a)

Public Members

float r
float g
float b
float a
struct Curve

Curve (sead::hostio::curve*)

Public Functions

OEAD_DEFINE_FIELDS(Curve, a, b, floats)

Public Members

u32 a
u32 b
std::array<float, 30> floats

Strings

Note

Any string that is too long to be stored in a FixedSafeString is truncated.

template<size_t N>
struct FixedSafeString

A string class with its own inline, fixed-size storage.

Public Functions

FixedSafeString()
FixedSafeString(std::string_view str)
auto &operator=(const FixedSafeString &other)
auto &operator=(std::string_view str)
operator std::string_view() const
bool operator==(const FixedSafeString &other) const
bool operator!=(const FixedSafeString &other) const

Note

In sead, this is actually a derived class of sead::BufferedSafeString which is in turn derived from sead::SafeString.

Since the latter is essentially a {vptr, const char* cstr} pair and the former is a std::string_view, we will not bother implementing those base classes.