|
| 1 | +#ifndef RFL_PARSING_PARSER_BYTESTRING_HPP_ |
| 2 | +#define RFL_PARSING_PARSER_BYTESTRING_HPP_ |
| 3 | + |
| 4 | +#include <map> |
| 5 | + |
| 6 | +#include "../Bytestring.hpp" |
| 7 | +#include "../Result.hpp" |
| 8 | +#include "Parser_base.hpp" |
| 9 | +#include "schema/Type.hpp" |
| 10 | + |
| 11 | +namespace rfl::parsing { |
| 12 | + |
| 13 | +template <class R, class W, class ProcessorsType> |
| 14 | + requires AreReaderAndWriter<R, W, Bytestring> |
| 15 | +struct Parser<R, W, Bytestring, ProcessorsType> { |
| 16 | + using InputVarType = typename R::InputVarType; |
| 17 | + using ParentType = Parent<W>; |
| 18 | + |
| 19 | + static Result<Bytestring> read(const R& _r, |
| 20 | + const InputVarType& _var) noexcept { |
| 21 | + return _r.template to_basic_type<Bytestring>(_var); |
| 22 | + } |
| 23 | + |
| 24 | + template <class P> |
| 25 | + static void write(const W& _w, const Bytestring& _b, |
| 26 | + const P& _parent) noexcept { |
| 27 | + ParentType::add_value(_w, _b, _parent); |
| 28 | + } |
| 29 | + |
| 30 | + static schema::Type to_schema( |
| 31 | + std::map<std::string, schema::Type>* _definitions) { |
| 32 | + return schema::Type{schema::Type::Bytestring{}}; |
| 33 | + } |
| 34 | +}; |
| 35 | + |
| 36 | +} // namespace rfl::parsing |
| 37 | + |
| 38 | +#endif |
0 commit comments