mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-07 03:06:18 +08:00
Added XML support; #21
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#ifndef RFL_XML_IS_REQUIRED_FOR_XML_HPP_
|
||||
#define RFL_XML_IS_REQUIRED_FOR_XML_HPP_
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#include "rfl/internal/has_reflection_type_v.hpp"
|
||||
#include "rfl/parsing/is_required.hpp"
|
||||
#include "rfl/parsing/is_vector_like.hpp"
|
||||
|
||||
namespace rfl {
|
||||
namespace xml {
|
||||
|
||||
// Empty vectors are simply not represented in XML. Therefore, XML requires more
|
||||
// lax rules when things are required.
|
||||
template <class T>
|
||||
consteval bool is_required_for_xml() {
|
||||
using Type = std::decay_t<std::remove_pointer_t<T>>;
|
||||
if constexpr (internal::has_reflection_type_v<T>) {
|
||||
return is_required_for_xml<typename T::ReflectionType>();
|
||||
} else {
|
||||
return parsing::is_required<Type>() && !parsing::is_vector_like_v<Type>;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace xml
|
||||
} // namespace rfl
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user