当前位置: 首页>>代码示例>>C++>>正文


C++ streambuf::pubseekpos方法代码示例

本文整理汇总了C++中std::streambuf::pubseekpos方法的典型用法代码示例。如果您正苦于以下问题:C++ streambuf::pubseekpos方法的具体用法?C++ streambuf::pubseekpos怎么用?C++ streambuf::pubseekpos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::streambuf的用法示例。


在下文中一共展示了streambuf::pubseekpos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

    virtual std::streampos seekoff (std::streamoff off, std::ios_base::seekdir way,
                   std::ios_base::openmode which = std::ios_base::in)
    {
        std::streamoff newpos;
        if ( way == std::ios_base::beg )
        {
            newpos = off;
        }
        else if ( way == std::ios_base::cur )
        {
            newpos = _curPos + off;
        }
        else if ( way == std::ios_base::end )
        {
            newpos = _numChars + off;
        }
        else
        {
            return -1;
        }

        if ( newpos<0 || newpos>_numChars ) return -1;
        if ( ARCHIVE_POS(_streambuf->pubseekpos( STREAM_POS(_startPos+newpos), which)) < 0 ) return -1;
        _curPos = newpos;
        return _curPos;
    }
开发者ID:MORTAL2000,项目名称:OpenSceneGraph,代码行数:26,代码来源:OSGA_Archive.cpp

示例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;
  }
}
开发者ID:irrawaddy28,项目名称:carmel,代码行数:19,代码来源:read_stream.hpp

示例3: 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;
}
开发者ID:sundoom,项目名称:sunstudio,代码行数:22,代码来源:campaign_file_header.cpp


注:本文中的std::streambuf::pubseekpos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。