Parse Performance/Maintenance Data (Message Type 3)

This commit is contained in:
Dan Paulat 2021-06-19 15:58:36 -05:00
parent e440d8c657
commit 2fc12d44db
10 changed files with 2854 additions and 86 deletions

View file

@ -1,7 +1,5 @@
#include <scwx/wsr88d/rda/message.hpp>
#include <istream>
#include <boost/log/trivial.hpp>
namespace scwx
@ -28,12 +26,23 @@ Message::~Message() = default;
Message::Message(Message&&) noexcept = default;
Message& Message::operator=(Message&&) noexcept = default;
bool Message::ValidateSize(std::istream& is, size_t bytesRead) const
bool Message::ValidateMessage(std::istream& is, size_t bytesRead) const
{
bool messageValid = true;
size_t dataSize = header().message_size() * 2 - header().SIZE;
if (bytesRead != dataSize)
if (is.eof())
{
BOOST_LOG_TRIVIAL(warning) << logPrefix_ << "Reached end of file";
messageValid = false;
}
else if (is.fail())
{
BOOST_LOG_TRIVIAL(warning)
<< logPrefix_ << "Could not read from input stream";
messageValid = false;
}
else if (bytesRead != dataSize)
{
is.seekg(static_cast<std::streamoff>(dataSize) -
static_cast<std::streamoff>(bytesRead),