X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/4a160f880ce46153acb23b137f30fd588df5fb9d..6b5e09540e9392a7015fae1ad3b01b0973600ff2:/rpc/marshall.h diff --git a/rpc/marshall.h b/rpc/marshall.h index 69b10df..6412612 100644 --- a/rpc/marshall.h +++ b/rpc/marshall.h @@ -13,8 +13,8 @@ class unmarshall; class marshall { private: - string buf_ = string(DEFAULT_RPC_SZ, 0); // Raw bytes buffer - size_t index_ = RPC_HEADER_SZ; // Read/write head position + string buf_ = string(rpc_protocol::DEFAULT_RPC_SZ, 0); // Raw bytes buffer + size_t index_ = rpc_protocol::RPC_HEADER_SZ; // Read/write head position public: template @@ -32,14 +32,14 @@ class marshall { // with header inline operator string() const { return buf_.substr(0,index_); } // without header - inline string content() const { return buf_.substr(RPC_HEADER_SZ,index_-RPC_HEADER_SZ); } + inline string content() const { return buf_.substr(rpc_protocol::RPC_HEADER_SZ,index_-rpc_protocol::RPC_HEADER_SZ); } // letting S be a defaulted template parameter forces the compiler to // delay looking up operator<<(marshall&, rpc_sz_t) until we define it // (i.e. we define an operator for marshalling uint32_t) - template inline void + template inline void pack_header(const T & h) { - VERIFY(sizeof(T)+sizeof(S) <= RPC_HEADER_SZ); + VERIFY(sizeof(T)+sizeof(S) <= rpc_protocol::RPC_HEADER_SZ); size_t saved_sz = index_; index_ = 0; *this << (S)(saved_sz - sizeof(S)) << (T)h; @@ -55,10 +55,10 @@ class unmarshall { public: unmarshall(const string &s, bool has_header) - : buf_(s),index_(RPC_HEADER_SZ) { + : buf_(s),index_(rpc_protocol::RPC_HEADER_SZ) { if (!has_header) - buf_.insert(0, RPC_HEADER_SZ, 0); - ok_ = (buf_.size() >= RPC_HEADER_SZ); + buf_.insert(0, rpc_protocol::RPC_HEADER_SZ, 0); + ok_ = (buf_.size() >= rpc_protocol::RPC_HEADER_SZ); } bool ok() const { return ok_; } @@ -74,11 +74,11 @@ class unmarshall { template inline void unpack_header(T & h) { - VERIFY(sizeof(T)+sizeof(rpc_sz_t) <= RPC_HEADER_SZ); + VERIFY(sizeof(T)+sizeof(rpc_protocol::rpc_sz_t) <= rpc_protocol::RPC_HEADER_SZ); // first 4 bytes hold length field - index_ = sizeof(rpc_sz_t); + index_ = sizeof(rpc_protocol::rpc_sz_t); *this >> h; - index_ = RPC_HEADER_SZ; + index_ = rpc_protocol::RPC_HEADER_SZ; } template inline T _grab() { T t; *this >> t; return t; } @@ -154,8 +154,8 @@ inline unmarshall & operator>>(unmarshall &u, _c_ &a) { return u >> a._tuple_(); inline marshall & operator<<(marshall &m, const _c_ a) { return m << a._tuple_(); } // our first two marshallable structs... -MARSHALLABLE(request_header) -MARSHALLABLE(reply_header) +MARSHALLABLE(rpc_protocol::request_header) +MARSHALLABLE(rpc_protocol::reply_header) // // Marshalling for STL containers