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


C++ pptr函数代码示例

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


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

示例1: okay

	/**
		Put bit at put pointer.

		\param[out] b Current bit.
		\return Whether okay (eof has not been encountered).
	*/
	bool sputb(bitfield b)
	{
		// Note: This is an optimization of "return sputn(bitfield, 1) == 1;"

		bool put_succeeded = true;

		if (pptr() == std::streampos(-1) || pptr() == epptr())
		{
			put_succeeded = overflow(b);
		}
		else
		{
			const size_t intra_byte_bit_offset = pptr() % CHAR_BIT;
			const size_t shift_amount = (CHAR_BIT - ((1 + intra_byte_bit_offset) % CHAR_BIT)) % CHAR_BIT;
			const unsigned char mask = ~(1 << shift_amount);
			unsigned char * const byte_pointer = current_put_byte();
			*byte_pointer = *byte_pointer & mask | (b & 1) << shift_amount;

			pbump(1);
		}

		return put_succeeded;
	}
开发者ID:dplong,项目名称:bitstream,代码行数:29,代码来源:iob.hpp

示例2: T

   int
   mlpipebuf::buffer_out()
   {
#ifdef DEBUG
      char *fname = "mlpipebuf::buffer_out()";
      Tracebuf T(fname);
#endif

      int cnt = pptr() - pbase();
      int retval = buffer_to_device(m_outbuf, cnt);
      pbump(-cnt);

      return retval;
   }
开发者ID:bryanhinton,项目名称:mls,代码行数:14,代码来源:mlpipebuf.cpp

示例3: pptr

int callbackBuffer::overflow(int ch)
{
	streamsize n = pptr() - pbase();
	if (n && sync())
		return EOF;
	if (ch != EOF) {
		char cbuf[1];
		cbuf[0] = (char) ch;
		if (write_to_callback(cbuf, 1) != 1)
			return EOF;
	}
	pbump(-n);					// Reset pptr().
	return 0;
}
开发者ID:wreality,项目名称:pstoedit-lmn-laser,代码行数:14,代码来源:cbstream.cpp

示例4: overflow

int scgi_outbuffer::overflow(int c)
{
	int len=pptr()-pbase();
	if(len) {
		int n=safe_write(fd,pbase(),len);
		pbump(-n);
	}
	if(c!=EOF) {
		char b=c;
		if(safe_write(fd,&b,1)<1)
			return EOF;
	}
	return 0;
}
开发者ID:klupek,项目名称:cppcms,代码行数:14,代码来源:scgi.cpp

示例5: pptr

bool ocryptostreambuf::update()
{
  int inl = pptr() - pbase(); // number of bytes to input
  pbump(-inl);
  int outl = 0;
  if (1 != EVP_CipherUpdate(ctx, (uint8_t*)out.data(), &outl, (uint8_t*)pbase(), inl))
    {
      EVP_CIPHER_CTX_free(ctx);
      ctx = NULL;
      return false;
    }
  // output to underlying stream
  return ( output.sputn(out.data(), outl) == outl );
}
开发者ID:jklof,项目名称:cryptostreambuf,代码行数:14,代码来源:cryptostreambuf.cpp

示例6: flushBuffer

    int flushBuffer () { // do the actual write
        int num = (int)(pptr()-pbase());
        if (write(2, buffer, num) != num) { // out to stderr
            return EOF;
        }
		// and log it
		buffer[num] = 0;
		if (!logs_.size()) { // did we recently hose this out?
			logs_.push_back(mprocess::mnote(time(NULL),std::string("")));
		}
		logs_[0].second += buffer;
        pbump (-num);    // reset put pointer accordingly
        return num;
    }
开发者ID:bspratt,项目名称:xtandem-g,代码行数:14,代码来源:mapreducehelper.cpp

示例7: gptr

