class
MdfValue
A single typed value in an MDF document.
- Module
- MDF
- Header
#include "mdf/mdf_value.h"- Namespace
MDF
Type aliases
| Alias | Description |
|---|---|
using ArrayType = std::vector<MdfValue> |
Constructors
| Signature | Name | Description |
|---|---|---|
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
| Returns | Name | Description |
|---|---|---|
MdfValue | MakeUUID | Named constructors for types sharing string storage |
MdfValue | MakeAssetRef | |
MdfValue | MakeEnum | |
MdfValue | MakeBytes | |
MdfValue | MakeBytes | |
MdfValueType | Type | |
bool | IsNull | |
bool | IsBool | |
bool | IsInt | |
bool | IsFloat | |
bool | IsNumber | |
bool | IsString | |
bool | IsVec2 | |
bool | IsVec3 | |
bool | IsVec4 | |
bool | IsQuat | |
bool | IsUUID | |
bool | IsAssetRef | |
bool | IsEnum | |
bool | IsArray | |
bool | IsBytes | |
const std::vector<uint8_t>& | AsBytes | |
bool | DecodeBytes | A blob as either encoding hands it back: Bytes from mdfb (or a document built in memory), a Base64 String from text. |
bool | AsBool | Throw on type mismatch. |
int64_t | AsInt | |
double | AsFloat | |
const std::string& | AsString | |
MdfVec2 | AsVec2 | |
MdfVec3 | AsVec3 | |
MdfVec4 | AsVec4 | |
MdfQuat | AsQuat | |
const std::string& | AsUUID | |
const std::string& | AsAssetRef | |
const std::string& | AsEnum | |
const ArrayType& | AsArray | |
bool | AsBool | Never throw. |
int64_t | AsInt | |
double | AsFloat | |
std::string | AsString | Returns by value (not by reference) so a temporary default can't dangle. |
std::string | AsUUID | |
std::string | AsAssetRef | |
std::string | AsEnum | |
MdfVec2 | AsVec2 | |
MdfVec3 | AsVec3 | |
MdfVec4 | AsVec4 | |
MdfQuat | AsQuat | |
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() constIsNull
C++
bool IsNull() constIsBool
C++
bool IsBool() constIsInt
C++
bool IsInt() constIsFloat
C++
bool IsFloat() constIsNumber
C++
bool IsNumber() constIsString
C++
bool IsString() constIsVec2
C++
bool IsVec2() constIsVec3
C++
bool IsVec3() constIsVec4
C++
bool IsVec4() constIsQuat
C++
bool IsQuat() constIsUUID
C++
bool IsUUID() constIsAssetRef
C++
bool IsAssetRef() constIsEnum
C++
bool IsEnum() constIsArray
C++
bool IsArray() constIsBytes
C++
bool IsBytes() constAsBytes
C++
const std::vector<uint8_t>& AsBytes() constDecodeBytes
C++
bool DecodeBytes(std::vector<uint8_t>& out) constA 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() constThrow on type mismatch.
AsInt
C++
int64_t AsInt() constAsFloat
C++
double AsFloat() constAsString
C++
const std::string& AsString() constAsVec2
C++
MdfVec2 AsVec2() constAsVec3
C++
MdfVec3 AsVec3() constAsVec4
C++
MdfVec4 AsVec4() constAsQuat
C++
MdfQuat AsQuat() constAsUUID
C++
const std::string& AsUUID() constAsAssetRef
C++
const std::string& AsAssetRef() constAsEnum
C++
const std::string& AsEnum() constAsArray
C++
const ArrayType& AsArray() constAsBool
C++
bool AsBool(bool def) constNever 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) constAsFloat
C++
double AsFloat(double def) constAsString
C++
std::string AsString(const std::string& def) constReturns by value (not by reference) so a temporary default can't dangle.
AsUUID
C++
std::string AsUUID(const std::string& def) constAsAssetRef
C++
std::string AsAssetRef(const std::string& def) constAsEnum
C++
std::string AsEnum(const std::string& def) constAsVec2
C++
MdfVec2 AsVec2(const MdfVec2& def) constAsVec3
C++
MdfVec3 AsVec3(const MdfVec3& def) constAsVec4
C++
MdfVec4 AsVec4(const MdfVec4& def) constAsQuat
C++
MdfQuat AsQuat(const MdfQuat& def) constAsArray
C++
ArrayType& AsArray()Generated from mdf/mdf_value.h via mdf.json · Oct 26, 2026Version 1.0.0