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

C++ setg函数代码示例

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

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



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

示例1: return

_CRTIMP2 int strstreambuf::underflow()
	{	// read only if read position available
	if (gptr() == 0)
		return (EOF);
	else if (gptr() < egptr())
		return ((unsigned char)*gptr());
	else if (pptr() == 0
		|| pptr() <= gptr() && _Seekhigh <= gptr())
		return (EOF);
	else
		{	// update _Seekhigh and expand read region
		if (_Seekhigh < pptr())
			_Seekhigh = pptr();
		setg(eback(), gptr(), _Seekhigh);
		return ((unsigned char)*gptr());
		}
	}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:17,代码来源:STRSTREA.CPP


示例2: egptr

int string_parsebuf::underflow()
{
    register char* ptr = egptr(); // Point to end of current_line
    do {
	int i = right() - ptr;
	if (i <= 0)
	    return EOF;
	ptr++; i--; // Skip '\n'.
	char *line_start = ptr;
	while (ptr < right() && *ptr == '\n') ptr++;
	setg(line_start-1, line_start, ptr + (ptr < right()));
	pos_at_line_start = line_start - left();
	_line_length = ptr - line_start;
	__line_number++;
    } while (gptr() == ptr);
    return *gptr();
}
开发者ID:Kiddinglife,项目名称:4.4BSD-Lite,代码行数:17,代码来源:parsestream.C


示例3: setg

	std::streampos streambuf::seekoff(	std::streamoff off,
						std::ios_base::seekdir seekdir,
						std::ios_base::openmode /*m*/)
	{
		if(sync())
			return -1;
		if(!buffer_in_.empty()) {
			setg(0,0,0);
		}
		if(seekdir == std::ios_base::cur)
			return device().seek(off,io_device::cur);
		if(seekdir == std::ios_base::beg)
			return device().seek(off,io_device::set);
		if(seekdir == std::ios_base::end)
			return device().seek(off,io_device::end);
		return -1;
	}
开发者ID:kienhdpr,项目名称:Talon,代码行数:17,代码来源:streambuf.cpp


示例4: underflow

			int_type underflow()
			{
				// if there is still data, then return it
				if ( gptr() < egptr() )
					return static_cast<int_type>(*(reinterpret_cast<uint8_t const *>(gptr())));

				assert ( gptr() == egptr() );

				// number of bytes for putback buffer
				uint64_t const putbackcopy = std::min(
					static_cast<uint64_t>(gptr() - eback()),
					putbackspace
				);
				
				// copy bytes
				#if 0
				std::copy(
					gptr()-putbackcopy,
					gptr(),
					buffer.begin() + putbackspace - putbackcopy
				);
				#endif
				std::memmove(
					buffer.begin() + putbackspace - putbackcopy,
					gptr()-putbackcopy,
					putbackcopy
				);
				
				// load data
				uint64_t const uncompressedsize = stream.readPart(
						buffer.begin()+putbackspace,
						buffer.size()-putbackspace
					);

				// set buffer pointers
				setg(
					buffer.begin()+putbackspace-putbackcopy,
					buffer.begin()+putbackspace,
					buffer.begin()+putbackspace+uncompressedsize
				);

				if ( uncompressedsize )
					return static_cast<int_type>(*(reinterpret_cast<uint8_t const *>(gptr())));
				else
					return traits_type::eof();
			}
开发者ID:dkj,项目名称:libmaus2,代码行数:46,代码来源:SocketInputStreamBuffer.hpp


示例5: setg

ProcReader*
ProcReader::open(const char* fileName, const char* mode)
{
	std::string fullName = "/proc/";
	fullName.append(fileName);

	fFD = ::open(fullName.c_str(), O_RDONLY);
	if (fFD < 0)
		return NULL;

	fBuffer = new char[512];
	if (fBuffer == NULL)
		return NULL;

	setg(fBuffer, fBuffer, fBuffer);
	return this;
}
开发者ID:sqnoc,项目名称:agent,代码行数:17,代码来源:ProcReader.cpp


示例6: socket

 /// Move-assign a basic_socket_streambuf from another.
 basic_socket_streambuf& operator=(basic_socket_streambuf&& other)
 {
   this->close();
   socket() = std::move(other.socket());
   detail::socket_streambuf_io_context::operator=(other);
   ec_ = other.ec_;
   expiry_time_ = other.expiry_time_;
   get_buffer_.swap(other.get_buffer_);
   put_buffer_.swap(other.put_buffer_);
   setg(other.eback(), other.gptr(), other.egptr());
   setp(other.pptr(), other.epptr());
   other.ec_ = asio::error_code();
   other.expiry_time_ = max_expiry_time();
   other.put_buffer_.resize(buffer_size);
   other.init_buffers();
   return *this;
 }
