本文整理汇总了C++中pbump函数的典型用法代码示例。如果您正苦于以下问题:C++ pbump函数的具体用法?C++ pbump怎么用?C++ pbump使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pbump函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Yadro,项目名称:avs-device-sdk,代码行数:26,代码来源:LogEntryBuffer.cpp
示例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;
}
开发者ID:ProjectAsura,项目名称:tungsten,代码行数:7,代码来源:FileStreambuf.cpp
示例3: pbump
Socket::int_type Socket::overflow(int_type c) {
if(sync() == EOF)
return EOF;
*pbase() = c;
pbump(1);
return c;
}
开发者ID:darcyg,项目名称:netLink,代码行数:7,代码来源:Socket.cpp
示例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;
}
开发者ID:stepp,项目名称:stanford-cpp-library,代码行数:28,代码来源:plainconsole.cpp
示例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;
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-cxxtools,代码行数:31,代码来源:tcpstream.cpp
示例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);
}
开发者ID:neurodebian,项目名称:iv-hines,代码行数:35,代码来源:rpcbuf.cpp
示例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() );
}
开发者ID:buchenberg,项目名称:zorba,代码行数:7,代码来源:mem_streambuf.cpp
示例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;
}
开发者ID:HemingChin,项目名称:POD_STL,代码行数:27,代码来源:sstream.cpp
示例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;
}
开发者ID:913862627,项目名称:cxxtools,代码行数:31,代码来源:md5stream.cpp
示例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);
}
开发者ID:crystax,项目名称:android-toolchain-libcxx-3-6,代码行数:30,代码来源:strstream.cpp
示例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;
}
开发者ID:go4and,项目名称:lib,代码行数:27,代码来源:Output.cpp
示例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;
}
开发者ID:WarlockD,项目名称:Cocos2dx-Undertale-Engine,代码行数:26,代码来源:console.cpp
示例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;
}
开发者ID:jgmdev,项目名称:PHP-CPP,代码行数:32,代码来源:streambuf.cpp
示例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;
}
开发者ID:dietmarkuehl,项目名称:kuhllib,代码行数:29,代码来源:cstrstrm.cpp
示例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));
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:30,代码来源:STRSTREA.CPP
示例16: commit
/**
* Appends @c n characters from the start of the output sequence to the input
* sequence. The beginning of the output sequence is advanced by @c n
* characters.
*
* Requires a preceding call <tt>prepare(x)</tt> where <tt>x >= n</tt>, and
* no intervening operations that modify the input or output sequence.
*
* @throws std::length_error If @c n is greater than the size of the output
* sequence.
*/
void commit(std::size_t n)
{
if (pptr() + n > epptr())
n = epptr() - pptr();
pbump(static_cast<int>(n));
setg(eback(), gptr(), pptr());
}
开发者ID:13609594236,项目名称:ph-open,代码行数:18,代码来源:basic_streambuf.hpp
示例17: setg
int gzfilebuf::overflow( int c ) {
if ( !is_open() || !(mode & ios::out) )
return EOF;
if ( !base() ) {
if ( allocate() == EOF )
return EOF;
setg(0,0,0);
} else {
if (in_avail()) {
return EOF;
}
if (out_waiting()) {
if (flushbuf() == EOF)
return EOF;
}
}
int bl = blen();
setp( base(), base() + bl);
if ( c != EOF ) {
*pptr() = c;
pbump(1);
}
return 0;
}
开发者ID:brunobuzzi,项目名称:Dolphin,代码行数:32,代码来源:zfstream.cpp
示例18: pptr
void LoggerBuffer::reserve(std::streamsize n)
{
if (n <= _buffer_len)
{
return;
}
//不超过最大大小
if (n > MAX_BUFFER_LENGTH)
{
n = MAX_BUFFER_LENGTH;
}
int len = pptr() - pbase();
char_type * p = new char_type[n];
memcpy(p, _buffer, len);
delete[] _buffer;
_buffer = p;
_buffer_len = n;
setp(_buffer, _buffer + _buffer_len);
pbump(len);
return;
}
开发者ID:hunterhang,项目名称:test_frame,代码行数:26,代码来源:tc_logger.cpp
示例19: pptr
GnuTls_streambuf::int_type GnuTls_streambuf::overflow(GnuTls_streambuf::int_type c)
{
try
{
if (pptr() != pbase())
{
int n = m_stream.sslWrite(pbase(), pptr() - pbase());
if (n <= 0)
return traits_type::eof();
}
setp(m_buffer, m_buffer + m_bufsize);
if (c != traits_type::eof())
{
*pptr() = (char_type)c;
pbump(1);
}
return 0;
}
catch (const std::exception& e)
{
log_error("error int GnuTls_streambuf::overflow: " << e.what());
return traits_type::eof();
}
}
开发者ID:913862627,项目名称:tntnet,代码行数:26,代码来源:gnutls.cpp
示例20: pptr
int gzstreambuf::flush_buffer() {
int w = pptr() - pbase();
if (gzwrite(file, pbase(), w) != w)
return EOF;
pbump(-w);
return w;
}
开发者ID:OpenMandrivaSoftware,项目名称:ldetect,代码行数:7,代码来源:gzstream.cpp
注:本文中的pbump函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论