int marshall(const Msg& inm, mutable_buffer<char> inb) { int newlen=inb.len()-HEAD_SIZE; if(newlen<=0) throw std::runtime_error("marshalling:: provided buffer is too small"); auto it = m_map.find(inm.type()); if(it==m_map.end()) throw std::runtime_error("marshalling:: message type not supported"); *(reinterpret_cast<int*>(inb.addr())) = htonl(inm.type()); int m_len = it->second->marshall(inm,mutable_buffer<char>(inb.addr()+HEAD_SIZE,newlen)); *(reinterpret_cast<unsigned int*>(inb.addr()+sizeof(int))) = htonl(m_len); return m_len+HEAD_SIZE; }
const_buffer(const mutable_buffer<Tp> &other) : m_addr(other.addr()), m_len(other.len()) {}