本文整理汇总了C++中pbase函数的典型用法代码示例。如果您正苦于以下问题:C++ pbase函数的具体用法?C++ pbase怎么用?C++ pbase使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pbase函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pptr
openssl_streambuf::int_type openssl_streambuf::overflow(openssl_streambuf::int_type c)
{
try
{
if (pptr() != pbase())
{
int n = _stream.sslWrite(pbase(), pptr() - pbase());
if (n <= 0)
return traits_type::eof();
}
setp(_buffer, _buffer + _bufsize);
if (c != traits_type::eof())
{
*pptr() = (char_type)c;
pbump(1);
}
return 0;
}
catch (const std::exception& e)
{
log_error("error int openssl_streambuf::overflow: " << e.what());
return traits_type::eof();
}
}
开发者ID:DaTomTom,项目名称:tntnet,代码行数:26,代码来源:openssl.cpp
示例2: epptr
_STLP_EXP_DECLSPEC void strstreambuf::freeze(bool frozenflag)
{
#ifdef __SYMBIAN32__
if (_M_dynamic)
{
//
if (frozenflag && !_M_frozen)
{ // disable writing
_M_frozen = frozenflag;
_pfrozenendsave = epptr();
_pgetfrozenendsave = pptr();
setp(pbase(), eback());
}
else if (!frozenflag && _M_frozen)
{ // re-enable writing
_M_frozen = frozenflag;
if(_pfrozenendsave != NULL)
{
setp(pbase(), _pfrozenendsave);
setg(pbase(), pbase(), _pgetfrozenendsave);
}
}
}
#else
if (_M_dynamic)
_M_frozen = frozenflag;
#endif
}
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:28,代码来源:strstream.cpp
示例3: __p
strstreambuf::pos_type
strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which)
{
off_type __p(-1);
bool pos_in = (__which & ios::in) != 0;
bool pos_out = (__which & ios::out) != 0;
bool legal = false;
switch (__way)
{
case ios::beg:
case ios::end:
if (pos_in || pos_out)
legal = true;
break;
case ios::cur:
if (pos_in != pos_out)
legal = true;
break;
}
if (pos_in && gptr() == nullptr)
legal = false;
if (pos_out && pptr() == nullptr)
legal = false;
if (legal)
{
off_type newoff;
char* seekhigh = epptr() ? epptr() : egptr();
switch (__way)
{
case ios::beg:
newoff = 0;
break;
case ios::cur:
newoff = (pos_in ? gptr() : pptr()) - eback();
break;
case ios::end:
newoff = seekhigh - eback();
break;
default:
return pos_type(off_type(-1));
}
newoff += __off;
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 = epptr() - newpos;
setp(min(pbase(), newpos), epptr());
pbump(static_cast<int>((epptr() - pbase()) - __off));
}
__p = newoff;
}
}
return pos_type(__p);
}
开发者ID:crystax,项目名称:android-toolchain-libcxx-3-6,代码行数:59,代码来源:strstream.cpp
示例4: out_lock
int server_streambuf::flush(bool end) {
std::error_code e;
// wait for previous responses in the pipeline to complete:
{
std::unique_lock<std::mutex> out_lock(act_mutex);
while (!active)
act_cond.wait(out_lock);
}
// flush headers if not already written:
if (!hdrs_written) {
size_t content_len;
if (!query_headers_content_length(out_hdrs, content_len)) {
chunked = true;
#ifdef CLANE_HAVE_STD_MULTIMAP_EMPLACE
out_hdrs.emplace("transfer-encoding", "chunked");
#else
out_hdrs.insert(header("transfer-encoding", "chunked"));
#endif
}
std::ostringstream ss;
ss << "HTTP/" << major_ver << '.' << minor_ver << ' ' << static_cast<int>(out_stat_code) << ' ' <<
what(out_stat_code) << "\r\n";
for (auto i = out_hdrs.begin(); i != out_hdrs.end(); ++i)
ss << canonize_1x_header_name(i->first) << ": " << i->second << "\r\n";
ss << "\r\n";
std::string hdr_lines = ss.str();
sock.send(hdr_lines.data(), hdr_lines.size(), net::all, e);
if (e)
return -1; // connection error
hdrs_written = true;
}
// send:
size_t chunk_len = pptr() - pbase();
if (chunk_len) {
if (chunked) {
std::ostringstream ss;
ss << std::hex << chunk_len << "\r\n";
std::string chunk_line = ss.str();
sock.send(chunk_line.data(), chunk_line.size(), net::all, e);
if (e)
return -1; // connection error
}
sock.send(pbase(), chunk_len, net::all, e);
if (e)
return -1; // connection error
if (chunked) {
sock.send("\r\n", 2, net::all, e);
if (e)
return -1; // connection error
}
}
// final chunk:
if (end && chunked) {
sock.send("0\r\n\r\n", 5, net::all, e);
if (e)
return -1; // connection error
}
return 0; // success
}
开发者ID:cmbrandenburg,项目名称:clane,代码行数:59,代码来源:clane_http_server.cpp
示例5: doSync
void doSync()
{
uint64_t n = pptr()-pbase();
pbump(-n);
char * p = pbase();
while ( n )
{
ssize_t const w = ::write(fd,p,n);
if ( w < 0 )
{
int const error = errno;
switch ( error )
{
case EINTR:
case EAGAIN:
break;
default:
{
libmaus2::exception::LibMausException se;
se.getStream() << "LinuxStreamingPosixFdOutputStreamBuffer::doSync(): write() failed: " << strerror(error) << std::endl;
se.finish();
throw se;
}
}
}
else
{
assert ( w <= static_cast<int64_t>(n) );
#if defined(__GLIBC__)
#if __GLIBC_PREREQ(2,6)
// non block buffer cache flush request for range we have just written
if ( w )
{
::sync_file_range(fd, prevwrite.first+prevwrite.second, w, SYNC_FILE_RANGE_WRITE);
}
if ( prevwrite.second )
{
// blocking buffer cache flush request for previous buffer
::sync_file_range(fd, prevwrite.first, prevwrite.second, SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE|SYNC_FILE_RANGE_WAIT_AFTER);
// tell kernel we no longer need the pages
::posix_fadvise(fd, prevwrite.first, prevwrite.second, POSIX_FADV_DONTNEED);
}
#endif
#endif
prevwrite.first = prevwrite.first + prevwrite.second;
prevwrite.second = w;
n -= w;
}
}
assert ( ! n );
}
开发者ID:jameslz,项目名称:libmaus2,代码行数:59,代码来源:LinuxStreamingPosixFdOutputStreamBuffer.hpp
示例6: sync
int sync() override {
std::ptrdiff_t n = pptr() - pbase();
for (auto ptr = pbase(); ptr != pptr(); ptr++) {
push(*ptr);
}
pbump(-n);
return 0;
}
开发者ID:WarlockD,项目名称:UnderTalk,代码行数:8,代码来源:global.cpp
示例7: writeData
int TCPStream::overflow(int c)
{
unsigned char ch;
ssize_t rlen, req;
if(bufsize == 1) {
if(c == EOF)
return 0;
ch = (unsigned char)(c);
if(Socket::state == STREAM)
rlen = ::write((int)so, (const char *)&ch, 1);
else
rlen = writeData(&ch, 1);
if(rlen < 1) {
if(rlen < 0) {
iostream::clear(ios::failbit | rdstate());
error(errOutput,(char *)"Could not write to socket",socket_errno);
}
return EOF;
}
else
return c;
}
if(!pbase())
return EOF;
req = (ssize_t)(pptr() - pbase());
if(req) {
if(Socket::state == STREAM)
rlen = ::write((int)so, (const char *)pbase(), req);
else
rlen = writeData(pbase(), req);
if(rlen < 1) {
if(rlen < 0) {
iostream::clear(ios::failbit | rdstate());
error(errOutput,(char *)"Could not write to socket",socket_errno);
}
return EOF;
}
req -= rlen;
}
// if write "partial", rebuffer remainder
if(req)
// memmove(pbuf, pptr() + rlen, req);
memmove(pbuf, pbuf + rlen, req);
setp(pbuf, pbuf + bufsize);
pbump(req);
if(c != EOF) {
*pptr() = (unsigned char)c;
pbump(1);
}
return c;
}
开发者ID:tmatth,项目名称:ucommon,代码行数:58,代码来源:tcp.cpp
示例8: return
/***
*virtual int filebuf::sync() - synchronize buffers with external file postion.
*
*Purpose:
* Synchronizes buffer with external file, by flushing any output and/or
* discarding any unread input data. Discards any get or put area(s).
*
*Entry:
* None.
*
*Exit:
* Returns EOF if error, else 0.
*
*Exceptions:
* Returns EOF if error.
*
*******************************************************************************/
int filebuf::sync()
{
long count, nout;
char * p;
if (x_fd==-1)
return(EOF);
if (!unbuffered())
{
if ((count=out_waiting())!=0)
{
if ((nout =_write(x_fd,(void *) pbase(),(unsigned int)count)) != count)
{
if (nout > 0) {
// should set _pptr -= nout
pbump(-(int)nout);
memmove(pbase(), pbase()+nout, (int)(count-nout));
}
return(EOF);
}
}
setp(0,0); // empty put area
if ((count=in_avail()) > 0)
{
// can't use seekoff here!!
#ifdef _WIN32
if (_osfile(x_fd) & FTEXT)
#else
if (_osfile[x_fd] & FTEXT)
#endif
{
// If text mode, need to account for CR/LF etc.
for (p = gptr(); p < egptr(); p++)
if (*p == '\n')
count++;
// account for EOF if read, not counted by _read
#ifdef _WIN32
if ((_osfile(x_fd) & FEOFLAG))
#else
if ((_osfile[x_fd] & FEOFLAG))
#endif
count++;
}
if (_lseek(x_fd, -count, SEEK_CUR)==-1L)
{
// unlock();
return (EOF);
}
}
setg(0,0,0); // empty get area
}
// unlock();
return(0);
}
开发者ID:chunhualiu,项目名称:OpenNT,代码行数:74,代码来源:filebuf.cpp
示例9: sync
int sync()
{
output();
for(SyncStreamSet::iterator i = sync_stream_set_.begin(); i != sync_stream_set_.end(); ++i) {
(*i)->sputn(pbase(), (std::streamsize)(pptr()-pbase()));
}
setp(__buf, __buf+(BUF_LEN-1));
return 0;
}
开发者ID:Emulyator,项目名称:gamecatapult,代码行数:9,代码来源:dbgoutbuf.hpp
示例10: pptr
int ClientSocket::StreamBuf::sync()
{
if(pbase() != pptr())
{
conn->write(pbase(), pptr() - pbase());
setp(outBuffer, outBuffer + sizeof(outBuffer) - 1);
}
return 1;
}
开发者ID:brianwatling,项目名称:StreamPlot,代码行数:9,代码来源:ClientSocket.cpp
示例11: pbase
int filedescbuf::sync()
{
if (pbase() && pptr() > pbase())
{
(void)::write(_fd, pbase(), pptr() - pbase()) ;
setp(buffer, buffer + sizeof(buffer)) ;
}
return 0 ;
}
开发者ID:ralfbrown,项目名称:framepac,代码行数:9,代码来源:frgcc3.C
示例12: pptr
int gzstreambuf::flush_buffer() {
// Separate the writing of the buffer from overflow() and
// sync() operation.
int w = pptr() - pbase();
if ( gzwrite( file, pbase(), w) != w)
return EOF;
pbump( -w);
return w;
}
开发者ID:AenBleidd,项目名称:openmalaria,代码行数:9,代码来源:gzstream.cpp
示例13: pptr
void EncryptBuffer::encryptAndFlush() {
std::ptrdiff_t n = pptr() - pbase();
if (n > 0) {
Slice slice = buffer_(0, n);
encrypt_.write(slice, slice);
pbump(-n);
sink_.sputn(pbase(), n);
}
}
开发者ID:facebook,项目名称:conceal,代码行数:9,代码来源:EncryptStream.cpp
示例14: doFlush
bool doFlush(){
if(!port.isOpen())
return false;
const std::ptrdiff_t bytesAvailable = pptr()-pbase();
const std::ptrdiff_t bytesWritten = port.write(reinterpret_cast<const uint8_t*>(pbase()), bytesAvailable);
if(bytesWritten!=bytesAvailable)
throw std::runtime_error("SerialProvider: Error writing to serial port.");
// std::cout << "Bytes to serial: "<<bytesWritten<<std::endl;
pbump(-bytesWritten);
return true;
}
开发者ID:PADrend,项目名称:Util,代码行数:11,代码来源:SerialProvider.cpp
示例15: pbase
CT_INT_TYPE CConn_Streambuf::overflow(CT_INT_TYPE c)
{
if (!m_Conn)
return CT_EOF;
size_t n_written;
size_t n_towrite = (size_t)(pptr() - pbase());
if (n_towrite) {
// send buffer
do {
m_Status = CONN_Write(m_Conn, pbase(),
n_towrite, &n_written, eIO_WritePlain);
_ASSERT(n_written <= n_towrite);
if (!n_written) {
_ASSERT(m_Status != eIO_Success);
break;
}
// update buffer content (get rid of the data just sent)
memmove(pbase(), pbase() + n_written, n_towrite - n_written);
x_PPos += (CT_OFF_TYPE) n_written;
pbump(-int(n_written));
// store char
if (!CT_EQ_INT_TYPE(c, CT_EOF))
return sputc(CT_TO_CHAR_TYPE(c));
n_towrite -= n_written;
} while (n_towrite && m_Status == eIO_Success);
if (n_towrite) {
_ASSERT(m_Status != eIO_Success);
ERR_POST_X(4, x_Message("overflow(): CONN_Write() failed"));
return CT_EOF;
}
} else if (!CT_EQ_INT_TYPE(c, CT_EOF)) {
// send char
CT_CHAR_TYPE b = CT_TO_CHAR_TYPE(c);
m_Status = CONN_Write(m_Conn, &b, 1, &n_written, eIO_WritePlain);
_ASSERT(n_written <= 1);
if (!n_written) {
_ASSERT(m_Status != eIO_Success);
ERR_POST_X(5, x_Message("overflow(): CONN_Write(1) failed"));
return CT_EOF;
}
x_PPos += (CT_OFF_TYPE) 1;
return c;
}
_ASSERT(CT_EQ_INT_TYPE(c, CT_EOF));
if ((m_Status = CONN_Flush(m_Conn)) != eIO_Success) {
ERR_POST_X(9, x_Message("overflow(): CONN_Flush() failed"));
return CT_EOF;
}
return CT_NOT_EOF(CT_EOF);
}
开发者ID:DmitrySigaev,项目名称:ncbi,代码行数:54,代码来源:ncbi_conn_streambuf.cpp
示例16: pbase
int streambuf::sync ()
{
// Ouput all contents of put buffer.
const std::streamsize count = myStream.write(
pbase(), ::ULONG(pptr()-pbase())
);
// Adjust put buffer pointers.
setp(pptr(),epptr());
// Indicate status (failure/success).
return ((count == 0)? 0 : 1);
}
开发者ID:AndreLouisCaron,项目名称:w32,代码行数:11,代码来源:streambuf.cpp
示例17: sync
int sync() override {
std::ptrdiff_t n = pptr() - pbase();
int real_n = ::MultiByteToWideChar(CP_UTF8, 0, pbase(), n, 0, 0);
::MultiByteToWideChar(CP_UTF8, 0, pbase(), n, _console_temp.data(), real_n);
DWORD written;
::WriteConsoleW(_handle, _console_temp.data(), real_n, &written, NULL);
//::WriteConsoleA(_handle, pbase(), n, &written, NULL);
assert(written == real_n);
pbump(-n);
return 0;
}
开发者ID:WarlockD,项目名称:Cocos2dx-Undertale-Engine,代码行数:11,代码来源:console.cpp
示例18: epptr
inline typename basic_dbgstreambuf<elem_t, traits_t>::int_type
basic_dbgstreambuf<elem_t, traits_t>::overflow(int_type c_)
{
if (traits_t::eq_int_type(traits_t::eof(), c_))
return traits_t::eof();
const elem_t c = traits_t::to_char_type(c_);
//sync();
//NOTE: No, we can't do this here, since dbgview will
//break the text across lines when the auto-scroll
//option is enabled.
const ptrdiff_t oldlen = epptr() - pbase();
const ptrdiff_t newlen = oldlen ? 2 * oldlen : 1;
if (elem_t* const newbuf = new (std::nothrow) elem_t[newlen + 1])
{
const std::streamsize pos = ppos();
#if _MSC_VER >= 1400
const size_t size_in_bytes = newlen * sizeof(elem_t);
traits_t::_Copy_s(newbuf, size_in_bytes, pbase(), pos);
#else
traits_t::copy(newbuf, pbase(), pos);
#endif
setp(newbuf, newbuf + pos, newbuf + newlen);
delete[] m_buf;
m_buf = newbuf;
*pptr() = c;
pbump(1);
return traits_t::not_eof(c_);
}
if (oldlen)
{
sync();
*pbase() = c;
pbump(1);
}
else
{
const elem_t str[2] = { c, elem_t() };
OutputDebugStringX(str);
}
return traits_t::not_eof(c_);
}
开发者ID:kazutomi,项目名称:xiphqt,代码行数:53,代码来源:dbgstreambuf.hpp
示例19: pbase
void Socket::setOutputBufferSize(std::streamsize n) {
if(pbase()) {
delete [] pbase();
setp(NULL, NULL);
}
if(n == 0) return;
if(type == TCP_SERVER)
throw Exception(Exception::BAD_TYPE);
char_type* writeBuffer = new char_type[n];
setp(writeBuffer, writeBuffer+n);
}
开发者ID:lbpinkston,项目名称:netLink,代码行数:12,代码来源:Socket.cpp
示例20: pptr
int
impl::systembuf::sync(void)
{
ssize_t cnt = pptr() - pbase();
bool ok;
ok = ::write(m_handle, pbase(), cnt) == cnt;
if (ok)
pbump(-cnt);
return ok ? 0 : -1;
}
开发者ID:AlexZhao,项目名称:freebsd,代码行数:12,代码来源:io.cpp
注:本文中的pbase函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论