| 24 | |
| 25 | template<typename... Ts> |
| 26 | uint32_t parse(unsigned char const* _mem, uint32_t _size, Ts&... _ts) { |
| 27 | uint32_t parsed{0}; |
| 28 | auto checked_parse = [&](auto& _out) { |
| 29 | auto const result = from_mem(_mem, _size, _out); |
| 30 | if (result == 0) { |
| 31 | return false; |
| 32 | } |
| 33 | parsed += result; |
| 34 | _mem += result; |
| 35 | _size -= result; |
| 36 | return true; |
| 37 | }; |
| 38 | return (checked_parse(_ts) && ...) ? parsed : 0; |
| 39 | } |
| 40 | |
| 41 | inline uint32_t deserialize(const byte_t* _data, uint32_t _size, command_header& _out) { |
| 42 | return parse(_data, _size, _out.id_, _out.version_, _out.client_, _out.length_); |
no test coverage detected