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


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

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


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

示例1: out

Logger::Logger(ostream &out) : out(out.rdbuf())
{
    pthread_mutex_lock(&counterLock);
    threadCount++;
    pthread_mutex_unlock(&counterLock);
    
    clientPort = 0;
    
    if(threadCount==1)
    {
        if(pthread_attr_init(&threadAttr))
        {
            out<<"ERROR: Failed to initialize thread attribute"<<endl;
            return;
        }
    
        if(pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_JOINABLE))
        {
            out<<"ERROR: Failed to set detach state"<<endl;
            out<<"ERROR: Failed to allocate memory for LoggerImpl"<<endl;
            return;
        }
        
        //First ever Logger instance gets to start the log writing thread
        int ret = pthread_create(&thread, &threadAttr, logWriter, this);
        if(ret)
        {
            out<<"ERROR: Failed to start log printer thread. Error code: "<<strerror(ret)<<endl;
            threadCount = 0;
            return;
        }
    }
}
开发者ID:keithmendozasr,项目名称:flat8,代码行数:33,代码来源:logger.cpp

示例2: min

ostream&  __STL_CALL operator<<(ostream& __os,
                                const basic_string<_CharT,_Traits,_Alloc>& __s)
{
    __STL_USING_VENDOR_STD
    streambuf* __buf = __os.rdbuf();
    if (__buf) {
        size_t __n = __s.size();
        size_t __pad_len = 0;
        const bool __left = (__os.flags() & ios::left) !=0;
        const size_t __w = __os.width();

        if (__w > 0) {
            __n = min(__w, __n);
            __pad_len = __w - __n;
        }

        if (!__left)
            __sgi_string_fill(__os, __buf, __pad_len);

        const size_t __nwritten = __buf->sputn(__s.data(), __n);

        if (__left)
            __sgi_string_fill(__os, __buf, __pad_len);

        if (__nwritten != __n)
            __os.clear(__os.rdstate() | ios::failbit);

        __os.width(0);
    }
    else
        __os.clear(__os.rdstate() | ios::badbit);

    return __os;
}
开发者ID:rickyharis39,项目名称:nolf2,代码行数:34,代码来源:_string_io.c

示例3: redirect

void redirect (ostream& strm)
{
    ofstream file("redirect.txt");
    
    // save output buffer of the stream
    streambuf* strm_buffer = strm.rdbuf();

    // redirect ouput into the file
    strm.rdbuf (file.rdbuf());

    file << "one row for the file" << endl;
    strm << "one row for the stream" << endl;

    // restore old output buffer
    strm.rdbuf (strm_buffer);

}    // closes file AND its buffer automatically
开发者ID:blueunix,项目名称:cppcode,代码行数:17,代码来源:iostreamTest.cpp

示例4: redirect

void redirect (ostream& strm)
{
    // save output buffer of the stream
    // - use unique pointer with deleter that ensures to restore
    //     the original output buffer at the end of the function
    auto del = [&](streambuf* p) {
                   strm.rdbuf(p);
               };
    unique_ptr<streambuf,decltype(del)> origBuffer(strm.rdbuf(),del);

    // redirect ouput into the file redirect.txt
    ofstream file("redirect.txt");
    strm.rdbuf (file.rdbuf());

    file << "one row for the file" << endl;
    strm << "one row for the stream" << endl;
} // closes file AND its buffer automatically
开发者ID:Heuristack,项目名称:Productivity,代码行数:17,代码来源:streamredirect1.cpp

示例5: ostream

 SVOutStream::SVOutStream(ostream& out, const String& sep,
                          const String& replacement,
                          String::QuotingMethod quoting) :
   ostream(out.rdbuf()), sep_(sep), replacement_(replacement), nan_("nan"),
   inf_("inf"), quoting_(quoting), modify_strings_(true), newline_(true)
 {
   // use high decimal precision (appropriate for double):
   precision(std::numeric_limits<double>::digits10);
 }
开发者ID:BioITer,项目名称:OpenMS,代码行数:9,代码来源:SVOutStream.C

示例6:

bool
ios_base::sync_with_stdio(bool sync)
{
    static ios_base::Init  __make_sure_streams_are_constructed;
    static bool previous_sync = true;
    bool result = previous_sync;
    previous_sync = sync;
    cin.rdbuf()->pubsetbuf(0, !sync);
    cout.rdbuf()->pubsetbuf(0, !sync);
    clog.rdbuf()->pubsetbuf(0, !sync);
    cerr.rdbuf()->pubsetbuf(0, !sync);
#ifndef _EWL_NO_WCHART_CPP_SUPPORT
    wcin.rdbuf()->pubsetbuf(0, !sync);
    wcout.rdbuf()->pubsetbuf(0, !sync);
    wclog.rdbuf()->pubsetbuf(0, !sync);
    wcerr.rdbuf()->pubsetbuf(0, !sync);
#endif  // _EWL_NO_WCHART_CPP_SUPPORT
    return result;
}
开发者ID:reynoldsbd3,项目名称:robot-d5,代码行数:19,代码来源:ios.cpp

示例7: genLineDirective

void genLineDirective( ostream &out )
{
	std::streambuf *sbuf = out.rdbuf();
	output_filter *filter = static_cast<output_filter*>(sbuf);
	lineDirective( out, filter->fileName, filter->line + 1 );
}
开发者ID:Mirocow,项目名称:balancer,代码行数:6,代码来源:fsmcodegen.cpp

示例8:

 ostream::ostream(ostream const& rhs)
 :   std::ios(0), base_type(rhs.rdbuf()), impl_(rhs.impl_)
 {
     this->copyfmt(rhs);
     this->clear(rhs.rdstate());
 }
开发者ID:saga-project,项目名称:saga-cpp,代码行数:6,代码来源:ostream.cpp

示例9: print_stream

// Threadsafe print a given stream.
void print_stream(ostream &strng)
{
	cout << strng.rdbuf();
	cout.flush();
	strng.clear();
}
开发者ID:bsanders,项目名称:threadify,代码行数:7,代码来源:threadify.cpp

示例10: CheckInit

void
Redirect( ostream& from, ostream& to )
{
  CheckInit();
  from.rdbuf( to.rdbuf() );
}
开发者ID:ACrazyer,项目名称:NeuralSystemsBCI2000,代码行数:6,代码来源:RedirectIO.cpp

示例11:

	    StreamBuf_Swapper(ostream & orig, ostream & replacement)
		          : buf_(orig.rdbuf()), str_(orig)
	    {
	        orig.rdbuf(replacement.rdbuf());
	    }
开发者ID:IsCoolEntertainment,项目名称:debpkg_graphviz,代码行数:5,代码来源:gvrender_lasi.cpp

示例12:

void
Nav2Logging::deleteHandlers(ostream& logStream)
{
   if (dynamic_cast<LogBuffer*>(logStream.rdbuf()) != NULL)
      static_cast<LogBuffer*>(logStream.rdbuf())->deleteHandlers();
}
开发者ID:FlavioFalcao,项目名称:Wayfinder-CppCore-v2,代码行数:6,代码来源:Nav2Logging.cpp


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