Skip to content

Instantly share code, notes, and snippets.

@berkus
Created September 23, 2013 19:01
Show Gist options
  • Save berkus/6675271 to your computer and use it in GitHub Desktop.
Save berkus/6675271 to your computer and use it in GitHub Desktop.
Lambdaed
inline std::ostream& operator << (std::ostream& os, ssu::base_stream::packet const& pkt)
{
std::string packet_type = [](stream_protocol::packet_type type){
switch (type) {
case stream_protocol::packet_type::invalid: return "invalid";
case stream_protocol::packet_type::init: return "init";
case stream_protocol::packet_type::reply: return "reply";
case stream_protocol::packet_type::data: return "data";
case stream_protocol::packet_type::datagram:return "datagram";
case stream_protocol::packet_type::ack: return "ack";
case stream_protocol::packet_type::reset: return "reset";
case stream_protocol::packet_type::attach: return "attach";
case stream_protocol::packet_type::detach: return "detach";
default: return "unknown";
}
}(pkt.type);
os << "[packet txseq " << pkt.tx_byte_seq << ", type " << packet_type
<< ", owner " << pkt.owner << ", header " << pkt.header_len
<< (pkt.late ? ", late" : ", not late") << ", data " << pkt.buf << "]";
return os;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment