draconisplusplus/include/rfl/xml/Parser.hpp

43 lines
1.2 KiB
C++
Raw Normal View History

2024-06-05 19:04:53 -04:00
#ifndef RFL_XML_PARSER_HPP_
#define RFL_XML_PARSER_HPP_
#include <type_traits>
#include "../internal/is_attribute.hpp"
#include "../parsing/NamedTupleParser.hpp"
#include "../parsing/Parser.hpp"
#include "Reader.hpp"
#include "Writer.hpp"
namespace rfl {
2024-06-08 14:10:59 -04:00
namespace parsing {
/// XML is very special. It doesn't have proper support for arrays, which
/// means that we just need to ignore empty containers. Therefore, we need
/// to a template specialization for the NamedTuple parser to accommodate
/// for it.
template <class ProcessorsType, class... FieldTypes>
2024-06-16 00:13:15 -04:00
requires AreReaderAndWriter<xml::Reader, xml::Writer, NamedTuple<FieldTypes...>>
struct Parser<xml::Reader, xml::Writer, NamedTuple<FieldTypes...>, ProcessorsType>
: public NamedTupleParser<
2024-06-08 15:53:06 -04:00
xml::Reader,
xml::Writer,
2024-06-16 00:13:15 -04:00
/*_ignore_empty_containers=*/true,
/*_all_required=*/ProcessorsType::all_required_,
ProcessorsType,
FieldTypes...> {};
2024-06-08 14:10:59 -04:00
} // namespace parsing
} // namespace rfl
2024-06-05 19:04:53 -04:00
namespace rfl {
2024-06-08 14:10:59 -04:00
namespace xml {
2024-06-05 19:04:53 -04:00
2024-06-08 14:10:59 -04:00
template <class T, class ProcessorsType>
using Parser = parsing::Parser<Reader, Writer, T, ProcessorsType>;
2024-06-05 19:04:53 -04:00
2024-06-08 14:10:59 -04:00
}
} // namespace rfl
2024-06-05 19:04:53 -04:00
#endif