本文整理汇总了C++中std::streambuf::pubseekoff方法的典型用法代码示例。如果您正苦于以下问题:C++ streambuf::pubseekoff方法的具体用法?C++ streambuf::pubseekoff怎么用?C++ streambuf::pubseekoff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::streambuf
的用法示例。
在下文中一共展示了streambuf::pubseekoff方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
bool t_single_scenario_campaign_file_header::read(
std::streambuf & stream,
t_progress_handler * progress_handler_ptr )
{
m_map_data_start = stream.pubseekoff( 0, std::ios::cur );
m_map_data_end = stream.pubseekoff( 0, std::ios::end );
stream.pubseekpos( m_map_data_start );
try
{
t_inflate_filter inflater( stream );
if ( !::read( inflater, *m_map_header_ptr, progress_handler_ptr ) )
return false;
}
catch ( t_inflate_filter::t_data_error const & )
{
return false;
}
return true;
}
示例2: size
/**
read whole contents of streambuf 'buf'
\return size of data malloced and copied into \param[out] buffer unless size
is 0 (in which case buffer is set to NULL for convenience, so you can blindly free)
requires put pointer is at end for determining size (e.g. just-written iostream)
*/
inline std::size_t read_streambuf_malloc(std::streambuf& buf, void*& buffer) {
typedef std::streambuf::pos_type Pos;
typedef std::streambuf::off_type Off;
Pos sz = buf.pubseekoff(0, std::ios::end, std::ios_base::out);
if (sz > 0 && seek_ok(sz) && seek_ok(buf.pubseekpos(0, std::ios_base::in)))
return buf.sgetn((char*)(buffer = std::malloc(sz)), sz);
else {
buffer = 0;
return 0;
}
}