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


C++ istream::seekg方法代码示例

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


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

示例1: readStream

void ScorePageBase::readStream(istream& testfile, int verboseQ) {
   int binaryQ = 0;  // to test if reading a binary or PMX data file.

   if (&testfile == &cin) {
      // presume that standard input is PMX data, and not binary data.
      binaryQ = 0;
   } else {
      // The last 4 bytes of a binary SCORE file are 00 3c 1c c6 which equals
      // the float value -9999.0.
      testfile.seekg(-4, ios::end);
      unsigned char databytes[4] = {0xff};
      testfile.read((char*)databytes, 4);
      if (databytes[0] == 0x00 && databytes[1] == 0x3c &&
            databytes[2] == 0x1c && databytes[3] == 0xc6) {
         binaryQ = 1;
      } else {
         binaryQ = 0;
      }
      testfile.seekg(0, ios::beg);
   }

   if (binaryQ) {
      readBinary(testfile, verboseQ);
   } else {
      readPmx(testfile, verboseQ);
   }
}
开发者ID:UIKit0,项目名称:scorelib,代码行数:27,代码来源:ScorePageBase_read.cpp

示例2: getStreamSize

static size_t getStreamSize(istream& stream) {
    auto startPosition = stream.tellg();
    stream.seekg(0, ios_base::end);
    auto fileSize = static_cast<size_t>(stream.tellg());
    stream.seekg(startPosition);
    return fileSize;
}
开发者ID:frostoov,项目名称:TrekUtils,代码行数:7,代码来源:dataset.cpp

示例3:

bool Point3Dot::load(istream &in){
  coords.resize(3);
  int start = in.tellg();
  for(int i = 0; i < 3; i++){
    in >> coords[i];
    if(in.fail()){
      in.clear();
      in.seekg(start+1); //????????? Why that one
      return false;
    }
  }
  in >> theta;
  if(in.fail()){
    in.clear();
    in.seekg(start+1); //????????? Why that one
    return false;
  }
  in >> phi;
  if(in.fail()){
    in.clear();
    in.seekg(start+1); //????????? Why that one
    return false;
  }
  int typeInt;
  in >> typeInt;
  type = (Type)typeInt;
  if(in.fail()){
    in.clear();
    in.seekg(start+1); //????????? Why that one
    return false;
  }
  return true;
}
开发者ID:contaconta,项目名称:neurons,代码行数:33,代码来源:Point3Dot.cpp

示例4: read_whole_stream

/* Reads a whole file/stream: somewhat inelegant */
string read_whole_stream(istream& in) {
	in.seekg(0, ios::end);
	string buf(in.tellg(), '$');
	in.seekg(0, ios::beg);
	in.read(&buf[0], buf.size());
	return buf;
}
开发者ID:dysnomia,项目名称:kit-plag,代码行数:8,代码来源:fileutils.cpp

示例5: getChunkName

void
readsection(HeaderInfo &rwh, uint32 build, uint32 level, istream &rw)
{
	for(uint32 i = 0; i < level; i++)
		cout << "  ";
	string name = getChunkName(rwh.type);
	cout << name << " (" << hex << rwh.length << " bytes @ 0x" <<
	  hex << rw.tellg()-(streampos)12 << "/0x" << hex << rw.tellg() <<
	  ") - [0x" << hex << rwh.type << "] " << rwh.build << endl;

	streampos end = rw.tellg() + (streampos)rwh.length;

	while(rw.tellg() < end){
		HeaderInfo newrwh;
		newrwh.read(rw);

		if(newrwh.build == build){
			readsection(newrwh, build, level+1, rw);

			/* Native Data PLG has the wrong length */
			if(rwh.type == 0x510)
				rw.seekg(end, ios::beg);
		}else{
			streampos sp = rw.tellg()+(streampos)rwh.length;
			sp -= 12;
			rw.seekg(sp, ios::beg);
			break;
		}
	}
}
开发者ID:AdmiralCurtiss,项目名称:rwtools,代码行数:30,代码来源:dumprwtree.cpp

示例6: preprocess_input

