本文整理汇总了C++中message::buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ message::buffer方法的具体用法?C++ message::buffer怎么用?C++ message::buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类message
的用法示例。
在下文中一共展示了message::buffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_handler
void AdminClient::read_handler(const boost::system::error_code& error, std::size_t bytes) {
std::cout << "Recieved " << bytes << " bytes.\n";
// The extra parens around the first argument here are necessary
// to avoid g++ interpreting this as a function declaration
//std::string s((std::istreambuf_iterator<char>(&read_buffer_)), std::istreambuf_iterator<char>());
if (error == boost::asio::error::eof)
close();
else if (error == boost::asio::error::operation_aborted)
return;
else if (error){
std::cout << "Throwing an error.\n";
throw boost::system::system_error(error); // Some other error.
}
std::string s(read_message_.data(bytes));
std::cout << "Built string.\n";
read_message_.consume(bytes);
std::cout << read_message_.buffer().size() << " bytes remaining in buffer.\n";
std::cout << s << "-----------------------\n";
boost::system::error_code err;
boost::asio::async_read_until(sock_, read_message_.buffer(), '\n',
boost::bind(&AdminClient::read_handler, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
示例2: s
message(const message& msg) {
const boost::asio::streambuf& sb(msg.buffer());
boost::asio::streambuf::const_buffers_type data = sb.data();
std::string s(boost::asio::buffers_begin(data), boost::asio::buffers_end(data));
from_string(s.c_str(), s.length());
}