#include #include #include #include using boost::sub_range; struct Msgs { inline Msgs() {} inline ~Msgs() {} inline int Send(Buffer* buf, const sub_range >& about1) { unsigned int headCount = 0; // Determine total length of the message. Counter cntr(max_msg_length); if (!cntr.Add(sizeof(int))) { buf->ews_.SetErrorWords(1, __FILE__, __LINE__); return 0; } if (!cntr.MultiplyAndAdd(about1.size(), sizeof(short))) { buf->ews_.SetErrorWords(1, __FILE__, __LINE__); return 0; } if (!buf->Receive(&cntr.value_, sizeof(cntr.value_))) { buf->ews_.SetErrorWords(2, __FILE__, __LINE__); return 0; } headCount = about1.size(); if (!buf->Receive(&headCount, sizeof(int))) { buf->ews_.SetErrorWords(1, __FILE__, __LINE__); return 0; } list::const_iterator rit1 = boost::begin(about1); list::const_iterator rit2 = boost::end(about1); for (; rit1 != rit2; ++rit1) { if (!buf->Receive(&(*rit1), sizeof(short))) { buf->ews_.SetErrorWords(1, __FILE__, __LINE__); return 0; } } if (!buf->SendStoredData()) { buf->ews_.SetErrorWords(2, __FILE__, __LINE__); return 0; } return 1; } };