开发者ID:DitansKing,项目名称:asio,代码行数:18,代码来源:basic_socket_streambuf.hpp


示例7: base

int strstreambuf::underflow()
{
    char * tptr;
    if (gptr() >= egptr())
        {
        // try to grow get area if we can...
        if (egptr()<pptr())
            {
            tptr = base() + (gptr()-eback());
            setg(base(),tptr,pptr());
            }
        if (gptr() >= egptr())
            return EOF;
        }

    return (int)(unsigned char) *gptr();
}
开发者ID:ngphloc,项目名称:agmagic,代码行数:17,代码来源:_STRSTRE.CPP


示例8: return

sockbuf::int_type sockbuf::underflow ()
{
  if (gptr () == 0)
    return eof; // input stream has been disabled

  if (gptr () < egptr ())
    return (unsigned char) *gptr (); // eof is a -ve number; make it
                                     // unsigned to be diff from eof

  int rlen = read (eback (), (char*) rep->gend - (char*) eback ());

  if (rlen == 0)
    return eof;

  setg (eback (), eback (), eback () + rlen);
  return (unsigned char) *gptr ();
}
开发者ID:bw-ok,项目名称:GDCM,代码行数:17,代码来源:sockstream.cpp


示例9: gptr

void BinaryStreamBuffer::reserve(size_t newSize)
{
	size_t getPos = 0;
	size_t putPos = 0;
	size_t readEndPos = 0;
	if(!m_dataBuf.empty()){
		getPos = gptr() - eback();
		readEndPos = egptr() - eback();
		putPos = pptr() - buffer();
	}

	if(newSize > m_dataBuf.size())
		m_dataBuf.resize(newSize);

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


示例10: category

LoggerMessage::LoggerMessage(LoggerMessage&& other)
  : std::ostream(nullptr)
  , std::streambuf()
  , category(other.category)
  , logLevel(other.logLevel)
  , logger(other.logger)
  , message(other.message)
  , timestamp(boost::posix_time::microsec_clock::local_time())
  , gotText(false) {
  if (this != &other) {
    _M_tie = nullptr;
    _M_streambuf = nullptr;

    //ios_base swap
    std::swap(_M_streambuf_state, other._M_streambuf_state);
    std::swap(_M_exception, other._M_exception);
    std::swap(_M_flags, other._M_flags);
    std::swap(_M_precision, other._M_precision);
    std::swap(_M_width, other._M_width);

    std::swap(_M_callbacks, other._M_callbacks);
    std::swap(_M_ios_locale, other._M_ios_locale);
    //ios_base swap

    //streambuf swap
    char *_Pfirst = pbase();
    char *_Pnext = pptr();
    char *_Pend = epptr();
    char *_Gfirst = eback();
    char *_Gnext = gptr();
    char *_Gend = egptr();

    setp(other.pbase(), other.epptr());
    other.setp(_Pfirst, _Pend);

    setg(other.eback(), other.gptr(), other.egptr());
    other.setg(_Gfirst, _Gnext, _Gend);

    std::swap(_M_buf_locale, other._M_buf_locale);
    //streambuf swap

    std::swap(_M_fill, other._M_fill);
    std::swap(_M_tie, other._M_tie);
  }
  _M_streambuf = this;
}
开发者ID:conordb,项目名称:bytecoin,代码行数:46,代码来源:LoggerMessage.cpp


示例11: _ASSERT

ERW_Result CRWStreambuf::x_Pushback(void)
{
    if ( !m_Reader ) {
        _ASSERT(!gptr()  &&  !egptr());
        return eRW_Success;
    }

    ERW_Result result;
    const CT_CHAR_TYPE* ptr = gptr();
    size_t count = (size_t)(egptr() - ptr);
    setg(0, 0, 0);
    if ( !count )
        result = eRW_Success;
    else if ((result = m_Reader->Pushback(ptr, count, m_pBuf)) == eRW_Success)
        m_pBuf = 0;
    return result;
}
开发者ID:svn2github,项目名称:ncbi_tk,代码行数:17,代码来源:rwstreambuf.cpp


示例12: STL_ASSERT

stringbuf::pos_type stringbuf::seekoff(off_type __off, ios_base::seekdir __dir, 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);
    STL_ASSERT((eback() <= gptr()) && (gptr() <= egptr()) && (pbase() <= pptr()) && (pptr() <= epptr()));

    streamoff __newoff;
    switch (__dir) 
    {
    case ios_base::beg:
        __newoff = 0;
        break;
    case ios_base::end:
        __newoff = __M_str.size();
        break;
    case ios_base::cur:
        __newoff = __imode ? (gptr() - eback()) : (pptr() - pbase());
        if (__off == 0) return pos_type(__newoff);
        break;
    default:
        return pos_type(-1);
    }

    __off += __newoff;

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

    if (__omode) 
    {
        ptrdiff_t __size = epptr() - pbase();
        if ((__off < 0) || (__off > __size)) return pos_type(-1);
        setp(pbase(), pbase() + __size);
        pbump(static_cast<int>(__off));
    }

    return pos_type(__off);
}
开发者ID:HemingChin,项目名称:POD_STL,代码行数:46,代码来源:sstream.cpp


