X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/dfe8486473094c0769fd1922329c3f0dfd8f43c0..130f2d53438eb6193accb445aca52fa8e2fe4158:/rpc/marshall.h diff --git a/rpc/marshall.h b/rpc/marshall.h index fcb5bab..27cebbb 100644 --- a/rpc/marshall.h +++ b/rpc/marshall.h @@ -34,6 +34,10 @@ typedef int rpc_sz_t; #define DEFAULT_RPC_SZ 1024 #define RPC_HEADER_SZ (std::max(sizeof(req_header), sizeof(reply_header)) + sizeof(rpc_sz_t)) +struct pass { + template inline pass(Args&&...) {} +}; + class marshall { private: char *_buf; // Base of the raw bytes buffer (dynamically readjusted) @@ -48,6 +52,10 @@ class marshall { _ind = RPC_HEADER_SZ; } + template marshall(const Args&... args) : marshall() { + (void)pass{(*this << args)...}; + } + ~marshall() { if (_buf) free(_buf); @@ -210,6 +218,15 @@ class unmarshall { unpack(&h->ret); _ind = RPC_HEADER_SZ; } + + template + void iterate(OutputIterator i, int n) { + while (n--) { + typename OutputIterator::value_type t; + *this >> t; + *i++ = t; + } + } }; unmarshall& operator>>(unmarshall &, bool &);