class

MdfValue

A single typed value in an MDF document.

Module
MDF
Header
#include "mdf/mdf_value.h"
Namespace
MDF

Type aliases

AliasDescription
using ArrayType = std::vector<MdfValue>

Constructors

SignatureNameDescription
MdfValue() : m_type(MdfValueType::Null), m_data(std::monostate{})MdfValue
MdfValue(bool val) : m_type(MdfValueType::Bool), m_data(val)MdfValue
MdfValue(int val) : m_type(MdfValueType::Int), m_data(static_cast<int64_t>(val))MdfValue
MdfValue(unsigned int val) : m_type(MdfValueType::Int), m_data(static_cast<int64…MdfValue
MdfValue(int64_t val) : m_type(MdfValueType::Int), m_data(val)MdfValue
MdfValue(unsigned long long val) : m_type(MdfValueType::Int), m_data(static_cast…MdfValue
MdfValue(float val) : m_type(MdfValueType::Float), m_data(static_cast<double>(va…MdfValue
MdfValue(double val) : m_type(MdfValueType::Float), m_data(val)MdfValue
MdfValue(const char* val) : m_type(MdfValueType::String), m_data(std::string(val…MdfValue
MdfValue(const std::string& val) : m_type(MdfValueType::String), m_data(val)MdfValue
MdfValue(std::string&& val) : m_type(MdfValueType::String), m_data(std::move(val…MdfValue
MdfValue(const MdfVec2& val) : m_type(MdfValueType::Vec2), m_data(val)MdfValue
MdfValue(const MdfVec3& val) : m_type(MdfValueType::Vec3), m_data(val)MdfValue
MdfValue(const MdfVec4& val) : m_type(MdfValueType::Vec4), m_data(val)MdfValue
MdfValue(const MdfQuat& val) : m_type(MdfValueType::Quat), m_data(val)MdfValue
MdfValue(const ArrayType& val) : m_type(MdfValueType::Array), m_data(val)MdfValue
MdfValue(ArrayType&& val) : m_type(MdfValueType::Array), m_data(std::move(val))MdfValue

Public functions

ReturnsNameDescription
MdfValueMakeUUIDNamed constructors for types sharing string storage
MdfValueMakeAssetRef
MdfValueMakeEnum
MdfValueMakeBytes
MdfValueMakeBytes
MdfValueTypeType
boolIsNull
boolIsBool
boolIsInt
boolIsFloat
boolIsNumber
boolIsString
boolIsVec2
boolIsVec3
boolIsVec4
boolIsQuat
boolIsUUID
boolIsAssetRef
boolIsEnum
boolIsArray
boolIsBytes
const std::vector<uint8_t>&AsBytes
boolDecodeBytesA blob as either encoding hands it back: Bytes from mdfb (or a document built in memory), a Base64 String from text.
boolAsBoolThrow on type mismatch.
int64_tAsInt
doubleAsFloat
const std::string&AsString
MdfVec2AsVec2
MdfVec3AsVec3
MdfVec4AsVec4
MdfQuatAsQuat
const std::string&AsUUID
const std::string&AsAssetRef
const std::string&AsEnum
const ArrayType&AsArray
boolAsBoolNever throw.
int64_tAsInt
doubleAsFloat
std::stringAsStringReturns by value (not by reference) so a temporary default can't dangle.
std::stringAsUUID
std::stringAsAssetRef
std::stringAsEnum
MdfVec2AsVec2
MdfVec3AsVec3
MdfVec4AsVec4
MdfQuatAsQuat
ArrayType&AsArray

Function details

MdfValue

C++
MdfValue() : m_type(MdfValueType::Null), m_data(std::monostate{})

MdfValue

C++
MdfValue(bool val) : m_type(MdfValueType::Bool), m_data(val)

MdfValue

C++
MdfValue(int val) : m_type(MdfValueType::Int), m_data(static_cast<int64_t>(val))

MdfValue

C++
MdfValue(unsigned int val) : m_type(MdfValueType::Int), m_data(static_cast<int64_t>(val))

MdfValue

C++
MdfValue(int64_t val) : m_type(MdfValueType::Int), m_data(val)

MdfValue

C++
MdfValue(unsigned long long val) : m_type(MdfValueType::Int), m_data(static_cast<int64_t>(val))

MdfValue

C++
MdfValue(float val) : m_type(MdfValueType::Float), m_data(static_cast<double>(val))

MdfValue

C++
MdfValue(double val) : m_type(MdfValueType::Float), m_data(val)

MdfValue

C++
MdfValue(const char* val) : m_type(MdfValueType::String), m_data(std::string(val))

MdfValue

C++
MdfValue(const std::string& val) : m_type(MdfValueType::String), m_data(val)

MdfValue

C++
MdfValue(std::string&& val) : m_type(MdfValueType::String), m_data(std::move(val))

MdfValue

C++
MdfValue(const MdfVec2& val) : m_type(MdfValueType::Vec2), m_data(val)

MdfValue

C++
MdfValue(const MdfVec3& val) : m_type(MdfValueType::Vec3), m_data(val)

MdfValue

C++
MdfValue(const MdfVec4& val) : m_type(MdfValueType::Vec4), m_data(val)

MdfValue

C++
MdfValue(const MdfQuat& val) : m_type(MdfValueType::Quat), m_data(val)

MdfValue

C++
MdfValue(const ArrayType& val) : m_type(MdfValueType::Array), m_data(val)

MdfValue

C++
MdfValue(ArrayType&& val) : m_type(MdfValueType::Array), m_data(std::move(val))

MakeUUID

C++
static MdfValue MakeUUID(const std::string& uuid)

Named constructors for types sharing string storage

MakeAssetRef

C++
static MdfValue MakeAssetRef(const std::string& path)

MakeEnum

C++
static MdfValue MakeEnum(const std::string& name)

MakeBytes

C++
static MdfValue MakeBytes(std::vector<uint8_t> bytes)

MakeBytes

C++
static MdfValue MakeBytes(const uint8_t* data, size_t size)

Type

C++
MdfValueType Type() const

IsNull

C++
bool IsNull() const

IsBool

C++
bool IsBool() const

IsInt

C++
bool IsInt() const

IsFloat

C++
bool IsFloat() const

IsNumber

C++
bool IsNumber() const

IsString

C++
bool IsString() const

IsVec2

C++
bool IsVec2() const

IsVec3

C++
bool IsVec3() const

IsVec4

C++
bool IsVec4() const

IsQuat

C++
bool IsQuat() const

IsUUID

C++
bool IsUUID() const

IsAssetRef

C++
bool IsAssetRef() const

IsEnum

C++
bool IsEnum() const

IsArray

C++
bool IsArray() const

IsBytes

C++
bool IsBytes() const

AsBytes

C++
const std::vector<uint8_t>& AsBytes() const

DecodeBytes

C++
bool DecodeBytes(std::vector<uint8_t>& out) const

A blob as either encoding hands it back: Bytes from mdfb (or a document built in memory), a Base64 String from text. False for anything else or a String that is not Base64.

AsBool

C++
bool AsBool() const

Throw on type mismatch.

AsInt

C++
int64_t AsInt() const

AsFloat

C++
double AsFloat() const

AsString

C++
const std::string& AsString() const

AsVec2

C++
MdfVec2 AsVec2() const

AsVec3

C++
MdfVec3 AsVec3() const

AsVec4

C++
MdfVec4 AsVec4() const

AsQuat

C++
MdfQuat AsQuat() const

AsUUID

C++
const std::string& AsUUID() const

AsAssetRef

C++
const std::string& AsAssetRef() const

AsEnum

C++
const std::string& AsEnum() const

AsArray

C++
const ArrayType& AsArray() const

AsBool

C++
bool AsBool(bool def) const

Never throw. MdfNode::GetProperty returns Null for a key that isn't there, so the throwing getters above turn a slightly-older or hand-edited document into a crash. These return the caller's fallback for both a missing key and a type mismatch. Prefer them over a HasProperty + GetProperty pair.

AsInt

C++
int64_t AsInt(int64_t def) const

AsFloat

C++
double AsFloat(double def) const

AsString

C++
std::string AsString(const std::string& def) const

Returns by value (not by reference) so a temporary default can't dangle.

AsUUID

C++
std::string AsUUID(const std::string& def) const

AsAssetRef

C++
std::string AsAssetRef(const std::string& def) const

AsEnum

C++
std::string AsEnum(const std::string& def) const

AsVec2

C++
MdfVec2 AsVec2(const MdfVec2& def) const

AsVec3

C++
MdfVec3 AsVec3(const MdfVec3& def) const

AsVec4

C++
MdfVec4 AsVec4(const MdfVec4& def) const

AsQuat

C++
MdfQuat AsQuat(const MdfQuat& def) const

AsArray

C++
ArrayType& AsArray()
Generated from mdf/mdf_value.h via mdf.json · Oct 26, 2026Version 1.0.0