diff options
Diffstat (limited to 'applications/message_process/include/message_process.hpp')
-rw-r--r-- | applications/message_process/include/message_process.hpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/applications/message_process/include/message_process.hpp b/applications/message_process/include/message_process.hpp index 51f474d..e820b60 100644 --- a/applications/message_process/include/message_process.hpp +++ b/applications/message_process/include/message_process.hpp @@ -55,6 +55,7 @@ public: bool read(uint8_t *dst, uint32_t length); bool write(const Vec *vec, size_t length); bool write(const uint32_t type, const void *src = nullptr, uint32_t length = 0); + bool skip(uint32_t length); template <typename T> bool read(T &dst) { @@ -62,6 +63,15 @@ public: } template <typename T> + bool readOrSkip(T &dst, uint32_t expectedLength) { + if (expectedLength == sizeof(dst)) { + return read(reinterpret_cast<uint8_t *>(&dst), sizeof(dst)); + } else { + return skip(expectedLength); + } + } + + template <typename T> bool write(const uint32_t type, const T &src) { return write(type, reinterpret_cast<const void *>(&src), sizeof(src)); } |