本文整理汇总了C++中rdbuf函数的典型用法代码示例。如果您正苦于以下问题:C++ rdbuf函数的具体用法?C++ rdbuf怎么用?C++ rdbuf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rdbuf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rdbuf
char * SQLQuery::preview_char() {
*this << ends;
#ifdef __USLC__
strstreambuf *tmpbuf = rdbuf();
uint length = tmpbuf->pcount();
#else
uint length = pcount();
#endif
char *s = new char[length+1];
get(s, length, '\0');
seekg (0,ios::beg);
seekp (-1,ios::cur);
return s;
}
示例2: CHECK_M
void ifstream::close() {
if (!is_open()) {
return;
}
CHECK_M(m_filterDepth == 0, "Filters still attached to file!");
filters::streamfilter *handle =
dynamic_cast< filters::streamfilter * >(rdbuf());
filters::streamfilter *filebuf =
dynamic_cast< filters::streamfilter * >(handle->getNext());
CHECK(vfs::close(filebuf));
handle->chain(nullptr, std::ios::in);
}
示例3: basic_compressor_ostream
explicit basic_compressor_ostream(
ostream_reference ostream_,
int open_mode = std::ios::out,
size_t level_ = Z_DEFAULT_COMPRESSION,
EStrategy strategy_ = DefaultStrategy,
size_t window_size_ = 15,
size_t memory_level_ = 8,
size_t buffer_size_ = default_buffer_size
)
:
zip_ostreambase_type(ostream_,level_,strategy_,window_size_,memory_level_,buffer_size_),
ostream_type(rdbuf(),open_mode )
{
};
示例4: __lock_it
void fstreambase::setbuf( char *buf, int len ) {
filebuf *fb;
__lock_it( __i_lock );
fb = rdbuf();
if( fb == NULL ) {
setstate( ios::failbit );
} else {
__lock_it( fb->__b_lock );
if( fb->setbuf( buf, len ) == NULL ) {
setstate( ios::failbit );
}
}
}
示例5: __lock_it
ostream &ostream::write( char const *buf, int len ) {
/***************************************************/
// Write a sequence of characters to the ostream.
__lock_it( __i_lock );
if( opfx() ) {
if( len ) {
if( rdbuf()->sputn( buf, len ) != len ) {
setstate( ios::failbit );
}
}
osfx();
}
return( *this );
}
示例6: rdbuf
/*--------------------------------------------------------------istream::read-+
| |
+----------------------------------------------------------------------------*/
istream & istream::read(char * buf, int n)
{
_M_gcount = 0;
if (n > 0) {
streambuf * sb = rdbuf();
do {
int c = sb->sbumpc();
if (c == EOF) {
setstate(ios::eofbit | ios::failbit);
break;
}
*buf++ = c;
}while (++_M_gcount < n);
}
return *this;
}
示例7: __lock_it
ostream &ostream::operator << ( char c ) {
/****************************************/
// Write a single character to the stream.
__lock_it( __i_lock );
if( opfx() ) {
if( width() == 0 ) {
if( rdbuf()->sputc( c ) == EOF ) {
setstate( ios::failbit );
}
} else {
do_lshift( c );
}
osfx();
}
return( *this );
}
示例8: __lock_it
void fstreambase::attach( filedesc fd ) {
filebuf *fb;
__lock_it( __i_lock );
fb = rdbuf();
if( fb == NULL ) {
setstate( ios::failbit );
} else {
__lock_it( fb->__b_lock );
if( fb->attach( fd ) == NULL ) {
setstate( ios::failbit );
} else {
clear();
}
}
}
示例9: __lock_it
void fstreambase::open( char const *name, ios::openmode mode, int prot ) {
filebuf *fb;
__lock_it( __i_lock );
fb = rdbuf();
if( fb == NULL ) {
setstate( ios::failbit );
} else {
__lock_it( fb->__b_lock );
if( fb->open( name, mode, prot ) == NULL ) {
setstate( ios::failbit );
} else {
clear();
}
}
}
示例10: while
/*---------------------------------------------------------------istream::get-+
| |
+----------------------------------------------------------------------------*/
istream & istream::get(char * s, streamsize n, char delim)
{
char * c_p = s;
if (n) {
int c;
while ((--n > 0) && ((EOF != (c=get())) && (c!=delim))) {
*c_p++ = (char)c;
}
*c_p = '\0';
if (c == delim) {
rdbuf()->sputbackc(c);
}else if (c==EOF) {
setstate(ios::eofbit); // clear failbit
}
}
_M_gcount = c_p - s;
return *this;
}
示例11: NCBI_THROW
void CConn_MemoryStream::ToVector(vector<char>* vec)
{
if (!vec) {
NCBI_THROW(CIO_Exception, eInvalidArg,
"CConn_MemoryStream::ToVector(NULL) is not allowed");
}
CConn_Streambuf* sb = dynamic_cast<CConn_Streambuf*>(rdbuf());
size_t size = sb && good() ? (size_t)(tellp() - tellg()) : 0;
vec->resize(size);
if (sb) {
size_t s = (size_t) sb->sgetn(&(*vec)[0], size);
#ifdef NCBI_COMPILER_WORKSHOP
if (s < 0) {
s = 0; // WS6 weirdness to sometimes return -1 from sgetn() :-/
} else
#endif //NCBI_COMPILER_WORKSHOP
_ASSERT(s == size);
vec->resize(s); // NB: just in case, essentially NOOP when s == size
}
}
示例12: clsCompressedStreamBuff
void clsCompressedOutputStream::open(const std::string &_name, bool _allowFail)
{
if (this->Buffer)
delete this->Buffer;
if ((_name.rfind(".gz") == _name.length() - 3) || (_name.rfind(".Z") == _name.length() - 3)) {
clsCompressedStreamBuff *CompressedBuff = new clsCompressedStreamBuff();
if (!CompressedBuff->open(_name, std::ios::out)) {
if (!_allowFail)
throw exTargomanBase("Could not open " + QString::fromStdString(_name) + " for writing");
setstate(std::ios::failbit);
}
this->Buffer = CompressedBuff;
} else if (_name == "-") {
this->Buffer = std::cout.rdbuf();
} else {
std::filebuf *FileBbuf = new std::filebuf();
if (!FileBbuf->open(_name.c_str(), std::ios::out)) setstate(std::ios::failbit);
this->Buffer = FileBbuf;
}
rdbuf(Buffer);
}
示例13: __lock_it
int istream::get() {
/******************/
// Extract a single character from the input stream.
// Don't set ios::failbit.
int c = EOF;
__lock_it( __i_lock );
if( ipfx( 1 ) ) {
c = rdbuf()->sgetchar();
if( c == EOF ) {
setstate( ios::eofbit );
__last_read_length = 0;
} else {
__last_read_length = 1;
}
isfx();
} else {
__last_read_length = 0;
}
return( c );
}
示例14: mpStreambuf
/**
* Logstream constructor
*/
LogStream::LogStream( std::ostream *pConsoleStream,
std::ofstream *pFileStream )
: std::ios( 0 ),
std::ostream( new DebugStreambuf<char> ),
mpStreambuf( NULL ),
mpConsoleStream( pConsoleStream ),
mpFileStream( pFileStream )
{
// i really don't like having to do this
mpStreambuf = dynamic_cast<DebugStreambuf<char>* >( rdbuf() );
ASSERT_MSG( mpStreambuf != NULL, "Something really evil just happened" );
// Assign the output streams to our internal debug stream
if ( pConsoleStream != NULL )
{
mpStreambuf->setConsole( pConsoleStream->rdbuf() );
}
if ( pFileStream != NULL )
{
mpStreambuf->setFile( pFileStream->rdbuf() );
}
}
示例15: error
/**
* @return An \c error_code corresponding to the last error from the stream.
*
* @par Example
* To print the error associated with a failure to establish a connection:
* @code tcp::iostream s("www.boost.org", "http");
* if (!s)
* {
* std::cout << "Error: " << s.error().message() << std::endl;
* } @endcode
*/
const boost::system::error_code& error() const
{
return rdbuf()->puberror();
}