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


C++ egptr函数代码示例

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


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

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

示例2: sync

std::streampos FileStreamBuf::seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode)
{
	if (_fd == -1 || !(getMode() & mode)) 
		return -1;

	if (getMode() & std::ios::out)
		sync();

	std::streamoff adj;
	if (mode & std::ios::in)
		adj = static_cast<std::streamoff>(egptr() - gptr());
	else
		adj = 0;

	resetBuffers();

	int whence = SEEK_SET;
	if (dir == std::ios::cur)
	{
		whence = SEEK_CUR;
		off -= adj;
	}
	else if (dir == std::ios::end)
	{
		whence = SEEK_END;
	}
	_pos = lseek(_fd, off, whence);
	return _pos;
}
开发者ID:119,项目名称:vdc,代码行数:29,代码来源:FileStream_POSIX.cpp

示例3: gptr

int filebuf::sync()
{
//    char* ptr = cur_ptr();
    if (pptr() > pbase())
	if (do_flush()) return EOF;
    if (gptr() != egptr()) {
	streampos delta = gptr() - egptr();
	if (in_backup())
	    delta -= eGptr() - Gbase();
	if (sys_seek(delta, ios::cur) == EOF)
	    return EOF;
    }
    // FIXME: Cleanup - can this be shared?
//    setg(base(), ptr, ptr);
    return 0;
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:16,代码来源:filebuf.C

示例4: LOG

    //read to buffer in place (apart from data already buffered)
    std::streamsize istreambuf::xsgetn(char *buffer, std::streamsize n) {
        LOG("bz::istreambuf::xsgetn (" << n << ")");

        //try to satisfy request from buffered input
        std::streamsize available = egptr() - gptr();
        int read = (available >= n)? n : available;
        if (read) {
            std::copy(gptr(), gptr() + read, buffer);
            gbump(read);
        }

        //inflate the rest directly into the user's buffer
        if (read < n) {
            if (end) {
                LOG("\tend of stream (EOF)");
                //signal the stream has reached it's end
                return eof;
            }

            z_strm->next_out = buffer + read;
            z_strm->avail_out = n - read;

            if (0 < z_strm->avail_in) {
                decompress();
            }
            while (!(end || 0 == z_strm->avail_out)) {
                read_decompress();
            }

            underflow();
        }
        return n;
    }
开发者ID:zahmed9,项目名称:sim-recon,代码行数:34,代码来源:bz.cpp

示例5: switch

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

    // new file position, relative to mOrigin
    std::streampos newPos = traits_type::eof();
    switch(whence)
    {
        case std::ios_base::beg:
            newPos = offset + mStart;
            break;
        case std::ios_base::cur:
            newPos = offset + mFile->tellg() - (egptr()-gptr());
            break;
        case std::ios_base::end:
            newPos = offset + mEnd;
            break;
        default:
            return traits_type::eof();
    }

    if(newPos < mStart || newPos > mEnd)
        return traits_type::eof();

    if(!mFile->seekg(newPos))
        return traits_type::eof();

    // Clear read pointers so underflow() gets called on the next read attempt.
    setg(0, 0, 0);

    return newPos - mStart;
}
开发者ID:afritz1,项目名称:OpenTESArena,代码行数:33,代码来源:archive.cpp

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

示例7: 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:ngphloc,项目名称:agmagic,代码行数:35,代码来源:_STRSTRE.CPP

示例8: underflow

        // input functions
        int_type underflow( 
        )
        {
            if (gptr() < egptr())
            {
                return static_cast<unsigned char>(*gptr());
            }

            int num_put_back = static_cast<int>(gptr() - eback());
            if (num_put_back > max_putback)
            {
                num_put_back = max_putback;
            }

            // copy the putback characters into the putback end of the in_buffer
            std::memmove(in_buffer+(max_putback-num_put_back), gptr()-num_put_back, num_put_back);


            if (read_echoing_select(fd, fd_printf))
                return EOF;
            int num = read(fd,in_buffer+max_putback, in_buffer_size-max_putback);
            if (num <= 0)
            {
                // an error occurred or the connection is over which is EOF
                return EOF;
            }

            // reset in_buffer pointers
            setg (in_buffer+(max_putback-num_put_back),
                in_buffer+max_putback,
                in_buffer+max_putback+num);

            return static_cast<unsigned char>(*gptr());
        }
