From 6e746716d6a5c72fbd42539c6d5d92da8830cb9e Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Fri, 1 Jul 2011 17:40:37 +0200 Subject: Overload read and write for Vector3. --- messages.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'messages.h') diff --git a/messages.h b/messages.h index f1625f8..f388805 100644 --- a/messages.h +++ b/messages.h @@ -25,12 +25,22 @@ class MessageBase { static inline void read(boost::asio::ip::tcp::socket& socket, T& v) { boost::asio::read(socket, boost::asio::buffer(&v, sizeof(T))); } + static inline void read(boost::asio::ip::tcp::socket& socket, Vector3& pos) { + read(socket, pos.x); + read(socket, pos.y); + read(socket, pos.z); + } static std::string read_string(boost::asio::ip::tcp::socket& socket); template static inline void write(boost::asio::ip::tcp::socket& socket, T& v) { boost::asio::write(socket, boost::asio::buffer(&v, sizeof(T))); } + static inline void write(boost::asio::ip::tcp::socket& socket, Vector3& pos) { + write(socket, pos.x); + write(socket, pos.y); + write(socket, pos.z); + } static void write_string(boost::asio::ip::tcp::socket& socket, std::string str); -- cgit v1.2.3