MessageBuffer::int_type MessageBuffer::overflow(int_type ch)
{
    typedef MessageBuffer::traits_type traits_type;

    if( ! _buffer)
    {
        _bufferSize = BufferSize;
        _buffer = new char[_bufferSize];
        this->setp(_buffer, _buffer + _bufferSize);
        this->setg(_buffer, _buffer, _buffer);
    }
    else
    {
        std::size_t bufsize = _bufferSize + BufferSize;
        char* buf = new char[ bufsize ];
        traits_type::copy(buf, _buffer, _bufferSize);
        std::swap(_buffer, buf);

        this->setp(_buffer, _buffer + bufsize);
        this->pbump(_bufferSize);

        std::size_t gsize = gptr() - eback();
        this->setg(_buffer, _buffer + gsize, pptr());
        
        _bufferSize = bufsize;
        delete [] buf;
    }

    // if the overflow char is not EOF put it in buffer
    if(traits_type::eq_int_type(ch, traits_type::eof()) == false)
    {
        *pptr() = traits_type::to_char_type(ch);
        this->pbump(1);
    }

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

示例8: pbump

int LogBuf::overflow(Int32 c)
{
    if(!pptr())
        return EOF;

    if(c != EOF)
    {
        // Put character into write buffer
        *pptr() = c;

        pbump(1);

        // Flush write buffer
        std::streamsize size = pptr() - pbase();

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

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

示例9: Assert

  int bz2streambuf::overflow(int c)
  {
    Assert(write);

    int w = pptr() - pbase();
    if (c != EOF)
    {
      *pptr() = c;
      ++w;
    }

    BZ2_bzWrite(&bzerror, bzfile, pbase(), w * sizeof(char));
    if (bzerror == BZ_OK)
    {
      setp(buf, buf + bufsize - 1);
      return 0;
    }
    else
    {
      error = true;
      setp(0, 0);
      return EOF;
    }
  }
开发者ID:CanoeFZH,项目名称:dx-toolkit,代码行数:24,代码来源:Compress.cpp

示例10: overflow

  /**
   * Behaves according to the specification of @c std::streambuf::overflow(),
   * with the specialisation that @c std::length_error is thrown if appending
   * the character to the input sequence would require the condition
   * <tt>size() > max_size()</tt> to be true.
   */
  int_type overflow(int_type c)
  {
    if (!traits_type::eq_int_type(c, traits_type::eof()))
    {
      if (pptr() == epptr())
      {
        std::size_t buffer_size = pptr() - gptr();
        if (buffer_size < max_size_ && max_size_ - buffer_size < buffer_delta)
        {
          reserve(max_size_ - buffer_size);
        }
        else
        {
          reserve(buffer_delta);
        }
      }

      *pptr() = traits_type::to_char_type(c);
      pbump(1);
      return c;
    }

    return traits_type::not_eof(c);
  }
开发者ID:13609594236,项目名称:ph-open,代码行数:30,代码来源:basic_streambuf.hpp

示例11: seekpos

std::streampos SimpleStreamBuf::seekoff(std::streamoff off, std::ios_base::seekdir dir, std::ios_base::openmode which)
{
    if (dir == std::ios_base::beg)
    {
        return seekpos(off, which);
    }
    else if (dir == std::ios_base::end)
    {
        return seekpos((pptr() - m_buffer) - off, which);
    }
    else if (dir == std::ios_base::cur)
    {
        if(which == std::ios_base::in)
        { 
            return seekpos((gptr() - m_buffer) + off, which);
        }
        else
        {
            return seekpos((pptr() - m_buffer) + off, which);
        }
    }

    return off_type(-1);
}
开发者ID:marcomagdy,项目名称:aws-sdk-cpp,代码行数:24,代码来源:SimpleStreamBuf.cpp

示例12: PHYSFS_write

std::streambuf::int_type COutputStreamBuffer::overflow(std::streambuf::int_type ch)
{
    /* This function should be called when pptr() == epptr(). We use it also in sync()
       so we also have to write data if buffer is not full. */

    if (pbase() == pptr()) // no data to write, sync() called with empty buffer
        return 0;

    // save buffer
    PHYSFS_sint64 bytes_written = PHYSFS_write(m_file, pbase(), 1, pptr() - pbase());
    if (bytes_written <= 0)
        return traits_type::eof();

    pbump(-bytes_written);
    // write final char
    if (ch != traits_type::eof())
    {
        bytes_written = PHYSFS_write(m_file, &ch, 1, 1);
        if (bytes_written <= 0)
            return traits_type::eof();
    }

    return ch;
}
开发者ID:CyborgMaster,项目名称:colobot,代码行数:24,代码来源:outputstreambuffer.cpp

示例13: switch

std::streampos iconvstreambuf::seekoff(std::streamoff off,
  std::ios_base::seekdir way, std::ios_base::openmode which)
{
  // modify off to by relative position from current position
  switch (way) {
    case std::ios_base::beg:
      off -= pos;
    case std::ios_base::cur:
      break;
    default:
      return std::streampos(-1);
  }

  if (which == std::ios_base::in) {
    char *buf_p = gptr() + off;
    // alow seek only on valid data
    if (buf_p < eback() || buf_p > pptr())
        return std::streampos(-1);

    gbump(off);
    pos += off;
    return pos;
  }

  if (which == std::ios_base::out) {
    char *buf_p = pptr() + off;
    // alow seek only on valid data
    if (buf_p < pbase() || buf_p > pptr())
        return std::streampos(-1);

    pbump(off);
    return pos + off;
  }

  return std::streampos(-1);
}
开发者ID:913862627,项目名称:cxxtools,代码行数:36,代码来源:iconvstream.cpp

示例14: LOG

 int ostreambuf::overflow (int c) {
     LOG("bz::ostreambuf::overflow(" << c << ")\t available=" << (available ()) << "\tEOF=" << eof);
     if (eof == c) {
         LOG("\tEOF");
         flush(no_sync);
         return eof;
     } else {
         if (0 == available()) {
             LOG("\t have to flush :[]");
             flush(no_sync);
         }
         *pptr() = static_cast < char >(c);
         pbump(1);
     }
     return c;
 }
开发者ID:zahmed9,项目名称:sim-recon,代码行数:16,代码来源:bz.cpp

示例15: overflow

 // output functions
 int_type overflow (
     int_type c
 )
 {
     if (c != EOF)
     {
         *pptr() = c;
         pbump(1);
     }
     if (flush_out_buffer() == EOF)
     {
         // an error occurred
         return EOF;
     }
     return c;
 }
开发者ID:Iflier,项目名称:dlib,代码行数:17,代码来源:subprocess_stream.cpp


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