开发者ID:Iflier,项目名称:dlib,代码行数:35,代码来源:subprocess_stream.cpp

示例9: seekoff

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

            // new file position, relative to mOrigin
            size_t newPos;
            switch (whence)
            {
                case std::ios_base::beg:
                    newPos = offset;
                    break;
                case std::ios_base::cur:
                    newPos = (mFile.tell() - mOrigin - (egptr() - gptr())) + offset;
                    break;
                case std::ios_base::end:
                    newPos = mSize + offset;
                    break;
                default:
                    return traits_type::eof();
            }

            if (newPos > mSize)
                return traits_type::eof();

            mFile.seek(mOrigin+newPos);

            // Clear read pointers so underflow() gets called on the next read attempt.
            setg(0, 0, 0);

            return newPos;
        }
开发者ID:A1-Triard,项目名称:openmw,代码行数:32,代码来源:constrainedfilestream.cpp

示例10: underflow

int func_parsebuf::underflow()
{
  retry:
    if (gptr() < egptr())
	return *gptr();
    if (gptr() != (char*)NewLine+1) {
	// Get buffer was line buffer.  Move to following '\n'.
	setg((char*)NewLine, (char*)NewLine, (char*)NewLine+1);
	return *gptr();
    }
    if (backed_up_to_newline)
	// Get buffer was '\n' preceding current line. Move to current line.
	backed_up_to_newline = 0;
    else {
	// Get buffer was '\n' following current line. Read new line.
	if (buf_start) free(buf_start);
	char *str = (*read_func)(arg);
	buf_start = str;
	if (str == NULL)
	    return EOF;
	// Initially, _line_length == -1, so pos_at_line_start becomes 0.
	pos_at_line_start += _line_length + 1;
	_line_length = strlen(str);
	buf_end = str + _line_length;
	__line_number++;
    }
    setg(buf_start, buf_start, buf_end);
    goto retry;
}
开发者ID:Kiddinglife,项目名称:4.4BSD-Lite,代码行数:29,代码来源:parsestream.C

示例11: underflow

int castorstreambuf::underflow()
{
    if ( gptr() && ( gptr()<egptr() ) )
        return * reinterpret_cast<unsigned char *>(gptr());
 
    if   ( !(mode & std::ios::in) || !opened) return EOF;

    // Josuttis' implementation of inbuf
    int n_putback = gptr() - eback();
    if ( n_putback > 4) n_putback = 4;
    memcpy( buffer + (4 - n_putback), gptr() - n_putback, n_putback);

#ifdef CASTOR_USE 
   signed int num = rfio_read( file_, buffer+4, bufferSize-4);
#else
   signed int num = -1;
#endif
      if (num <= 0) return EOF;

    // reset buffer pointers
    setg( buffer + (4 - n_putback),   // beginning of putback area
          buffer + 4,                 // read position
          buffer + 4 + num);          // end of buffer

    // return next character
    return * reinterpret_cast<unsigned char *>( gptr());    
}
开发者ID:cmstas,项目名称:TopAFB7TeV,代码行数:27,代码来源:castorstream.cpp

