#include "ydi_networking.h" #include #include namespace ydi { MessageType to_message_type(std::string const &msg) { int as_int{ std::stoi(msg) }; if (as_int >= 0 && as_int < MESSAGE_TYPE_MAX) { return (MessageType)as_int; } else { return NONE; } } MessageType message_type(zmq::multipart_t const &msg, size_t *type_idx) { MessageType type{ to_message_type(msg[0].to_string()) }; size_t idx{ 0 }; if (!type) { ++idx; type = to_message_type(msg[0].to_string()); } if (!type) { idx = std::numeric_limits::max(); } if (type_idx) { *type_idx = idx; } return type; } bool decompose_connect(zmq::multipart_t &msg, int *code) { size_t start{}; MessageType actual_type{ message_type(msg, &start) }; if (actual_type) { } } void extend_multipart(zmq::multipart_t &mpart, MessageType type) { mpart.addstr(std::to_string(type)); } void extend_multipart(zmq::multipart_t &mpart, ClueID id) { mpart.addstr(std::to_string(id)); } void extend_multipart(zmq::multipart_t &mpart, std::string const &string) { mpart.addstr(string); } void extend_multipart(zmq::multipart_t &mpart, std::string_view const &strv) { mpart.addmem(strv.data(), strv.size()); } void extend_multipart(zmq::multipart_t &mpart, char const *cstr) { mpart.addstr(cstr); } void extend_multipart(zmq::multipart_t &mpart, int const &arg) { std::string as_string{ std::to_string(arg) }; mpart.addstr(as_string); } void extend_multipart(zmq::multipart_t &mpart, zmq::multipart_t const &right) { mpart.append(right.clone()); } void extend_multipart(zmq::multipart_t &mpart) {} }