示例13: pptr

streamsize stringbuf::xsputn(const char_type* __string, streamsize __length) 
{
    if (((__M_mode & ios_base::out) == 0) || (__length <= 0)) return 0;

    streamsize __nwritten = 0;

    // If the put pointer is somewhere in the middle of the string, then overwrite instead of append.
    if (!__M_str.empty() && (pbase() == __M_str.begin()))
    {
        ptrdiff_t __avail = __M_str.end() - pptr();
        if (__avail >= __length)
        {
            VOS_memcpy_s(pptr(), epptr() - pptr(), __string, static_cast<size_t>(__length));
            pbump(static_cast<int>(__length));
            return __length;
        }
        else 
        {
            VOS_memcpy_s(pptr(), epptr() - pptr(), __string, __avail);
            __nwritten += __avail;
            __length -= __avail;
            __string += __avail;
        }
    }

    // At this point we know we're appending.
    char_type* __data_ptr;
    if (__M_mode & ios_base::in) 
    {
        ptrdiff_t __get_offset = gptr() - eback();
        __M_str.append(__string, __string + static_cast<ptrdiff_t>(__length));
        __data_ptr = __M_str.begin();
        setg(__data_ptr, __data_ptr + __get_offset, __M_str.end());
    }
    else 
    {
        __M_str.append(__string, __string + static_cast<ptrdiff_t>(__length));
        __data_ptr = __M_str.begin();
    }

    setp(__data_ptr, __M_str.end());
    pbump(static_cast<int>(__M_str.size()));
    __nwritten += __length;
    return __nwritten;
}
开发者ID:HemingChin,项目名称:POD_STL,代码行数:45,代码来源:sstream.cpp


示例14: _TRACE

EIO_Status CConn_Streambuf::x_Close(bool close)
{
    if (!m_Conn)
        return close ? eIO_Closed : eIO_Success;
 
    EIO_Status status;
    // flush only if some data pending
    if (pbase() < pptr()) {
        if ((status = CONN_Status(m_Conn, eIO_Write)) != eIO_Success) {
            m_Status = status;
            if (CONN_Status(m_Conn, eIO_Open) == eIO_Success) {
                _TRACE(x_Message("Close():  Cannot finalize implicitly"
                                 ", data loss may result"));
            }
        } else if (sync() != 0)
            status = m_Status != eIO_Success ? m_Status : eIO_Unknown;
    } else
        status = eIO_Success;

    setg(0, 0, 0);
    setp(0, 0);

    CONN c = m_Conn;
    m_Conn = 0;  // NB: no re-entry

    if (close) {
        // here: not called from the close callback x_OnClose
        if (m_CbValid) {
            SCONN_Callback cb;
            CONN_SetCallback(c, eCONN_OnClose, &m_Cb, &cb);
            if ((void*) cb.func != (void*) x_OnClose  ||  cb.data != this)
                CONN_SetCallback(c, eCONN_OnClose, &cb, 0);
        }
        if (m_Close  &&  (m_Status = CONN_Close(c)) != eIO_Success) {
            _TRACE(x_Message("Close():  CONN_Close() failed"));
            if (status == eIO_Success)
                status  = m_Status;
        }
    } else if (m_CbValid  &&  m_Cb.func) {
        EIO_Status cbstat = m_Cb.func(c, eCONN_OnClose, m_Cb.data);
        if (cbstat != eIO_Success)
            status  = cbstat;
    }
    return status;
}
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:45,代码来源:ncbi_conn_streambuf.cpp


