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


C++ pos_type函数代码示例

本文整理汇总了C++中pos_type函数的典型用法代码示例。如果您正苦于以下问题:C++ pos_type函数的具体用法?C++ pos_type怎么用?C++ pos_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: switch

stdio_streambuf_base::pos_type
stdio_streambuf_base::seekoff(off_type off, ios_base::seekdir dir,
                              ios_base::openmode /* mode */) {
  int whence;
  switch (dir) {
  case ios_base::beg:
    whence = SEEK_SET;
    break;
  case ios_base::cur:
    whence = SEEK_CUR;
    break;
  case ios_base::end:
    whence = SEEK_END;
    break;
  default:
    return pos_type(-1);
  }

  if (off <= numeric_limits<off_type>::max() && FSEEK(_M_file, off, whence) == 0) {
    FPOS_T pos;
    FGETPOS(_M_file, &pos);
    // added 21 june 00 mdb,rjf,wjs: glibc 2.2 changed fpos_t to be a struct instead
    // of a primitive type
    return pos_type(pos);
  }
  else
    return pos_type(-1);
}
开发者ID:vorlonofportland,项目名称:ti-cgt-c6x,代码行数:28,代码来源:stdio_streambuf.cpp

示例2: pos_type

stringbuf::pos_type stringbuf::seekpos(pos_type __pos, ios_base::openmode __mode /* = ios_base::in | ios_base::out */)
{
    __mode &= __M_mode;

    bool __imode = (__mode & ios_base::in) != 0;
    bool __omode = (__mode & ios_base::out) != 0;

    if ((__imode == false) && (__omode == false)) return pos_type(-1);
    if ((__imode && (gptr() == 0)) || (__omode && (pptr() == 0))) return pos_type(-1);

    const off_type __offset = __pos - pos_type(0);

    if (__imode) 
    {
        if ((__offset < 0) || (__offset > (egptr() - eback()))) return pos_type(-1);
        setg(eback(), eback() + static_cast<ptrdiff_t>(__offset), egptr());
    }

    if (__omode) 
    {
        if ((__offset < 0) || (size_t(__offset) > __M_str.size())) return pos_type(-1);
        setp(__M_str.begin(), __M_str.end());
        pbump(static_cast<int>(__offset));
    }

    return __pos;
}
开发者ID:HemingChin,项目名称:POD_STL,代码行数:27,代码来源:sstream.cpp

示例3: pos_type

