本文整理汇总了C++中std::iostream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ iostream::rdbuf方法的具体用法?C++ iostream::rdbuf怎么用?C++ iostream::rdbuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::iostream
的用法示例。
在下文中一共展示了iostream::rdbuf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
gzstream::gzstream( std::iostream & strm,
unsigned int buffer_size )
: std::iostream( static_cast< std::streambuf * >( 0 ) )
, M_gzstreambuf( *(strm.rdbuf()), buffer_size )
{
this->init( &M_gzstreambuf );
}
示例2: write_stream
std::shared_ptr<Response> request(const std::string& request_type, const std::string& path, std::iostream& content,
const std::map<std::string, std::string>& header = std::map<std::string, std::string>()) {
std::string corrected_path = path;
if (corrected_path == "")
corrected_path = "/";
content.seekp(0, std::ios::end);
auto content_length = content.tellp();
content.seekp(0, std::ios::beg);
boost::asio::streambuf write_buffer;
std::ostream write_stream(&write_buffer);
write_stream << request_type << " " << corrected_path << " HTTP/1.1\r\n";
write_stream << "Host: " << host << "\r\n";
for (auto& h : header) {
write_stream << h.first << ": " << h.second << "\r\n";
}
if (content_length>0)
write_stream << "Content-Length: " << content_length << "\r\n";
write_stream << "\r\n";
if (content_length>0)
write_stream << content.rdbuf();
try {
connect();
boost::asio::write(*socket, write_buffer);
}
catch (const std::exception& e) {
socket_error = true;
throw std::invalid_argument(e.what());
}
return request_read();
}
示例3:
/*!
*/
gzfilterstream::gzfilterstream( std::iostream & strm,
int level,
std::size_t buf_size )
: std::iostream( static_cast< std::streambuf* >( 0 ) )
, M_filter_buf( *(strm.rdbuf()), level, buf_size )
{
// std::basic_ios::init( basic_streambuf<charT,traits>* sb );
this->init( &M_filter_buf );
}