#include #include namespace brynet { namespace net { class SendableMsg { public: using Ptr = std::shared_ptr; virtual ~SendableMsg() = default; virtual const void* data() = 0; virtual size_t size() = 0; }; class StringSendMsg : public SendableMsg { public: explicit StringSendMsg(const char* buffer, size_t len) : mMsg(buffer, len) {} explicit StringSendMsg(const std::string& buffer) : mMsg(buffer) {} explicit StringSendMsg(std::string&& buffer) : mMsg(std::move(buffer)) {} const void* data() override { return static_cast(mMsg.data()); } size_t size() override { return mMsg.size(); } private: std::string mMsg; }; static SendableMsg::Ptr MakeStringMsg(const char* buffer, size_t len) { return std::make_shared(buffer, len); } static SendableMsg::Ptr MakeStringMsg(const std::string& buffer) { return std::make_shared(buffer); } static SendableMsg::Ptr MakeStringMsg(std::string&& buffer) { return std::make_shared(std::move(buffer)); } }}// namespace brynet::net