strstreambuf::pos_type
strstreambuf::seekoff(off_type off, ios_base::seekdir dir, ios_base::openmode which)
{
  if (dir == ios_base::cur && (which & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
      || (which & (ios_base::in | ios_base::out)) == 0)
    return pos_type(-1);

  off_type newoff = 0;
  if (dir == ios_base::cur)
    newoff = ((which & ios_base::in) != 0? gptr(): pptr()) - eback();
  else
    newoff = (epptr() == 0? egptr(): epptr()) - eback();

  if (newoff + off < gptr() - eback() || newoff + off >= epptr() - eback())
    return pos_type(-1);
  
  if (which & ios_base::in)
    if (gptr() == 0)
      return pos_type(-1);
    else
      setg(eback(), eback() + newoff + off, egptr());

  if (which & ios_base::out)
    if (pptr() == 0)
      return pos_type(-1);
    else
      setp(eback() + newoff + off, epptr());

  return newoff + off;
}
开发者ID:dietmarkuehl,项目名称:kuhllib,代码行数:30,代码来源:cstrstrm.cpp

示例4: pos_type

std::streambuf::pos_type
DataIStreamBuf::seekoff(off_type off, std::ios_base::seekdir way, std::ios_base::openmode which)
{
	pos_type ret = pos_type(off_type(-1));

	char* begin = eback();
	char* cur = gptr();
	char* end = egptr();

	off_type newOff = 0;

	if (way == std::ios_base::cur)
	{
		newOff = cur - begin;
	}
	else if (way == std::ios_base::end)
	{
		newOff = end - begin;
	}

	if (newOff + off >= 0 && end - begin >= newOff + off)
	{
		setg(begin, begin + newOff + off, end);
		ret = pos_type(newOff);
	}

	return ret;
}
开发者ID:besser82,项目名称:libblocxx-deb,代码行数:28,代码来源:DataStreams.cpp

示例5: switch

FileStreamBuf::pos_type FileStreamBuf::seekoff(off_type offset, std::ios_base::seekdir whence, std::ios_base::openmode mode)
{
    if(!usrFile || (mode&std::ios_base::out))
        return traits_type::eof();

    pos_type pos = traits_type::eof();
    switch(whence)
    {
        case std::ios_base::beg:
            if(offset == off_type(alureInt64(offset)))
                pos = pos_type(fio.seek(usrFile, offset, SEEK_SET));
            break;

        case std::ios_base::cur:
            offset -= off_type(egptr()-gptr());
            if(offset == off_type(alureInt64(offset)))
                pos = pos_type(fio.seek(usrFile, offset, SEEK_CUR));
            break;

        case std::ios_base::end:
            if(offset == off_type(alureInt64(offset)))
                pos = pos_type(fio.seek(usrFile, offset, SEEK_END));
            break;

        default:
            break;
    }
    if(pos >= 0)
        setg(0, 0, 0);
    return pos;
}
开发者ID:AnsonX10,项目名称:bitfighter,代码行数:31,代码来源:istream.cpp

示例6: switch

stdio_streambuf_base::pos_type
stdio_streambuf_base::seekoff(off_type off, ios_base::seekdir dir,
                              ios_base::openmode /* mode */)
{
  int whence;
  switch(dir) {
  case ios_base::beg:
    whence = SEEK_SET;
    break;
  case ios_base::cur:
    whence = SEEK_CUR;
    break;
  case ios_base::end:
    whence = SEEK_END;
    break;
  default:
    return pos_type(-1);
  }
      
  if (_STLP_VENDOR_CSTD::fseek(_M_file, off, whence) == 0) {
    fpos_t pos;
    _STLP_VENDOR_CSTD::fgetpos(_M_file, &pos);
    // added 21 june 00 mdb,rjf,wjs: glibc 2.2 changed fpos_t to be a struct instead
    // of a primitive type
#if (defined(__GLIBC__) && ( (__GLIBC__ > 2) || ( (__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 2) ) ) )
    return pos_type((streamoff)pos.__pos);
#elif defined(__ISCPP__) || defined(__MVS__) || (__OS400__)
     return pos_type(pos.__fpos_elem[ 0 ]);
#else
    return pos_type(pos);
#endif
  }
  else
    return pos_type(-1);
}
开发者ID:RaymondLiao,项目名称:elektronika,代码行数:35,代码来源:stdio_streambuf.cpp

示例7: __p

strstreambuf::pos_type
strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which)
{
    off_type __p(-1);
    bool pos_in = (__which & ios::in) != 0;
    bool pos_out = (__which & ios::out) != 0;
    bool legal = false;
    switch (__way)
    {
    case ios::beg:
    case ios::end:
        if (pos_in || pos_out)
            legal = true;
        break;
    case ios::cur:
        if (pos_in != pos_out)
            legal = true;
        break;
    }
    if (pos_in && gptr() == nullptr)
        legal = false;
    if (pos_out && pptr() == nullptr)
        legal = false;
    if (legal)
    {
        off_type newoff;
        char* seekhigh = epptr() ? epptr() : egptr();
        switch (__way)
        {
        case ios::beg:
            newoff = 0;
            break;
        case ios::cur:
            newoff = (pos_in ? gptr() : pptr()) - eback();
            break;
        case ios::end:
            newoff = seekhigh - eback();
            break;
        default:
            return pos_type(off_type(-1));
        }
        newoff += __off;
        if (0 <= newoff && newoff <= seekhigh - eback())
        {
            char* newpos = eback() + newoff;
            if (pos_in)
                setg(eback(), newpos, _VSTD::max(newpos, egptr()));
            if (pos_out)
            {
                // min(pbase, newpos), newpos, epptr()
                __off = epptr() - newpos;
                setp(min(pbase(), newpos), epptr());
                pbump(static_cast<int>((epptr() - pbase()) - __off));
            }
            __p = newoff;
        }
    }
    return pos_type(__p);
}
开发者ID:crystax,项目名称:android-toolchain-libcxx-3-6,代码行数:59,代码来源:strstream.cpp

示例8: if

	std::streambuf::pos_type rdbuf::seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode which)
	{
		if (dir == std::ios_base::beg) seekpos(pos_type(off), which);
		else if (dir == std::ios_base::cur) seekpos(pos_ + pos_type(gptr() - eback() + off), which);
		else if (dir == std::ios_base::end) seekpos(decomp_ + pos_type(off), which);
		else return pos_type(-1);
		return pos_ + gptr() - eback();
	}
开发者ID:showermat,项目名称:zsr-utils,代码行数:8,代码来源:compress.cpp

示例9: pos_type

