#include "dbcc/message.h" #include #include #include namespace ad { namespace dbcc { std::istream &operator>>(std::istream &in, Message &msg) { std::string preamble; in >> preamble; // Check if we are actually reading a message otherwise fail the stream if (preamble != "BO_") { in.setstate(std::ios_base::failbit); return in; } // Parse the message ID. in >> msg.m_id; // Parse the name of the message std::string name; in >> name; msg.m_name = name.substr(0, name.length() - 1); // Parse the message length in >> msg.m_dlc; // Parse the sender in >> msg.m_from; in.ignore(std::numeric_limits::max(), '\n'); // As long as there is a signal, parse the signal while (in) { Signal sig; in >> sig; if (in) { msg.appendSignal(sig); } } in.clear(); return in; } std::set Message::to() const { std::set collection; for (auto sig : m_signals) { auto toList = sig.to(); collection.insert(toList.begin(), toList.end()); } return collection; } } // namespace dbcc } // namespace ad