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


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

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


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

示例1: 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

示例2: state

void Foam::state(ostream& to, const string& s)
{
    state_value osState = state_value(to.rdstate());

    switch (osState)
    {
        case _good:                // Do not anything 'unusual'.
            break;

        case _eof:
            Info
                << "Output stream: premature end of stream", s << endl;
        break;

        case _fail:
            SeriousErrorIn("state(ostream& to, const string& s)")
                << "Output stream failure (bad format?)", s << endl;
        break;

        case (_fail + _eof) :
         SeriousErrorIn("state(ostream& to, const string& s)")
             << "Output stream failure and end of stream", s << endl;
        break;

        case _bad:
            SeriousErrorIn("state(ostream& to, const string& s)")
                << "Serious output stream failure", s << endl;
        break;

        default:
            SeriousErrorIn("state(ostream& to, const string& s)")
                << "Output stream failure of unknown type", s << endl
                << "Stream state value = ", osState << endl;
        break;
    }

    return;
}
开发者ID:TsukasaHori,项目名称:openfoam-extend-foam-extend-3.1,代码行数:38,代码来源:state.C

示例3:

 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


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