/*******************************************************************************
 raw_omemstream
*******************************************************************************/
raw_ios::pos_type raw_omemstream::seekoff(off_type offs, seekdir dir)
{
   const pos_type from =
      dir == cur ? _pos : (dir == beg ? pos_type() : _endpos) ;
   const pos_type newpos = from + offs ;
   return
      newpos <= maxsize() || expand(newpos) ? (_pos = newpos) : pos_type(-1) ;
}
开发者ID:ymarkovitch,项目名称:libpcomn,代码行数:11,代码来源:pcomn_rawstream.cpp

示例10: seekpos

MemStreamBuf::pos_type MemStreamBuf::seekpos(pos_type pos, std::ios_base::openmode mode)
{
    if((mode&std::ios_base::out))
        return traits_type::eof();

    if(pos < 0 || pos > pos_type(memInfo.Length) || pos != pos_type(size_t(pos)))
        return traits_type::eof();
    memInfo.Pos = pos;

    setg(0, 0, 0);
    return pos;
}
开发者ID:AnsonX10,项目名称:bitfighter,代码行数:12,代码来源:istream.cpp

示例11: pos_type

typename parser_buf<charT, traits>::pos_type
parser_buf<charT, traits>::seekpos(pos_type sp, ::std::ios_base::openmode which)
{
   if(which & ::std::ios_base::out)
      return pos_type(off_type(-1));
   off_type size = static_cast<off_type>(this->egptr() - this->eback());
   charT* g = this->eback();
   if(off_type(sp) <= size)
   {
      this->setg(g, g + off_type(sp), g + size);
   }
   return pos_type(off_type(-1));
}
开发者ID:18037108618,项目名称:readium-sdk,代码行数:13,代码来源:cpp_regex_traits.hpp

示例12: setstate

/*******************************************************************************
 raw_imemstream
*******************************************************************************/
raw_ios::pos_type raw_imemstream::seekoff(off_type offs, seekdir dir)
{
   setstate(eofbit, false) ;
   const pos_type from =
      dir == cur ? _pos : (dir == beg ? pos_type() : (pos_type)_size) ;
   return _pos = midval<pos_type>(0, _size, from + offs) ;
}
开发者ID:ymarkovitch,项目名称:libpcomn,代码行数:10,代码来源:pcomn_rawstream.cpp

示例13: PHYSFS_tell

IFileStreambuf::pos_type
IFileStreambuf::seekoff(off_type off, std::ios_base::seekdir dir,
                        std::ios_base::openmode mode)
{
  off_type pos = off;
  PHYSFS_sint64 ptell = PHYSFS_tell(file);

  switch(dir) {
    case std::ios_base::beg:
      break;
    case std::ios_base::cur:
      if(off == 0)
        return static_cast<pos_type> (ptell) - static_cast<pos_type> (egptr() - gptr());
      pos += static_cast<off_type> (ptell) - static_cast<off_type> (egptr() - gptr());
      break;
    case std::ios_base::end:
      pos += static_cast<off_type> (PHYSFS_fileLength(file));
      break;
    default:
      assert(false);
      return pos_type(off_type(-1));
  }

  return seekpos(static_cast<pos_type> (pos), mode);
}
开发者ID:maxteufel,项目名称:supertux,代码行数:25,代码来源:ifile_streambuf.cpp

示例14: seekoff

 pos_type seekoff(off_type off, std::ios_base::seekdir dir,
                  std::ios_base::openmode which) override {
   // We only have a get area, so no put area (= out) operations.
   if ((which & std::ios_base::out) == std::ios_base::out)
     return pos_type(off_type(-1));
   return this->default_seekoff(off, dir, which);
 }
开发者ID:actor-framework,项目名称:actor-framework,代码行数:7,代码来源:streambuf.hpp

示例15: RCF_UNUSED_VARIABLE

    mem_streambuf::pos_type mem_streambuf::seekoff(
        mem_streambuf::off_type offset, 
        std::ios_base::seekdir dir,
        std::ios_base::openmode mode)
    {
        RCF_UNUSED_VARIABLE(mode);

        char * pBegin = mBuffer;
        char * pEnd = mBuffer + mBufferLen;
        
        char * pBase = NULL;
        switch(dir)
        {
            case std::ios::cur: pBase = gptr(); break;
            case std::ios::beg: pBase = pBegin; break;
            case std::ios::end: pBase = pEnd; break;
            default: assert(0); break; 
        }

        char * pNewPos = pBase + offset;
        if (pBegin <= pNewPos && pNewPos <= pEnd)
        {
            setg(pBegin, pNewPos, pEnd);
            return pNewPos - pBegin;
        }
        else
        {
            return pos_type(-1);
        }
    }
开发者ID:mkotsbak,项目名称:librcf-cpp,代码行数:30,代码来源:MemStream.cpp


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