本文整理汇总了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;
}
示例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;
}
示例3:
ostream::ostream(ostream const& rhs)
: std::ios(0), base_type(rhs.rdbuf()), impl_(rhs.impl_)
{
this->copyfmt(rhs);
this->clear(rhs.rdstate());
}