本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}