YamlCppConverters update + tests
This commit is contained in:
@@ -71,4 +71,179 @@ namespace YAML
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Vector2<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Vector2<T>& v)
|
||||
{
|
||||
return Node(fmt::format("({},{})", v.x, v.y));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Vector2<T>& v)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{})", v.x, v.y);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Vector3<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Vector3<T>& v)
|
||||
{
|
||||
return Node(fmt::format("({},{},{})", v.x, v.y, v.z));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Vector3<T>& v)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{})", v.x, v.y, v.z);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Vector4<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Vector4<T>& v)
|
||||
{
|
||||
return Node(fmt::format("({},{},{},{})", v.x, v.y, v.z, v.w));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Vector4<T>& v)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{},{})", v.x, v.y, v.z, v.w);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Vector2_SIMD<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Vector2_SIMD<T>& v)
|
||||
{
|
||||
return Node(fmt::format("({},{})", v.x, v.y));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Vector2_SIMD<T>& v)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{})", v.x, v.y);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Vector3_SIMD<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Vector3_SIMD<T>& v)
|
||||
{
|
||||
return Node(fmt::format("({},{},{})", v.x, v.y, v.z));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Vector3_SIMD<T>& v)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()), "({},{},{})", v.x, v.y, v.z);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Matrix3<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Matrix3<T>& mat)
|
||||
{
|
||||
return Node(fmt::format("(({},{},{}),({},{},{}),({},{},{}))",
|
||||
mat[0][0], mat[0][1], mat[0][2],
|
||||
mat[1][0], mat[1][1], mat[1][2],
|
||||
mat[2][0], mat[2][1], mat[2][2]));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Matrix3<T>& mat)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()),
|
||||
"(({},{},{}),({},{},{}),({},{},{}))",
|
||||
mat[0][0], mat[0][1], mat[0][2],
|
||||
mat[1][0], mat[1][1], mat[1][2],
|
||||
mat[2][0], mat[2][1], mat[2][2]);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Matrix3_SIMD<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Matrix3_SIMD<T>& mat)
|
||||
{
|
||||
return Node(fmt::format("(({},{},{}),({},{},{}),({},{},{}))",
|
||||
mat[0][0], mat[0][1], mat[0][2],
|
||||
mat[1][0], mat[1][1], mat[1][2],
|
||||
mat[2][0], mat[2][1], mat[2][2]));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Matrix3_SIMD<T>& mat)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()),
|
||||
"(({},{},{}),({},{},{}),({},{},{}))",
|
||||
mat[0][0], mat[0][1], mat[0][2],
|
||||
mat[1][0], mat[1][1], mat[1][2],
|
||||
mat[2][0], mat[2][1], mat[2][2]);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct convert<OpenVulkano::Math::Matrix4<T>>
|
||||
{
|
||||
static Node encode(const OpenVulkano::Math::Matrix4<T>& mat)
|
||||
{
|
||||
return Node(fmt::format("(({},{},{},{}),({},{},{},{}),({},{},{},{}),({},{},{},{}))",
|
||||
mat[0][0], mat[0][1], mat[0][2], mat[0][3],
|
||||
mat[1][0], mat[1][1], mat[1][2], mat[1][3],
|
||||
mat[2][0], mat[2][1], mat[2][2], mat[2][3],
|
||||
mat[3][0], mat[3][1], mat[3][2], mat[3][3]));
|
||||
}
|
||||
|
||||
static bool decode(const Node& node, OpenVulkano::Math::Matrix4<T>& mat)
|
||||
{
|
||||
if (node.IsScalar())
|
||||
{
|
||||
size_t ret = c4::unformat(c4::to_csubstr(node.Scalar().c_str()),
|
||||
"(({},{},{},{}),({},{},{},{}),({},{},{},{}),({},{},{},{}))",
|
||||
mat[0][0], mat[0][1], mat[0][2], mat[0][3],
|
||||
mat[1][0], mat[1][1], mat[1][2], mat[1][3],
|
||||
mat[2][0], mat[2][1], mat[2][2], mat[2][3],
|
||||
mat[3][0], mat[3][1], mat[3][2], mat[3][3]);
|
||||
return ret != c4::csubstr::npos;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user