string parser::preprocess_input(istream &stream)
{
    streampos start = stream.tellg();
    stream.seekg(0, ios::end);
    streampos end = stream.tellg();
    size_t file_size = end - start;
    stream.seekg(start, ios::beg);
    char bom_test[3];
    static const char * BOM = "\xEF\xBB\xBF";
    stream.read(bom_test, 3u);
    if (strncmp(bom_test, BOM, 3u) == 0) {
        // Matched BOM, keep stream position to prevent its reading
        file_size -= 3u;
    }
    else {
        // Seek stream back
        stream.seekg(start, ios::beg);
    }
    char * buffer = new char[file_size + 1];
    stream.read(buffer, file_size);
    buffer[file_size] = '\0';
    string s0(buffer);
    delete[] buffer;
    string s1 = fix_corrupted_data(s0);
    return s1;
}
开发者ID:woronin,项目名称:kumir2,代码行数:26,代码来源:parser.cpp

示例7: get_fsize

size_t get_fsize(istream& is)
{
    size_t fsize = is.tellg();
    is.seekg(0, std::ios::end);
    fsize = size_t(is.tellg()) - fsize;
    is.seekg(0, std::ios::beg);
    return fsize;
}
开发者ID:anwinged,项目名称:reed-solomon-pkg,代码行数:8,代码来源:main.cpp

示例8: BinaryReader

    BinaryReader(istream &is): buffer(nullptr), size(0), pos(0) {
        is.seekg (0, ios::end);
        size = is.tellg();
        is.seekg (0, ios::beg);

        buffer = new char[size];
        is.read(buffer, size);
        is.seekg(0, ios::beg);
    }
开发者ID:daemacles,项目名称:ess,代码行数:9,代码来源:stlmesh.cpp

示例9: open_font

font font::open_font(istream& thefile,int ptsize,long index) {
    thefile.seekg(0,ios::end);
    int filesize=thefile.tellg();
    thefile.seekg(0,ios::beg);
    auto_ptr<vector<char> > filecont(new vector<char>(filesize));
    thefile.read(&(*filecont)[0],filesize);
    SDL_RWops* wop=SDL_RWFromConstMem(&(*filecont)[0],filesize);
    TTF_Font* thefont = TTF_OpenFontIndexRW(wop,true,ptsize,index);
    return font().build(thefont,filecont);
}
开发者ID:nicolas-van,项目名称:codeyong,代码行数:10,代码来源:sdlw_font.cpp

示例10: FrFileType

FrFILETYPE FrFileType(istream &in)
{
   char buf[BUFFER_SIZE] ;
   long pos = in.tellg() ;
   in.seekg(0) ;
   (void)in.read(buf,sizeof(buf)) ;
   FrFILETYPE type = check_type(buf,in.gcount()) ;
   in.seekg(pos) ;
   return type ;
}
开发者ID:ralfbrown,项目名称:framepac,代码行数:10,代码来源:frfilut3.C

示例11: _getStreamSize

std::streampos Data::_getStreamSize(istream &stream) {
  auto current_pos = stream.tellg();

  //Retrieve length
  stream.seekg(0, stream.end);
  auto endpos = stream.tellg();

  //Restore old position
  stream.seekg(current_pos, stream.beg);

  return endpos - current_pos;
}
开发者ID:Gitborter,项目名称:cryfs,代码行数:12,代码来源:Data.cpp

示例12: sizeof

DecisionTreePtr DecisionTree::readC5(istream& in, AttributeSpec* spec)
{
    int tag;
    in.read((char*)&tag, sizeof(int));
    if (memcmp((char *)&tag, "id=", 3) == 0)
    {
        in.seekg (0, ios::beg);
        return readC5Text(in, spec);
    }
    in.seekg(0, ios::beg);
    return readC5Bin(in, spec);
}
开发者ID:lastfallen,项目名称:mlplus,代码行数:12,代码来源:decision_tree.cpp

示例13: StreamIn