示例12: lzma_code

	std::streamsize buf_base::load()
	{
		lzma_.next_out = reinterpret_cast<uint8_t *>(&buf_[0]);
		if (lzma_.total_out > 0)
		{
			lzma_.avail_out = buf_.size();
			lzma_.total_out = 0;
			lzma_ret retval = lzma_code(&lzma_, action_);
			if (retval != LZMA_OK && retval != LZMA_STREAM_END) throw compress_error{"Compression failed with liblzma error " + util::t2s(retval)};
			if (lzma_.total_out > 0) goto loaded; // Valid use case?
		}
		lzma_.next_out = reinterpret_cast<uint8_t *>(&buf_[0]);
		while (lzma_.total_out == 0)
		{
			lzma_.total_in = 0;
			lzma_.next_in = reinterpret_cast<uint8_t *>(&inbuf_[0]);
			std::streamsize insize = fill();
			if (insize == 0) action_ = LZMA_FINISH;
			lzma_.avail_in = insize;
			lzma_.avail_out = buf_.size();
			lzma_ret retval = lzma_code(&lzma_, action_);
			//std::cout << "Got " << lzma_.total_in << " bytes, compressed to " << lzma_.total_out << "\n";
			if (retval == LZMA_STREAM_END) break;
			else if (retval != LZMA_OK) throw compress_error{"Compression failed with liblzma error " + util::t2s(retval)};
		}
	loaded:	char *start = &buf_[0], *end = start + lzma_.total_out;
		pos_ += egptr() - eback();
		setg(start, start, end);
		return lzma_.total_out;
	}
开发者ID:showermat,项目名称:zsr-utils,代码行数:30,代码来源:compress.cpp

示例13: _ASSERT

CT_INT_TYPE CConn_Streambuf::underflow(void)
{
    _ASSERT(gptr() >= egptr());

    if (!m_Conn)
        return CT_EOF;

    // flush output buffer, if tied up to it
    if (m_Tie  &&  x_sync() != 0)
        return CT_EOF;

#ifdef NCBI_COMPILER_MIPSPRO
    if (m_MIPSPRO_ReadsomeGptrSetLevel  &&  m_MIPSPRO_ReadsomeGptr != gptr())
        return CT_EOF;
    m_MIPSPRO_ReadsomeGptr = (CT_CHAR_TYPE*)(-1L);
#endif /*NCBI_COMPILER_MIPSPRO*/

    // read from connection
    size_t n_read;
    m_Status = CONN_Read(m_Conn, m_ReadBuf, m_BufSize,
                         &n_read, eIO_ReadPlain);
    _ASSERT(n_read <= m_BufSize);
    if (!n_read) {
        _ASSERT(m_Status != eIO_Success);
        if (m_Status != eIO_Closed)
            ERR_POST_X(8, x_Message("underflow():  CONN_Read() failed"));
        return CT_EOF;
    }

    // update input buffer with the data just read
    x_GPos += (CT_OFF_TYPE) n_read;
    setg(m_ReadBuf, m_ReadBuf, m_ReadBuf + n_read);

    return CT_TO_INT_TYPE(*m_ReadBuf);
}
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:35,代码来源:ncbi_conn_streambuf.cpp

示例14: eback

void IOBuffer::beginRead()
{
    if(_ioDevice == 0 || _ioDevice->isReading())
        return;

    if( ! _ibuffer)
        _ibuffer = new char[_ibufferSize];

    std::size_t putback = _pbmax;
    std::size_t leftover = 0;

    // Keep chars for putback
    if( gptr() )
    {
        putback    = std::min<std::size_t>(gptr() - eback(), _pbmax);
        char* to   = _ibuffer + _pbmax - putback;
        char* from = gptr() - putback;

        leftover = egptr() - gptr();
        std::memmove(to, from, putback + leftover);
    }

    std::size_t used = _pbmax + leftover;

    if(_ibufferSize == used)
        throw std::logic_error(PT_ERROR_MSG("IOBuffer is full"));

    _ioDevice->beginRead(_ibuffer + used, _ibufferSize - used);

    setg(_ibuffer + (_pbmax - putback), // start of get area
         _ibuffer + used,               // gptr position
         _ibuffer + used);              // end of get area
}
开发者ID:3Nigma,项目名称:frayon,代码行数:33,代码来源:IOBuffer.cpp

示例15: egptr

void BinaryStreamBuffer::reset()
{
	size_t readEndPos = egptr() - eback();

	setg(buffer(), buffer(), buffer() + readEndPos);
	setp(buffer(), end());
}
开发者ID:bsumirak,项目名称:ugcore,代码行数:7,代码来源:binary_stream.cpp


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