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


C++ stream_type::peek方法代码示例

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


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

示例1: getLinearMaxChunk

			static std::pair<int64_t,int64_t> getLinearMaxChunk(stream_type & stream)
			{
				int64_t refid = -1;
				int64_t maxpos = 0;
				
				::libmaus2::bambam::BamIndexLinearChunk LC;
				
				while ( stream.peek() != stream_type::traits_type::eof() )
				{
					stream.read(reinterpret_cast<char *>(&LC),sizeof(::libmaus2::bambam::BamIndexLinearChunk));
					
					if ( refid == -1 )
						refid = LC.refid;
					
					// put back element, if it has a different refid	
					if ( static_cast<int64_t>(LC.refid) != refid )
					{
						stream.clear();
						stream.seekg(-static_cast<int64_t>(sizeof(::libmaus2::bambam::BamIndexLinearChunk)),std::ios::cur);
						break;
					}
					
					maxpos = std::max(maxpos,LC.chunkid);
				}
				
				return std::pair<int64_t,int64_t>(refid,maxpos);
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:27,代码来源:BamIndexGenerator.hpp

示例2: countBinChunks

			static std::pair<int64_t,uint64_t> countBinChunks(stream_type & stream)
			{
				int64_t bin = -1;
				int64_t refid = -1;
				uint64_t chunks = 0;

				::libmaus2::bambam::BamIndexBinChunk BC;
				
				while ( stream.peek() != stream_type::traits_type::eof() )
				{
					stream.read(reinterpret_cast<char *>(&BC),sizeof(::libmaus2::bambam::BamIndexBinChunk));

					if ( refid < 0 )
						refid = BC.refid;
					if ( bin < 0 )
						bin = BC.bin;
					
					if ( 
						refid != static_cast<int64_t>(BC.refid) 
						||
						bin != static_cast<int64_t>(BC.bin)
					)
					{
						stream.clear();
						stream.seekg(-static_cast<int64_t>(sizeof(::libmaus2::bambam::BamIndexBinChunk)),std::ios::cur);
						stream.clear();
						break;
					}
					
					chunks++;
				}
					
				return std::pair<uint64_t,uint64_t>(bin,chunks);
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:34,代码来源:BamIndexGenerator.hpp

示例3: countLinearChunks

			static std::pair<int64_t,uint64_t> countLinearChunks(stream_type & stream)
			{
				int64_t refid = -1;
				uint64_t cnt = 0;
				
				::libmaus2::bambam::BamIndexLinearChunk LC;
				
				while ( stream.peek() != stream_type::traits_type::eof() )
				{
					stream.read(reinterpret_cast<char *>(&LC),sizeof(::libmaus2::bambam::BamIndexLinearChunk));
					
					if ( refid == -1 )
						refid = LC.refid;
					
					// put back element, if it has a different refid	
					if ( static_cast<int64_t>(LC.refid) != refid )
					{
						stream.clear();
						stream.seekg(-static_cast<int64_t>(sizeof(::libmaus2::bambam::BamIndexLinearChunk)),std::ios::cur);
						break;
					}
					
					cnt++;
				}
				
				return std::pair<int64_t,uint64_t>(refid,cnt);
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:27,代码来源:BamIndexGenerator.hpp

示例4: peekLinearChunk

			static bool peekLinearChunk(stream_type & stream, uint64_t const refid, uint64_t const pos, unsigned int const posshift)
			{
				::libmaus2::bambam::BamIndexLinearChunk LC;

				if ( stream.peek() == stream_type::traits_type::eof() )
					return false;
				
				stream.read(reinterpret_cast<char *>(&LC),sizeof(::libmaus2::bambam::BamIndexLinearChunk));
				stream.clear();
				stream.seekg(-static_cast<int64_t>(sizeof(::libmaus2::bambam::BamIndexLinearChunk)),std::ios::cur);
				
				return (LC.refid == refid) && ((LC.pos >> posshift)==(pos>>posshift));
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:13,代码来源:BamIndexGenerator.hpp

示例5: getLEInteger

			static value_type getLEInteger(stream_type & stream)
			{
				value_type v = 0;
				
				for ( uint64_t i = 0; i < length; ++i )
					if ( stream.peek() == stream_type::traits_type::eof() )
					{
						libmaus2::exception::LibMausException ex;
						ex.getStream() << "Failed to little endian number of length " << length << " in BamIndex::getLEInteger." << std::endl;
						ex.finish();
						throw ex;		
					}
					else
					{
						v |= static_cast<value_type>(stream.get()) << (8*i);
					}
									
				return v;
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:19,代码来源:BamIndex.hpp

示例6: peekBin

			static int64_t peekBin(stream_type & stream)
			{
				::libmaus2::bambam::BamIndexBinChunk BC;
				
				if ( stream.peek() == stream_type::traits_type::eof() )
					return -1;
					
				stream.read(
					reinterpret_cast<char *>(&BC),
					sizeof(::libmaus2::bambam::BamIndexBinChunk)
				);
				
				assert ( stream.gcount() == sizeof(::libmaus2::bambam::BamIndexBinChunk) );
				
				stream.clear();
				stream.seekg(-static_cast<int64_t>(sizeof(::libmaus2::bambam::BamIndexBinChunk)),std::ios::cur);
				
				return BC.refid;
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:19,代码来源:BamIndexGenerator.hpp

示例7: readBlock

			bool readBlock(stream_type & stream)
			{
				state = bgzfinflateblockstate_read_block;
				
				if ( failed() )
					return false;
				
				try
				{
					std::pair<uint64_t,uint64_t> preblockinfo = BgzfInflateBase::readBlock(stream);
					
					blockinfo = ::libmaus2::lz::BgzfInflateInfo(
						preblockinfo.first,
						preblockinfo.second,
						preblockinfo.second ? false : (stream.peek() == stream_type::traits_type::eof())
					);
										
					return blockinfo.uncompressed;
				}
				catch(libmaus2::exception::LibMausException const & lex)
				{
					libmaus2::exception::LibMausException::unique_ptr_type tex(lex.uclone());
					ex = UNIQUE_PTR_MOVE(tex);
					return false;
				}
				catch(std::exception const & lex)
				{
					libmaus2::exception::LibMausException::unique_ptr_type tex(new libmaus2::exception::LibMausException);
					ex = UNIQUE_PTR_MOVE(tex);
					ex->getStream() << lex.what();
					ex->finish(false);
					return false;
				}
				catch(...)
				{
					libmaus2::exception::LibMausException::unique_ptr_type tex(new libmaus2::exception::LibMausException);
					ex = UNIQUE_PTR_MOVE(tex);
					ex->getStream() << "BgzfInflateBlock::readBlock(): unknown exception caught";
					ex->finish(false);
					return false;				
				}
			}
开发者ID:jameslz,项目名称:libmaus2,代码行数:42,代码来源:BgzfInflateBlock.hpp


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