void JackPlugin::StreamIn (istream &s) 
{
	char Test;
	int Version, NumInputs, NumOutputs;

	s.seekg (2, ios::cur );  //skip to next line
	Test = s.peek();         //peek first char
	s.seekg (-2, ios::cur ); //jump back to prior line
	
	if ( (Test >= '0') && (Test <= '9') )
	{
		s >> Version;
	}
开发者ID:sdekrijger,项目名称:spiralsynthmodular,代码行数:13,代码来源:JackPlugin.C

示例14: StreamIn

void SplitterPlugin::StreamIn (istream &s) 
{
	char Test;
	int Version, Channels;

	s.seekg (2, ios::cur );//skip to next line
	Test = s.peek();//peek first char
	s.seekg (-2, ios::cur );//jump back to prior line 
	
	if ( (Test >= '0') && (Test <= '9') )
	{
		s >> Version;
	}
开发者ID:original-male,项目名称:spiralsynthmodular,代码行数:13,代码来源:SplitterPlugin.C

示例15: XING_LABEL_SIZE

XingStreamBase::XingStreamBase(int nIndex, NoteColl& notes, istream& in) : MpegStreamBase(nIndex, notes, in), m_nFrameCount(-1), m_nByteCount(-1), m_nQuality(-1)
{
    fill(&m_toc[0], &m_toc[100], 0);
    in.seekg(m_pos);

    const int XING_LABEL_SIZE (4);
    const int BFR_SIZE (MpegFrame::MPEG_FRAME_HDR_SIZE + 32 + XING_LABEL_SIZE); // MPEG header + side info + "Xing" size //ttt2 not sure if space for CRC16 should be added; then not sure if frame size should be increased by 2 when CRC is found
    char bfr [BFR_SIZE];

    int nSideInfoSize (m_firstFrame.getSideInfoSize());

    int nBfrSize (MpegFrame::MPEG_FRAME_HDR_SIZE + nSideInfoSize + XING_LABEL_SIZE);

    MP3_CHECK_T (nBfrSize <= m_firstFrame.getSize(), m_pos, "Not a Xing stream. This kind of MPEG audio doesn't support Xing.", NotXingStream()); // !!! some kinds of MPEG audio (e.g. "MPEG-1 Layer I, 44100Hz 32000bps" or "MPEG-2 Layer III, 22050Hz 8000bps") have very short frames, which can't accomodate a Xing header

    streamsize nRead (read(in, bfr, nBfrSize));
    STRM_ASSERT (nBfrSize == nRead); // this was supposed to be a valid frame to begin with (otherwise the base class would have thrown) and nBfrSize is no bigger than the frame

    char* pLabel (bfr + MpegFrame::MPEG_FRAME_HDR_SIZE + nSideInfoSize);
    MP3_CHECK_T (0 == strncmp("Xing", pLabel, XING_LABEL_SIZE) || 0 == strncmp("Info", pLabel, XING_LABEL_SIZE), m_pos, "Not a Xing stream. Header not found.", NotXingStream());

    MP3_CHECK_T (4 == read(in, bfr, 4) && 0 == bfr[0] && 0 == bfr[1] && 0 == bfr[2], m_pos, "Not a Xing stream. Header not found.", NotXingStream());
    m_cFlags = bfr[3];
    MP3_CHECK_T ((m_cFlags & 0x0f) == m_cFlags, m_pos, "Not a Xing stream. Invalid flags.", NotXingStream());
    if (0x01 == (m_cFlags & 0x01))
    { // has frames
        MP3_CHECK_T (4 == read(in, bfr, 4), m_pos, "Not a Xing stream. File too short.", NotXingStream());
        m_nFrameCount = get32BitBigEndian(bfr);
    }

    if (0x02 == (m_cFlags & 0x02))
    { // has bytes
        MP3_CHECK_T (4 == read(in, bfr, 4), m_pos, "Not a Xing stream. File too short.", NotXingStream());
        m_nByteCount = get32BitBigEndian(bfr);
    }

    if (0x04 == (m_cFlags & 0x04))
    { // has TOC
        MP3_CHECK_T (100 == read(in, m_toc, 100), m_pos, "Not a Xing stream. File too short.", NotXingStream());
    }

    if (0x08 == (m_cFlags & 0x08))
    { // has quality
        MP3_CHECK_T (4 == read(in, bfr, 4), m_pos, "Not a Xing stream. File too short.", NotXingStream());
        m_nQuality = get32BitBigEndian(bfr);
    }

    streampos posEnd (m_pos);
    posEnd += m_firstFrame.getSize();
    in.seekg(posEnd); //ttt2 2010.12.07 - A header claiming to have TOC but lacking one isn't detected. 1) Should check that values in TOC are ascending. 2) Should check that it actually fits: a 104 bytes-long 32kbps frame cannot hold a 100 bytes TOC along with the header and other things.
}
开发者ID:miracle2k,项目名称:mp3diags,代码行数:51,代码来源:MpegStream.cpp


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