示例15: common

    istreambuf::istreambuf(std::streambuf * sb)
    : common(sb), end(false) {
        LOG("bz::istreambuf");

        int cret =::BZ2_bzDecompressInit(z_strm,
            0, //verbosity
            0  //no small memory
        );

        if (BZ_OK != cret) {
            LOG("\terror creating zstream " << cret);
            raise_error(cret);
        }
        //initialize streambuf interface functions
        //first call will call uflow and this will set the buffer accordingly
        //no buffering
        setg(out.buf, out.buf, out.buf);
    }
开发者ID:zahmed9,项目名称:sim-recon,代码行数:18,代码来源:bz.cpp


示例16: to_utf8

// Read characters from input buffer.
// This invokes wide_buffer_.xsgetn() which requires a patch for
// console (keyboard) input on Windows, so ensure this class is
// initialized with a patched std::wcin when std::wcin is used.
std::streambuf::int_type unicode_streambuf::underflow()
{
    // Read from the wide input buffer.
    const auto read = wide_buffer_->sgetn(wide_, wide_size_);

    // Handle read termination.
    if (read == 0)
        return traits_type::eof();

    // Convert utf16 to utf8, returning bytes written.
    const auto bytes = to_utf8(narrow_, narrow_size_, wide_, read);

    // Reset gptr and egptr, eback never changes.
    setg(narrow_, narrow_, &narrow_[bytes]);

    // Return the first character in the input sequence.
    return traits_type::to_int_type(*gptr());
}
开发者ID:Saad94,项目名称:libbitcoin,代码行数:22,代码来源:unicode_streambuf.cpp


示例17: init

 void init (
 )
 {
     try
     {
         out_buffer = new char[out_buffer_size];
         in_buffer = new char[in_buffer_size];
     }
     catch (...)
     {
         if (out_buffer) delete [] out_buffer;
         throw;
     }
     setp(out_buffer, out_buffer + (out_buffer_size-1));
     setg(in_buffer+max_putback, 
         in_buffer+max_putback, 
         in_buffer+max_putback);
 }
开发者ID:Iflier,项目名称:dlib,代码行数:18,代码来源:subprocess_stream.cpp


示例18: switch

void sockbuf::shutdown (shuthow sh)
{
    switch (sh) {
    case shut_read:
        delete [] eback ();
        setg (0, 0, 0);
        break;
    case shut_write:
        delete [] pbase ();
        setp (0, 0);
        break;
    case shut_readwrite:
        shutdown (shut_read);
        shutdown (shut_write);
        break;
    }
    if (::shutdown(rep->sock, sh) == -1) throw sockerr (errno, "sockbuf::shutdown", sockname.text.c_str());
}
开发者ID:drescherjm,项目名称:GDCM,代码行数:18,代码来源:sockstream.cpp


示例19: _roll

LoggerBuffer::LoggerBuffer(YAC_LoggerRollPtr roll, size_t buffer_len) : _roll(roll), _buffer(NULL), _buffer_len(buffer_len)
{
    //设置get buffer, 无效, 不适用
    setg(NULL, NULL, NULL);

    //设置put buffer
    if (_roll)
    {
        //分配空间
        _buffer = new char[_buffer_len];
        setp(_buffer, _buffer + _buffer_len);
    }
    else
    {
        setp(NULL, NULL);
        _buffer_len = 0;
    }
}
开发者ID:peerswu,项目名称:Jump,代码行数:18,代码来源:yac_logger.cpp


示例20: sync

// ---------
pos_type CEEStdStreamBufProxy::seekoff(off_type offset, seekdir dir, openmode mode)
{
	// sync in case writing to stream
	sync();

    pos_type pos = 
		m_EEStream->SeekTo(offset, 
            (dir ==  ios::beg) ? SEEK_SET :
            (dir ==  ios::cur) ? SEEK_CUR :
                                        SEEK_END
        );

    if (pos < 0)
        return -1;

    setg(m_Buffer, m_Buffer + 1, m_Buffer + 1);
    return pos;
}
开发者ID:klhurley,项目名称:ElementalEngine2,代码行数:19,代码来源:EEStdStreamBufProxy.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ setgid函数代码示例发布时间:2022-05-30
下一篇:
C++ setfont函数代码示例发布时间: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