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


C++ epptr函数代码示例

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


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

示例1: 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

示例2: epptr

strstreambuf::int_type
strstreambuf::overflow (int_type c)
{
  if (c == char_traits<char>::eof())
    return ' ';

  if (pptr() == epptr())
    {
      if (_CS_m_dynamic == 0 || _CS_m_frozen == 1)
	return char_traits<char>::eof();

      streamsize n = epptr() - eback();
      char* tmp = _CS_m_alloc == 0
	? new char[n + _CS_m_chunk_size]
	: static_cast<char*>(_CS_m_alloc(n + _CS_m_chunk_size));
      char_traits<char>::copy(tmp, eback(), n);
      char* del = eback();
      setg(tmp, tmp + (gptr() - del), tmp + (egptr() - del));
      setp(tmp + (pptr() - del), tmp + n + _CS_m_chunk_size);
      if (_CS_m_allocated != 0)
	_CS_m_free == 0? delete[] del: _CS_m_free(del);

      _CS_m_allocated = 1;
    }

  *pptr() = static_cast<unsigned char>(c);
  pbump(1);
  return c;
}
开发者ID:dietmarkuehl,项目名称:kuhllib,代码行数:29,代码来源:cstrstrm.cpp

示例3: __p

strstreambuf::pos_type
strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which)
{
    off_type __p(-1);
    bool pos_in = (__which & ios::in) != 0;
    bool pos_out = (__which & ios::out) != 0;
    if (pos_in || pos_out)
    {
        if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr)))
        {
            off_type newoff = __sp;
            char* seekhigh = epptr() ? epptr() : egptr();
            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_type temp = epptr() - newpos;
                    setp(min(pbase(), newpos), epptr());
                    pbump(static_cast<int>((epptr() - pbase()) - temp));
                }
                __p = newoff;
            }
        }
    }
    return pos_type(__p);
}
开发者ID:crystax,项目名称:android-toolchain-libcxx-3-6,代码行数:30,代码来源:strstream.cpp

示例4: allocate

