• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ eback函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: underflow

			int_type underflow()
			{
				if ( gptr() < egptr() )
					return static_cast<int_type>(*uptr());
					
				assert ( gptr() == egptr() );
				
				char * midptr = buffer.begin() + pushbackspace;
				uint64_t const copyavail = 
					std::min(
						// previously read
						static_cast<uint64_t>(gptr()-eback()),
						// space we have to copy into
						static_cast<uint64_t>(midptr-buffer.begin())
					);
				::std::memmove(midptr-copyavail,gptr()-copyavail,copyavail);
				
				size_t n = 0;
				bool done = false;
				
				while ( ! done )
				{
					BgzfInflateInfo const info = stream.readAndInfo(midptr, buffer.end()-midptr);						
					n = info.uncompressed;
					
					// non eof block
					if ( n )
					{
						streamreadpos += n;
						done = true;			
					}
					else
					{
						// eof block at end of stream
						if ( info.streameof )
						{
							done = true;
						}
						// intermediate empty block, skip it
						else
						{
						
						}
					}
				}

				setg(midptr-copyavail, midptr, midptr+n);

				if (!n)
					return traits_type::eof();
									
				return static_cast<int_type>(*uptr());
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:53,代码来源:BgzfStreamWrapper.hpp


示例2: egptr

int general_parsebuf::seek_in_line(int i)
{
    if (__line_number == 0)
	(void)general_parsebuf::underflow();
    if (__line_number > 1)
	i++; // Add 1 for '\n' from end of previous line.
    if (i < 0) i = 0;
    int len = egptr() - eback();
    if (i > len) i = len;
    setg(base(), base() + i, egptr());
    return i;
}
开发者ID:Kiddinglife,项目名称:4.4BSD-Lite,代码行数:12,代码来源:parsestream.C


示例3: egptr

strstreambuf::pos_type
strstreambuf::seekpos(pos_type pos, ios_base::openmode which)
{
  if ((which & (ios_base::in | ios_base::out)) == 0
      || pos < 0 || (epptr() == 0? egptr(): epptr()) - gptr() < pos)
    return pos_type(-1);
    
  if (which & ios_base::in)
    if (gptr() == 0)
      return pos_type(-1);
    else
      setg(eback(), eback() + pos, egptr());
    
  if (which & ios_base::in)
    if (pptr() == 0)
      return pos_type(-1);
    else
      setp(eback() + pos, epptr());

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


示例4: seekpos

			/**
			 * seek to absolute position
			 **/
			::std::streampos seekpos(::std::streampos sp, ::std::ios_base::openmode which = ::std::ios_base::in | ::std::ios_base::out)
			{
				if ( which & ::std::ios_base::in )
				{
					// current position
					int64_t const cur = symsread-(egptr()-gptr());
					// current start of buffer (relative)
					int64_t const curlow = cur - static_cast<int64_t>(gptr()-eback());
					// current end of buffer (relative)
					int64_t const curhigh = cur + static_cast<int64_t>(egptr()-gptr());
					
					// call relative seek, if target is in range
					if ( sp >= curlow && sp <= curhigh )
						return seekoff(static_cast<int64_t>(sp) - cur, ::std::ios_base::cur, which);

					// target is out of range, we really need to seek
					uint64_t tsymsread = (sp / blocksize)*blocksize;

					// set symsread					
					symsread = tsymsread;

					// reinit
					init(true);

					// read next block
					underflow();
					
					// skip bytes in block to get to final position
					setg(
						eback(),
						gptr() + (static_cast<int64_t>(sp)-static_cast<int64_t>(tsymsread)), 
						egptr()
					);
				
					return sp;
				}
				
				return -1;
			}
开发者ID:allenday,项目名称:libmaus,代码行数:42,代码来源:PosixFdInputStreamBuffer.hpp


示例5:

_CRTIMP2 int strstreambuf::pbackfail(int ch)
	{	// try to putback a character
	if (gptr() == 0 || gptr() <= eback()
		|| ch != EOF
			&& (unsigned char)ch != (unsigned char)gptr()[-1]
			&& _Strmode & _Constant)
		return (EOF);
	else
		{	// safe to back up
		gbump(-1);
		return (ch == EOF ? 0 : (unsigned char)(*gptr() = (char)ch));
		}
	}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:13,代码来源:STRSTREA.CPP


示例6: if

strstreambuf::int_type
strstreambuf::underflow()
{
  if (gptr() != egptr())
    return static_cast<unsigned char>(*gptr());
  else if (pptr() != 0 && egptr() != pptr())
    {
      setg(eback(), gptr(), pptr());
      return static_cast<unsigned char>(*gptr());
    }
    
  return char_traits<char>::eof();
}
开发者ID:dietmarkuehl,项目名称:kuhllib,代码行数:13,代码来源:cstrstrm.cpp


示例7: gptr

		void FtpFileStream::flushPutback() {
			if (mPutbackBuffer.size() == 0) {
				return;
			}

			auto g = gptr();
			uint32 offset = g - eback();

			mCurrentBuffer.insert(mCurrentBuffer.end(), mPutbackBuffer.begin(), mPutbackBuffer.end());
			mPutbackBuffer.clear();

			setg(&mCurrentBuffer[0], &mCurrentBuffer[offset], &mCurrentBuffer[mCurrentBuffer.size() - 1]);
		}
开发者ID:Craftrect,项目名称:rectangu.land,代码行数:13,代码来源:FtpFileStream.cpp


示例8: gptr

MessageBuffer::int_type MessageBuffer::underflow()
{ 
    if( this->gptr() < this->pptr() )
    {
        std::size_t gsize = gptr() - eback();
        this->setg(_buffer, _buffer + gsize, this->pptr());
    }
    
    if( this->gptr() < this->egptr() )
        return traits_type::to_int_type(*(this->gptr()));

    return traits_type::eof();
}
开发者ID:3Nigma,项目名称:frayon,代码行数:13,代码来源:Message.cpp


示例9: underflow

 // base showmanyc() returns 0 to indicate we don't know how many characters are available
 virtual int_type underflow() override { // add some characters to the buffer if empty
     if (gptr()<egptr()) return traits_type::to_int_type(*gptr());
     // copy up to putback_size previously read characters into putback buffer
     int putback_num = 0;
     if (1) {
         putback_num = min(int(gptr()-eback()), possible_cast<int>(putback_size));
         ASSERTX(putback_num>=0 && putback_num<=putback_size);
         std::memmove(_buffer0-putback_num, gptr()-putback_num, putback_num); // ranges may overlap
     }
     size_t num = fread(_buffer0, sizeof(char), buffer_size, _file);
     if (!num) return EOF;   // on failure we retain gptr()==egptr()
     setg(_buffer0-putback_num, _buffer0, _buffer0+num);
     return traits_type::to_int_type(*gptr());
 }
开发者ID:5432935,项目名称:Mesh-processing-library,代码行数:15,代码来源:FileIO.cpp


示例10: seekoff

 std::streampos seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode) {
     char *p;
     switch (dir) {
     case std::ios_base::beg:
         p = eback() + off;
         break;
     case std::ios_base::cur:
         p = gptr() + off;
         break;
     case std::ios_base::end:
         p = egptr() - off;
         break;
     default:
         p = 0;
         break;
     }
     if (p >= eback() && p <= egptr()) {
         setg(eback(), p, egptr());
         return std::streampos(p - eback());
     } else {
         return -1;
     }
 }
开发者ID:atlasicus,项目名称:intercept,代码行数:23,代码来源:membuf.hpp


示例11: setg

exec_stream_buffer_t::int_type exec_stream_buffer_t::underflow()
{
    if( gptr()==egptr() ) {
        std::size_t read_size=STREAM_BUFFER_SIZE;
        bool no_more;
        m_thread_buffer.get( m_kind, m_stream_buffer, read_size, no_more );
        if( no_more || read_size==0 ) { // there is no way for underflow to return something other than eof when 0 bytes are read
            return traits_type::eof();
        }else {
            setg( m_stream_buffer, m_stream_buffer, m_stream_buffer+read_size );
        }
    }
    return traits_type::to_int_type( *eback() );
}
开发者ID:EarthDollar,项目名称:farmer,代码行数:14,代码来源:exec-stream.cpp


示例12: epptr

void strstreambuf::freeze(bool freezeit)
	{	// freeze or unfreeze writing
	if (freezeit && !(_Strmode & _Frozen))
		{	// disable writing
		_Strmode |= _Frozen;
		_Pendsave = epptr();
		setp(pbase(), pptr(), eback());
		}
	else if (!freezeit && _Strmode & _Frozen)
		{	// re-enable writing
		_Strmode &= ~_Frozen;
		setp(pbase(), pptr(), _Pendsave);
		}
	}
开发者ID:JackDoan,项目名称:locolab,代码行数:14,代码来源:strstrea.cpp


示例13: pptr

// According to the C++ standard the effects of setbuf are implementation
// defined, except that setbuf(0, 0) has no effect.  In this implementation,
// setbuf(<anything>, __length), for __length > 0, calls reserve(__length) on the underlying
// string.
streambuf* stringbuf::setbuf(char_type*, streamsize __length) 
{
    if (__length > 0) 
    {
        bool __do_get_area = false;
        bool __do_put_area = false;
        ptrdiff_t __offg = 0;
        ptrdiff_t __offp = 0;

        if (pbase() == __M_str.begin()) 
        {
            __do_put_area = true;
            __offp = pptr() - pbase();
        }

        if (eback() == __M_str.begin()) 
        {
            __do_get_area = true;
            __offg = gptr() - eback();
        }

        __M_str.reserve(static_cast<size_t>(__length));

        char_type* __data_ptr = __M_str.begin();
        if (__do_get_area) 
        {
            setg(__data_ptr, __data_ptr + __offg, __M_str.end());
        }
        if (__do_put_area) 
        {
            setp(__data_ptr, __M_str.end());
            pbump(static_cast<int>(__offp));
        }
    }

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


示例14: if

int TCPStream::underflow()
{
    ssize_t rlen = 1;
    unsigned char ch;

    if(bufsize == 1) {
        if(Socket::state == STREAM)
            rlen = ::read((int)so, (char *)&ch, 1);
        else if(timeout && !Socket::isPending(pendingInput, timeout)) {
            iostream::clear(ios::failbit | rdstate());
            error(errTimeout,(char *)"Socket read timed out",socket_errno);
            return EOF;
        }
        else
            rlen = readData(&ch, 1);
        if(rlen < 1) {
            if(rlen < 0) {
                iostream::clear(ios::failbit | rdstate());
                error(errInput,(char *)"Could not read from socket",socket_errno);
            }
            return EOF;
        }
        return ch;
    }

    if(!gptr())
        return EOF;

    if(gptr() < egptr())
        return (unsigned char)*gptr();

    rlen = (ssize_t)((gbuf + bufsize) - eback());
    if(Socket::state == STREAM)
        rlen = ::read((int)so, (char *)eback(), _IOLEN64 rlen);
    else if(timeout && !Socket::isPending(pendingInput, timeout)) {
        iostream::clear(ios::failbit | rdstate());
        error(errTimeout,(char *)"Socket read timed out",socket_errno);
        return EOF;
    }
    else
        rlen = readData(eback(), rlen);
    if(rlen < 1) {
//      clear(ios::failbit | rdstate());
        if(rlen < 0)
                        error(errNotConnected,(char *)"Connection error",socket_errno);
        else {
            error(errInput,(char *)"Could not read from socket",socket_errno);
            iostream::clear(ios::failbit | rdstate());
        }
        return EOF;
    }
    error(errSuccess);

    setg(eback(), eback(), eback() + rlen);
    return (unsigned char) *gptr();
}
开发者ID:tmatth,项目名称:ucommon,代码行数:56,代码来源:tcp.cpp


示例15: setg

//unget char, some special cases
int StringIteratorStreamBuf::pbackfail ( int c )
{
  if(eback() != gptr())
  {
    setg(eback(), gptr()-1, egptr());
    if(c != EOF)
      *gptr() = (char)c;
    return 1;
  }

  //else have to rewind to previous buffer
  if(last_buffer != current_buffer)
    return EOF;
  if(buffer[1-last_buffer].length() == 0)
    return EOF;
  current_buffer = 1 - current_buffer;

  begin_offset -= buffer[current_buffer].length();
  char *buffstr = (char*)buffer[current_buffer].c_str();
  setg(buffstr, buffstr+buffer[current_buffer].length()-1, buffstr+buffer[current_buffer].length());
  if(c != EOF)
    *gptr() = (char)c;
  return 1;
}
开发者ID:28msec,项目名称:zorba-csv-module,代码行数:25,代码来源:stringiterator_streambuf.cpp


示例16: seekoff

			::std::streampos seekoff(::std::streamoff off, ::std::ios_base::seekdir way, ::std::ios_base::openmode which = ::std::ios_base::in | ::std::ios_base::out)
			{
				if ( which & ::std::ios_base::in )
				{
					int64_t abstarget = 0;
					int64_t const cur = symsread - (egptr()-gptr());
					
					if ( way == ::std::ios_base::cur )
						abstarget = cur + off;
					else if ( way == ::std::ios_base::beg )
						abstarget = off;
					else // if ( way == ::std::ios_base::end )
						abstarget = n + (addterm?1:0) + off;
						
					if ( abstarget - cur == 0 )
					{
						return abstarget;
					}
					else if ( (abstarget - cur) > 0 && (abstarget - cur) <= (egptr()-gptr()) )
					{
						setg(eback(),gptr()+(abstarget-cur),egptr());
						return abstarget;
					}
					else if ( (abstarget - cur) < 0 && (cur-abstarget) <= (gptr()-eback()) )
					{
						setg(eback(),gptr()-(cur-abstarget),egptr());
						return abstarget;
					}
					else
					{
						return seekpos(abstarget,which);
					}
				}
				
				return -1;
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:36,代码来源:PacDecoderBuffer.hpp


示例17: pbump

_STLP_EXP_DECLSPEC strstreambuf::int_type strstreambuf::overflow(int_type c) {
  if (c == traits_type::eof())
    return traits_type::not_eof(c);
#ifdef __SYMBIAN32__
  if (pptr() != 0 && pptr() < epptr())
  {
    *pptr() = c;
    pbump(1);
    return c;
  }
  if (!_M_dynamic || _M_constant || _M_frozen)
  	return (EOF);	// can't extend
#endif
  // Try to expand the buffer.
  if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant) {
    ptrdiff_t old_size = epptr() - pbase();
    ptrdiff_t new_size = (max)(2 * old_size, ptrdiff_t(1));

    char* buf = _M_alloc(new_size);
    if (buf) {
      memcpy(buf, pbase(), old_size);

      char* old_buffer = pbase();
      bool reposition_get = false;
      ptrdiff_t old_get_offset;
      if (gptr() != 0) {
        reposition_get = true;
        old_get_offset = gptr() - eback();
      }

      setp(buf, buf + new_size);
      pbump((int)old_size);

      if (reposition_get) 
        setg(buf, buf + old_get_offset, buf + (max)(old_get_offset, old_size));

      _M_free(old_buffer);
    }
  }

  if (pptr() != epptr()) {
    *pptr() = c;
    pbump(1);
    return c;
  }
  else
    return traits_type::eof();
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:48,代码来源:strstream.cpp


示例18: T

   mlpipebuf::int_type
   mlpipebuf::pbackfail(int_type c)
   {
#ifdef DEBUG
      char *fname = "mlpipebuf::pbackfail(c)";
      Tracebuf T(fname);
#endif

      if(gptr() != eback()) {
         gbump(-1);
         if(c != ((int)EOF))
            *(gptr()) = char(c);
         return c;
      } else
         return (int(EOF));
   }
开发者ID:bryanhinton,项目名称:mls,代码行数:16,代码来源:mlpipebuf.cpp


示例19: pos_type

std::streambuf::pos_type
DataIStreamBuf::seekpos(pos_type sp, std::ios_base::openmode which)
{
	pos_type ret = pos_type(off_type(-1));

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

	if (sp <= end - begin)
	{
		setg(begin, begin + sp, end);
		ret = sp;
	}

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


示例20: __max

int strstreambuf::doallocate()
{
    char * bptr;
    int size;
    size = __max(x_bufmin,blen() + __max(x_bufmin,1));
    long offset = 0;

    if (x_alloc)
        {
        bptr = (char*)(*x_alloc)(size);
        }
    else
        {
        bptr = _new_crt char[size];
        }
    if (!bptr)
        return EOF;

    if (blen())
        {
        memcpy(bptr, base(), blen());
        offset = bptr - base(); // amount to adjust pointers by
        }
    if (x_free)
        {
        (*x_free)(base());
        }
    else
        {
        delete base();
        }
    setb(bptr,bptr+size,0);     // we handle deallocation

    // adjust get/put pointers too, if necessary
    if (offset)
        if (egptr())
            {
            setg(eback()+offset,gptr()+offset,egptr()+offset);
            }
        if (epptr())
            {
            size = pptr() - pbase();
            setp(pbase()+offset,epptr()+offset);
            pbump(size);
        }
    return(1);
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:47,代码来源:_STRSTRE.CPP



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ebcdic2ascii函数代码示例发布时间:2022-05-30
下一篇:
C++ eat_whitespace函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap