当前位置: 首页>>代码示例>>C++>>正文


C++ ostream::rdbuf方法代码示例

本文整理汇总了C++中std::ostream::rdbuf方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::rdbuf方法的具体用法?C++ ostream::rdbuf怎么用?C++ ostream::rdbuf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::ostream的用法示例。


在下文中一共展示了ostream::rdbuf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: swapstdout

void swapstdout(std::ostream& buf)
{
    // Switch the stream buffer with std::cout, which is used by Print.
    std::streambuf* cout_strbuf(std::cout.rdbuf());
    std::cout.rdbuf(buf.rdbuf());
    buf.rdbuf(cout_strbuf);
}
开发者ID:cfarrow,项目名称:pyobjcryst,代码行数:7,代码来源:helpers.cpp

示例2:

BufferStream::BufferStream(std::ostream &stream, QByteArray &buffer)
    : stream_(stream)
    , outputBuffer_(buffer)
{
    oldBuffer_ = stream.rdbuf();
    stream.rdbuf(this);
}
开发者ID:mvasilkov,项目名称:fefu-mmorpg,代码行数:7,代码来源:DebugStream.cpp

示例3: StreamRedirect

 StreamRedirect( std::ostream& stream, std::string& targetString )
 :   m_stream( stream ),
     m_prevBuf( stream.rdbuf() ),
     m_targetString( targetString )
 {
     stream.rdbuf( m_oss.rdbuf() );
 }
开发者ID:1611714,项目名称:TCTI-V1OOPC-15-BASE,代码行数:7,代码来源:catch_run_context.hpp

示例4: redirect

    /**
      Redirect a stream to some other stream, by default a null stream.

      \param out   Stream to redirect.
      \param dst   Destination stream.
      \return  Context for stream restoration (see \ref restore()).
    */
    inline RedirectStream redirect(std::ostream& out, std::ostream& dst)
    {
        RedirectStream redir;

        redir.m_buf = out.rdbuf();
        out.rdbuf(dst.rdbuf());
        return redir;
    }
开发者ID:PDAL,项目名称:PDAL,代码行数:15,代码来源:Utils.hpp

示例5: printCurrentOrderBook

void Reporter::printCurrentOrderBook(std::ostream& os) const
{
    StrStream strstream;
    auto cap = strstream.capacity() - 128;
    const auto nbBids = bids_.size();
    const auto nbAsks = asks_.size();
    os << "Full Bids/Asks:\n";
    auto i = 0U;
    while (1)
    {
        StrStream strstream_tmp;
        if (i < nbBids)
        {
            Limit bid = bids_[i];
            strstream_tmp << i; 
            strstream_tmp.append(6, ' ');
            strstream_tmp << ": " << getQty(bid) << " @ " << getPrice(bid);
            strstream_tmp.append(40, ' ');
            if (i < nbAsks)
            {
                Limit ask = asks_[i];
                strstream_tmp << getQty(ask) << " @ " << getPrice(ask) << '\n';
            }
            else
            {
                strstream_tmp << "empty\n";
            }
        }
        else
        {
            strstream_tmp << i;
            strstream_tmp.append(6, ' ');
            strstream_tmp << ": empty";
            strstream_tmp.append(40, ' ');
            if (i < nbAsks)
            {
                Limit ask = asks_[i];
                strstream_tmp << getQty(ask) << " @ " << getPrice(ask) << '\n';
            }
            else
            {
                strstream << strstream_tmp;
                strstream << "empty\n";
                break;
            }
        }

        if (strstream.length() + strstream_tmp.length() > cap)
        {
            os.rdbuf()->sputn(strstream.c_str(), strstream.length());
            strstream.clear();
        }
        strstream << strstream_tmp;
        ++i;
    }
    os.rdbuf()->sputn(strstream.c_str(), strstream.length());
    os.flush();
}
开发者ID:bgn9000,项目名称:Cpp1y-OrderBook,代码行数:58,代码来源:Reporter.cpp

示例6: set

    void set(std::istream& in, std::ostream& out, std::ostream& err) {
      if (not activated) {
	using namespace std;
	in_buf = cin.rdbuf(); out_buf = cout.rdbuf(); err_buf = cerr.rdbuf();
	in_state = cin.rdstate(); out_state = cin.rdstate(); err_state = cerr.rdstate();
	cin.rdbuf(in.rdbuf()); cout.rdbuf(out.rdbuf()); cerr.rdbuf(err.rdbuf());
	cin.exceptions(ios_base::goodbit); cout.exceptions(ios_base::goodbit); cerr.exceptions(ios_base::goodbit);
	cin.clear(in.rdstate()); cout.clear(out.rdstate()); cerr.clear(err.rdstate());
      }
    }
开发者ID:PJames,项目名称:oklibrary,代码行数:10,代码来源:StreamHandling.hpp

示例7:

nc_window_streambuf::nc_window_streambuf(WINDOW* _p, std::ostream& _os, unsigned long _cursesAttr):
	m_pnl(_p),
	m_flags(_cursesAttr),
	m_os(&_os),
	m_old(_os.rdbuf())
{
	setp(0, 0);
	setg(0, 0, 0);
	_os.rdbuf(this);
	scrollok(_p, true);
	mvwinch(_p, 0, 0);
}
开发者ID:LefterisJP,项目名称:cpp-ethereum,代码行数:12,代码来源:main.cpp

示例8: setp

reset_level_buf::reset_level_buf(std::ostream& Stream) :
    m_stream(Stream),
    m_streambuf(Stream.rdbuf())
{
    setp(0, 0);
    m_stream.rdbuf(this);
}
开发者ID:karstenda,项目名称:aqsis,代码行数:7,代码来源:logging.cpp

示例9: GZIPOutputStreambuf

/** \brief Create a ZIP output stream object.
 *
 * This constructor creates a zip stream from an existing standard
 * output stream.
 *
 * \warning
 * You must keep the output stream valid for as long as this object
 * exists (although this object close() function can be used to close
 * the \p os stream.)
 *
 * \param[in,out] os  ostream to which the compressed zip archive is written.
 * \param[in] compression_level  The compression level to use to compress.
 */
GZIPOutputStream::GZIPOutputStream(std::ostream& os, FileEntry::CompressionLevel compression_level)
    : std::ostream( nullptr )
    //, m_ofs(nullptr) -- auto-init
    , m_ozf(new GZIPOutputStreambuf(os.rdbuf(), compression_level))
{
    init(m_ozf.get());
}
开发者ID:pgquiles,项目名称:zipios,代码行数:20,代码来源:gzipoutputstream.cpp

示例10: writeNode

        virtual WriteResult writeNode( const osg::Node& node, std::ostream& fOut, const Options* options ) const
        {
            // Convert Options to FltOptions.
            ExportOptions* fltOpt = new ExportOptions( options );
            fltOpt->parseOptionsString();

            // If user didn't specify a temp dir, use the output directory
            //   that was implicit in the output file name.
            if (fltOpt->getTempDir().empty())
                fltOpt->setTempDir( _implicitPath );
            if (!fltOpt->getTempDir().empty())
            {
                // If the temp directory doesn't already exist, make it.
                if ( !osgDB::makeDirectory( fltOpt->getTempDir() ) )
                {
                    osg::notify( osg::FATAL ) << "fltexp: Error creating temp dir: " << fltOpt->getTempDir() << std::endl;
                    return WriteResult::ERROR_IN_WRITING_FILE;
                }
            }

            flt::DataOutputStream dos( fOut.rdbuf(), fltOpt->getValidateOnly() );
            flt::FltExportVisitor fnv( &dos, fltOpt );

            // Hm. 'node' is const, but in order to write out this scene graph,
            //   must use Node::accept() which requires 'node' to be non-const.
            //   Pretty much requires casting away const.
            osg::Node* nodeNonConst = const_cast<osg::Node*>( &node );
            if (!nodeNonConst)
                return WriteResult::ERROR_IN_WRITING_FILE;
            nodeNonConst->accept( fnv );
            fnv.complete( node );

            return fltOpt->getWriteResult();
        }
开发者ID:BlitzMaxModules,项目名称:osg.mod,代码行数:34,代码来源:ReaderWriterFLT.cpp

示例11:

Logger::Logger( std::ostream& str ):
    _logLevel( Warning ),
    _displayFilePosition( true ),
    _out( str.rdbuf() )
{

}
开发者ID:hjanetzek,项目名称:SFCGAL,代码行数:7,代码来源:Log.cpp

示例12: printMidQuotesAndTrades

void Reporter::printMidQuotesAndTrades(std::ostream& os, Errors& errors)
{
    StrStream strstream;
    if (unlikely(bids_.begin() == bids_.end() || asks_.begin() == asks_.end()))
    {
        strstream << "NAN" << '\n';
    }
    else if (receivedNewTrade_)
    {
        strstream << getQty(currentTrade_) << '@' << getPrice(currentTrade_) << '\n';
        receivedNewTrade_ = false;
        detectCross_ = false;
    }
    else if (unlikely(getPrice(*bids_.begin()) >= getPrice(*asks_.begin())))
    {
        if (likely(!detectCross_)) detectCross_ = true;
        else
        {
            strstream << "Cross BID (" << getPrice(*bids_.begin()) <<  ")/ASK(" << getPrice(*asks_.begin()) << ')' << '\n';
            ++errors.bestBidEqualOrUpperThanBestAsk;
        }
    }
    else
    {
        Price midQuote = (getPrice(*bids_.begin())+getPrice(*asks_.begin()))/2;
        strstream << midQuote << '\n';
    }
    os.rdbuf()->sputn(strstream.c_str(), strstream.length());
    os.flush();
}
开发者ID:bgn9000,项目名称:Cpp1y-OrderBook,代码行数:30,代码来源:Reporter.cpp

示例13:

gzostream::gzostream( std::ostream & dest,
                      unsigned int buffer_size )
    : std::ostream( static_cast< std::streambuf * >( 0 ) )
    , M_gzstreambuf( *(dest.rdbuf()), buffer_size )
{
    this->init( &M_gzstreambuf );
}
开发者ID:edymanoloiu,项目名称:FotbalRobotic,代码行数:7,代码来源:gzstream.cpp

示例14: ostream

GZIPOutputStream::GZIPOutputStream( std::ostream &os )
    : ostream( 0 ),
      ofs( 0 )
{
    ozf = new GZIPOutputStreambuf( os.rdbuf() ) ;

    init( ozf ) ;
}
开发者ID:WaterBlade,项目名称:FreeCAD_sf_master,代码行数:8,代码来源:gzipoutputstream.cpp

示例15: restore

    /**
      Restore a stream redirected with redirect().

      \param out  Stream to be restored.
      \param redir RedirectStream returned from corresponding
        \ref redirect() call.
    */
    inline void restore(std::ostream& out, RedirectStream& redir)
    {
        out.rdbuf(redir.m_buf);
        if (redir.m_out)
            redir.m_out->close();
        redir.m_out = NULL;
        redir.m_buf = NULL;
    }
开发者ID:PDAL,项目名称:PDAL,代码行数:15,代码来源:Utils.hpp


注:本文中的std::ostream::rdbuf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。