本文整理汇总了C++中pbump函数的典型用法代码示例。如果您正苦于以下问题:C++ pbump函数的具体用法?C++ pbump怎么用?C++ pbump使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pbump函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pptr
LogEntryBuffer::int_type LogEntryBuffer::overflow(int_type ch) {
if (traits_type::eof() == ch) {
return traits_type::eof();
}
auto size = pptr() - m_base;
if (!m_largeBuffer) {
m_largeBuffer.reset(new std::vector<char>(ACSDK_LOG_ENTRY_BUFFER_SMALL_BUFFER_SIZE * 2));
memcpy(m_largeBuffer->data(), m_base, size);
} else {
m_largeBuffer->resize(m_largeBuffer->size() * 2);
}
auto newBase = m_largeBuffer->data();
auto delta = newBase - m_base;
// -1 so there is always room to append a null terminator.
auto newEnd = newBase + m_largeBuffer->size() - 1;
setp(newBase + size, newEnd);
setg(newBase, gptr() + delta, newEnd);
m_base = newBase;
*pptr() = ch;
pbump(1);
return ch;
}
示例2: pptr
int FileOutputStreambuf::sync()
{
std::ptrdiff_t n = pptr() - pbase();
pbump(int(-n));
return std::fwrite(_buffer.get(), 1, n, _file.get()) != size_t(n) ? -1 : 0;
}
示例3: pbump
Socket::int_type Socket::overflow(int_type c) {
if(sync() == EOF)
return EOF;
*pbase() = c;
pbump(1);
return c;
}
示例4: overflow
virtual int overflow(int ch = EOF) {
std::string line = "";
for (char *cp = pbase(); cp < pptr(); cp++) {
if (*cp == '\n') {
// puts(line.c_str());
outputPrinted += line.length();
if (outputLimit > 0 && outputPrinted > outputLimit) {
error("excessive output printed");
}
line = "";
} else {
line += *cp;
}
}
if (line != "") {
// puts(line.c_str());
outputPrinted += line.length();
if (outputLimit > 0 && outputPrinted > outputLimit) {
error("excessive output printed");
}
}
setp(outBuffer, outBuffer + BUFFER_SIZE);
if (ch != EOF) {
outBuffer[0] = ch;
pbump(1);
}
return ch != EOF;
}
示例5: log_debug
streambuf::int_type streambuf::overflow(streambuf::int_type c)
{
log_debug("streambuf::overflow");
if (pptr())
{
Stream::size_type N = pptr() - m_buffer; // bytes to write
Stream::size_type n = m_stream.write(m_buffer, N, false);
if (n <= 0)
return traits_type::eof();
if (n < N)
{
// there are bytes left - move them to the start of our buffer
memmove(m_buffer, m_buffer + n, N - n);
setp(m_buffer + N - n, m_buffer + m_bufsize);
}
else
setp(m_buffer, m_buffer + m_bufsize);
}
else
setp(m_buffer, m_buffer + m_bufsize);
if (c != traits_type::eof())
{
*pptr() = traits_type::to_char_type(c);
pbump(1);
}
return 0;
}
示例6: 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);
}
示例7: pbump
mem_streambuf::int_type mem_streambuf::pbackfail( int_type c ) {
if ( !traits_type::eq_int_type( c, traits_type::eof() ) ) {
*pptr() = traits_type::to_char_type( c );
pbump( -1 );
}
return traits_type::to_int_type( *pptr() );
}
示例8: pos_type
stringbuf::pos_type stringbuf::seekpos(pos_type __pos, 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);
const off_type __offset = __pos - pos_type(0);
if (__imode)
{
if ((__offset < 0) || (__offset > (egptr() - eback()))) return pos_type(-1);
setg(eback(), eback() + static_cast<ptrdiff_t>(__offset), egptr());
}
if (__omode)
{
if ((__offset < 0) || (size_t(__offset) > __M_str.size())) return pos_type(-1);
setp(__M_str.begin(), __M_str.end());
pbump(static_cast<int>(__offset));
}
return __pos;
}
示例9: log_debug
std::streambuf::int_type Md5streambuf::overflow(
std::streambuf::int_type ch)
{
if (pptr() == 0)
{
// Ausgabepuffer ist leer - initialisieren
log_debug("initialize MD5");
cxxtools_MD5Init(context);
}
else
{
// konsumiere Zeichen aus dem Puffer
log_debug("process " << (pptr() - pbase()) << " bytes of data");
cxxtools_MD5Update(context,
(const unsigned char*)pbase(),
pptr() - pbase());
}
// setze Ausgabepuffer
setp(buffer, buffer + bufsize);
if (ch != traits_type::eof())
{
// das Zeichen, welches den overflow ausgelöst hat, stecken
// wir in den Puffer.
*pptr() = traits_type::to_char_type(ch);
pbump(1);
}
return 0;
}
示例10: __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);
}
示例11: xsputn
std::streamsize xsputn(const char_type * s, std::streamsize n)
{
const char_type * end = s + n;
size_t c = std::min<size_t>(end - s, epptr() - pptr());
memcpy(pptr(), s, c);
pbump(static_cast<int>(c));
s += c;
if(s != end)
{
size_t c;
cur_->next = new Buffer;
cur_ = cur_->next;
for(;;)
{
c = std::min<size_t>(end - s, bufferSize);
memcpy(&cur_->data[0], s, c);
s += c;
if(s == end)
break;
cur_->next = new Buffer;
cur_ = cur_->next;
}
char * begin = &cur_->data[0];
std::streambuf::setp(begin + c, begin + bufferSize);
}
return n;
}
示例12: sync
int sync() override
{
std::ptrdiff_t n = pptr() - pbase();
for (auto ptr = pbase(); ptr != pptr(); ptr++) {
CharT ch = *ptr;
if (ch == '\r' || ch == '\n') {
if (_lastc != ch && (_lastc == '\r' || _lastc == '\n')) {
ch = 0;
}
else {
_linebuffer.push_back(0);
auto now = std::chrono::system_clock::now();
auto in_time_t = std::chrono::system_clock::to_time_t(now);
std::basic_stringstream<CharT, TraitsT> ss;
ss << "[" << std::put_time(std::localtime(&in_time_t), "%Y-%m-%d %X") << "]:" << _linebuffer.data() << std::endl;
output_visualstudio(ss.str().c_str());
_linebuffer.clear();
}
}
else _linebuffer.push_back(ch);
_lastc = ch;
}
pbump(-n);
return 0;
}
示例13: pptr
/**
* Called when the internal buffer should be synchronized
* @return int
*/
int StreamBuf::sync()
{
// current buffer size
size_t size = pptr() - pbase();
// is this the error stream or the regular output stream?
if (_error)
{
// write to error (the zend_error() method is a varargs function,
// which means that we have to include a printf() like format as first
// parameter. We can not specify pbase() directly, because (1) it is
// not null terminated and (2) it could contain % signs and allow all
// sorts of buffer overflows.
zend_error(_error, "%.*s", (int)size, pbase());
}
else
{
// write to zend
zend_write(pbase(), size);
}
// reset the buffer
pbump(-size);
// done
return 0;
}
示例14: 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;
}
示例15: 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));
}