int strstreambuf::overflow(int c)
{
/*
- if no room and not dynamic, give error
- if no room and dynamic, allocate (1 more or min) and store
- if and when the buffer has room, store c if not EOF
*/
    int temp;
    if (pptr() >= epptr())
        {
        if (!x_dynamic)
            return EOF;

        if (strstreambuf::doallocate()==EOF)
            return EOF;

        if (!epptr())   // init if first time through
            {
            setp(base() + (egptr() - eback()),ebuf());
            }
        else
            {
            temp = pptr()-pbase();
            setp(pbase(),ebuf());
            pbump(temp);
            }
        }

    if (c!=EOF)
        {
        *pptr() = (char)c;
        pbump(1);
        }
    return(1);
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:35,代码来源:_STRSTRE.CPP

示例5: commit

 /**
  * Appends @c n characters from the start of the output sequence to the input
  * sequence. The beginning of the output sequence is advanced by @c n
  * characters.
  *
  * Requires a preceding call <tt>prepare(x)</tt> where <tt>x >= n</tt>, and
  * no intervening operations that modify the input or output sequence.
  *
  * @throws std::length_error If @c n is greater than the size of the output
  * sequence.
  */
 void commit(std::size_t n)
 {
   if (pptr() + n > epptr())
     n = epptr() - pptr();
   pbump(static_cast<int>(n));
   setg(eback(), gptr(), pptr());
 }
开发者ID:13609594236,项目名称:ph-open,代码行数:18,代码来源:basic_streambuf.hpp

示例6: return

int strstreambuf::overflow(int meta)
	{	// try to extend write area
	if (meta == EOF)
		return (0);	// nothing to write
	else if (pptr() != 0 && pptr() < epptr())
		return ((unsigned char)(*_Pninc() = meta));	// room in buffer
	else if (!(_Strmode & _Dynamic)
		|| _Strmode & (_Constant | _Frozen))
		return (EOF);	// can't extend
	else
		{	// okay to extend
		int oldsize = gptr() == 0 ? 0 : epptr() - eback();
		int newsize = oldsize;
		int inc = newsize / 2 < _Minsize
			? _Minsize : newsize / 2;	// grow by 50 per cent if possible
		_Minsize = _MINSIZE;	// back to default for future growth
		char *ptr = 0;

		while (0 < inc && INT_MAX - inc < newsize)
			inc /= 2;	// reduce growth increment if too big
		if (0 < inc)
			{	// room to grow, increase size
			newsize += inc;
			ptr = _Palloc != 0 ? (char *)(*_Palloc)(newsize)
				: _NEW_CRT char[newsize];
			}
		if (ptr == 0)
			return (EOF);	// couldn't grow, return failure

		if (0 < oldsize)
			memcpy(ptr, eback(), oldsize);	// copy existing buffer
		if (!(_Strmode & _Allocated))
			;	// no buffer to free
		else if (_Pfree != 0)
			(*_Pfree)(eback());	// free with function call
		else
			_DELETE_CRT_VEC(eback());	// free by deleting array

		_Strmode |= _Allocated;
		if (oldsize == 0)
			{	// set up new buffer
			_Seekhigh = ptr;
			setp(ptr, ptr + newsize);
			setg(ptr, ptr, ptr);
			}
		else
			{	// revise old pointers
			_Seekhigh = _Seekhigh - eback() + ptr;
			setp(pbase() - eback() + ptr, pptr() - eback() + ptr,
				ptr + newsize);
			setg(ptr, gptr() - eback() + ptr, pptr() + 1);
			}

		return ((unsigned char)(*_Pninc() = meta));
		}
开发者ID:JackDoan,项目名称:locolab,代码行数:55,代码来源:strstrea.cpp

示例7: switch

std::ios::pos_type
Charbuf::seekoff(std::ios::off_type off, std::ios_base::seekdir dir,
    std::ios_base::openmode which)
{
    std::ios::pos_type pos;
    char *cpos = nullptr;
    if (which & std::ios_base::in)
    {
        switch (dir)
        {
        case std::ios::beg:
            cpos = eback() + off - m_bufOffset;
            break;
        case std::ios::cur:
            cpos = gptr() + off;
            break;
        case std::ios::end:
            cpos = egptr() - off;
            break;
        default:
            break;  // Should never happen.
        }
        if (cpos < eback() || cpos > egptr())
            return -1;
        setg(eback(), cpos, egptr());
        pos = cpos - eback();
    }
    if (which & std::ios_base::out)
    {
        switch (dir)
        {
        case std::ios::beg:
            cpos = m_buf + off - m_bufOffset;
            break;
        case std::ios::cur:
            cpos = pptr() + off;
            break;
        case std::ios::end:
            cpos = egptr() - off;
            break;
        default:
            break;  // Should never happen.
        }
        if (cpos < m_buf || cpos > epptr())
            return -1;
        setp(cpos, epptr());
        pos = cpos - m_buf;
    }
    return pos;
}
开发者ID:rskelly,项目名称:PDAL,代码行数:50,代码来源:Charbuf.cpp

示例8: return

  streampos strstreambuf::seekoff( streamoff offset,
                                   ios::seekdir direction,
                                   int mode ) {

    streampos  newpos;
    char      *endget;
    char      *pos;

    mode &= (ios::in | ios::out);
    if( (mode == 0) ||
      ( (direction==ios::cur) && (mode == (ios::in | ios::out)) ) ) {
        return( EOF );
    }

    __lock_it( __b_lock );

    // Move the get pointer:
    if( mode & ios::in ) {
        endget = pptr();
        if( endget == NULL || endget < egptr() ) {
            endget = egptr();
        }
        newpos = __get_position( offset, direction, eback(), gptr(), egptr(), endget );
        if( newpos != EOF ) {

            // If the seek went beyond the end of the get area, extend the
            // get area to include the characters in the put area.
            pos = eback() + newpos;
            if( pos > egptr() ) {
                setg( eback(), pos, epptr() );
            } else {
                setg( eback(), pos, egptr() );
            }
        }
    }

    if( mode & ios::out ) {
        // Move the put pointer:
        newpos = __get_position( offset, direction, pbase(), pptr(), epptr(), epptr() );
        if( newpos != EOF ) {
            setp( pbase(), epptr() );
            pbump( newpos );
            if( newpos > __minbuf_size ) {
                __minbuf_size = (int)newpos;
            }
        }
    }
    return( newpos );
  }
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:49,代码来源:ssfseeko.cpp

示例9: 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

示例10: bits

void sha1buf::update_sha1(uint32_t &H0, uint32_t &H1, uint32_t &H2, uint32_t &H3, uint32_t &H4)
{
	uint64_t bits(len);
	uint32_t *words = (uint32_t *) buf;
	char *ptr = pptr(), *end = epptr();

	bits += (ptr - pbase()) * 8;

	std::ptrdiff_t pad = end + 1 - ptr;
	if (pad) {
		*ptr = '\x80';

		if (pad >= 9)
			end -= 8;

		while (ptr++ < end)
			*ptr = '\0';

		if (pad < 9) {
			_update_sha1(H0, H1, H2, H3, H4, words);
			words = new uint32_t[16]();
		}

		words[15] = _BE(bits);
		words[14] = _BE(((uint32_t *) &bits)[1]);
	}

	_update_sha1(H0, H1, H2, H3, H4, words);
}
开发者ID:tynn,项目名称:H4KvT,代码行数:29,代码来源:sha1buf.cpp

示例11: overflow

stringbuf::int_type stringbuf::overflow(int_type __char)
{
    if (__char == EOF) return 0;     // __char is EOF, so we don't have to do anything

    if (__M_mode & ios_base::out) 
    {
        if (pptr() < epptr())    // just put back in any case
        { 
            __M_str.push_back(static_cast<char_type>(__char));
            pbump(1);
        }
        else if (__M_mode & ios_base::in) 
        {
            ptrdiff_t __offset = gptr() - eback();
            __M_str.push_back(static_cast<char_type>(__char));
            char_type* __data_ptr = __M_str.begin();
            setg(__data_ptr, __data_ptr + __offset, __M_str.end());
            setp(__data_ptr, __M_str.end());
            pbump(static_cast<int>(__M_str.size()));
        }
        else 
        {
            __M_str.push_back(static_cast<char_type>(__char));
            setp(__M_str.begin(), __M_str.end());
            pbump(static_cast<int>(__M_str.size()));
        }
        return __char;
    }
    return EOF;     // Overflow always fails if it's read-only
}
开发者ID:HemingChin,项目名称:POD_STL,代码行数:30,代码来源:sstream.cpp

示例12: setg

int _ALControlStream::overflow( int ch )
{
    if ( !base() ) {
        if ( allocate() == EOF )
            return EOF;
        setg( 0, 0, 0 );
    } else {
        if ( out_waiting() ) {
            if ( sync() == EOF )
                return EOF;
        }
    }
    int bl = blen();
    setp( base(), base() + bl - 2 );
    if ( pptr() < epptr() ) {
        *pptr() = (char) ch;
        pbump( 1 );
    } else {
        *pptr() = (char ) ch;
        pbump( 1 );
        *pptr() = '\0';
        pbump( 1 );
        SendMessage( hWindow,
                     EM_REPLACESEL,
                     0,
                     (LPARAM) ( (LPSTR) pbase() ) );
    }
    return 0;
}
开发者ID:softwarepublico,项目名称:lightbase,代码行数:29,代码来源:ALSTREAM.CPP

示例13: pptr

_CRTIMP2 streampos strstreambuf::seekpos(streampos sp,
		ios::openmode which)
	{	// seek to memorized position
	streamoff off = (streamoff)sp;
	if (pptr() != 0 && _Seekhigh < pptr())
		_Seekhigh = pptr();
	if (off == _BADOFF)
		;
	else if (which & ios::in && gptr() != 0)
		{	// set input (and maybe output) pointer
		if (0 <= off && off <= _Seekhigh - eback())
			{	// set valid offset
			gbump(eback() - gptr() + off);
			if (which & ios::out && pptr() != 0)
				setp(pbase(), gptr(), epptr());
			}
		else
			off = _BADOFF;
		}
	else if (which & ios::out && pptr() != 0)
		{	// set output pointer
		if (0 <= off && off <= _Seekhigh - eback())
			pbump(eback() - pptr() + off);
		else
			off = _BADOFF;
		}
	else	// nothing to set
		off = _BADOFF;
	return (streampos(off));
	}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:30,代码来源:STRSTREA.CPP

示例14: epptr

std::streamsize LogBuf::xsputn(const Char8 *buffer, std::streamsize size)
{
    if(size > 0)
    {
        if(!pptr())
            return 0;

        std::streamsize s = epptr() - pptr();

        if(s >= size)
        {
            // Put it into the write buffer
            memcpy(pptr(), buffer, size);
            pbump(size);
        }
        else
        {
            // Flush write buffer
            s = pptr() - pbase();

            if (s > 0)
            {
                write(pbase(), s);
                pbump(-s);
            }

            // Write data
            write(buffer, size);
        }
    }

    return size;
}
开发者ID:vossg,项目名称:OpenSGDevMaster,代码行数:33,代码来源:OSGLog.cpp

示例15: finish_request

int rpcbuf::overflow(int c) {
    if (!_opened || allocate() == EOF) {
	return EOF;
    }

    if (c == EOF) {
	finish_request();
    }

    if (rptr() == pbase() && pptr() >= epptr() && !expand_p()) {
	error("rpcbuf::overflow: out of memory");
	return EOF;
    }

    int nwrite = (rptr() >= pbase()) ? rptr() - pbase() : out_waiting();
    int count = 0;
    while (count < nwrite) {
	int nsent = write(_fd, pbase() + count, nwrite - count);
	if (nsent < 0) {
	    sys_error("rpcbuf::overflow: write");
	    return EOF;
	}
	count += nsent;
    }
    if (rptr() > pbase()) {
	Memory::copy(rptr(), pbase(), pptr() - rptr());
	rbump(-nwrite);
    }
    pbump(-nwrite);

    if (c != EOF) {
	sputc(c);
    }
    return zapeof(c);
}
开发者ID:neurodebian,项目名称:iv-hines,代码行数:35,代码来源:rpcbuf.cpp


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