本文整理汇总了C++中Ostream::flags方法的典型用法代码示例。如果您正苦于以下问题:C++ Ostream::flags方法的具体用法?C++ Ostream::flags怎么用?C++ Ostream::flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ostream
的用法示例。
在下文中一共展示了Ostream::flags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: singleFmt
void Foam::UList<double>::writeNonUniform(Ostream& os) const
{
//Pout<< "width:" << os.width() << endl;
//Pout<< "precision:" << os.precision() << endl;
//Pout<< "fmtflags:" << os.flags() << endl;
//Pout<< "boolalpha:" << (os.flags() & ios_base::boolalpha) << endl;
//Pout<< "showbase:" << (os.flags() & ios_base::showbase) << endl;
//Pout<< "showpoint:" << (os.flags() & ios_base::showpoint) << endl;
//Pout<< "showpos:" << (os.flags() & ios_base::showpos) << endl;
//Pout<< "skipws:" << (os.flags() & ios_base::skipws) << endl;
//Pout<< "unitbuf:" << (os.flags() & ios_base::unitbuf) << endl;
//Pout<< "uppercase:" << (os.flags() & ios_base::uppercase) << endl;
//
//Pout<< "dec:" << (os.flags() & ios_base::showbase) << endl;
//Pout<< "hex:" << (os.flags() & ios_base::hex) << endl;
//Pout<< "oct:" << (os.flags() & ios_base::oct) << endl;
//
//Pout<< "fixed:" << (os.flags() & ios_base::fixed) << endl;
//Pout<< "scientific:" << (os.flags() & ios_base::scientific) << endl;
//
//Pout<< "internal:" << (os.flags() & ios_base::internal) << endl;
//Pout<< "left:" << (os.flags() & ios_base::left) << endl;
//Pout<< "right:" << (os.flags() & ios_base::right) << endl;
const Foam::UList<double>& L = *this;
// Write size and start delimiter
os << nl << L.size() << nl << token::BEGIN_LIST;
if
(
(os.width() == 0)
&& !(os.flags() & ios_base::showbase)
&& !(os.flags() & ios_base::showpoint)
&& !(os.flags() & ios_base::showpos)
&& !(os.flags() & ios_base::unitbuf)
&& !(os.flags() & ios_base::uppercase)
&& !(os.flags() & ios_base::hex)
&& !(os.flags() & ios_base::oct)
&& !(os.flags() & ios_base::fixed)
&& !(os.flags() & ios_base::scientific)
&& !(os.flags() & ios_base::internal)
&& !(os.flags() & ios_base::right)
&& isA<OFstream>(os)
)
{
OFstream& ofs = dynamic_cast<OFstream&>(os);
// Can do optimised
Pout<< "Optimised" << endl;
const string singleFmt("\n%-." + Foam::name(ofs.precision()) + "lg");
string fmt;
for (int i = 0; i < 8; i++)
{
fmt += singleFmt;
}
//Pout<< "Format string:" << fmt << endl;
const char* fmt_ptr = fmt.c_str();
const int bufLen = 4096;
char buf[bufLen];
int free = 0;
label i = 0;
for (label outer = 0; outer < L.size()/8; outer++)
{
const int nFree = bufLen-free;
int n = snprintf
(
&buf[free],
nFree,
fmt_ptr,
L[i],
L[i+1],
L[i+2],
L[i+3],
L[i+4],
L[i+5],
L[i+6],
L[i+7]
);
if (n >= nFree)
{
// Failed. Flush buffer so far
ofs.stdStream().write(buf, free);
free = 0;
// Re-print current entry (assume it succeeds)
n = snprintf
(
&buf[free],
bufLen-free,
fmt_ptr,
L[i],
L[i+1],
L[i+2],
L[i+3],
L[i+4],
L[i+5],
L[i+6],
L[i+7]
//.........这里部分代码省略.........
示例2: sFmt
void Foam::UList<Foam::Vector<double>>::writeNonUniform(Ostream& os) const
{
//Pout<< "width:" << os.width() << endl;
//Pout<< "precision:" << os.precision() << endl;
//Pout<< "fmtflags:" << os.flags() << endl;
//Pout<< "boolalpha:" << (os.flags() & ios_base::boolalpha) << endl;
//Pout<< "showbase:" << (os.flags() & ios_base::showbase) << endl;
//Pout<< "showpoint:" << (os.flags() & ios_base::showpoint) << endl;
//Pout<< "showpos:" << (os.flags() & ios_base::showpos) << endl;
//Pout<< "skipws:" << (os.flags() & ios_base::skipws) << endl;
//Pout<< "unitbuf:" << (os.flags() & ios_base::unitbuf) << endl;
//Pout<< "uppercase:" << (os.flags() & ios_base::uppercase) << endl;
//
//Pout<< "dec:" << (os.flags() & ios_base::showbase) << endl;
//Pout<< "hex:" << (os.flags() & ios_base::hex) << endl;
//Pout<< "oct:" << (os.flags() & ios_base::oct) << endl;
//
//Pout<< "fixed:" << (os.flags() & ios_base::fixed) << endl;
//Pout<< "scientific:" << (os.flags() & ios_base::scientific) << endl;
//
//Pout<< "internal:" << (os.flags() & ios_base::internal) << endl;
//Pout<< "left:" << (os.flags() & ios_base::left) << endl;
//Pout<< "right:" << (os.flags() & ios_base::right) << endl;
const Foam::UList<Vector<double>>& L = *this;
// Write size and start delimiter
os << nl << L.size() << nl << token::BEGIN_LIST;
if
(
(os.width() == 0)
&& !(os.flags() & ios_base::showbase)
&& !(os.flags() & ios_base::showpoint)
&& !(os.flags() & ios_base::showpos)
&& !(os.flags() & ios_base::unitbuf)
&& !(os.flags() & ios_base::uppercase)
&& !(os.flags() & ios_base::hex)
&& !(os.flags() & ios_base::oct)
&& !(os.flags() & ios_base::fixed)
&& !(os.flags() & ios_base::scientific)
&& !(os.flags() & ios_base::internal)
&& !(os.flags() & ios_base::right)
&& isA<OFstream>(os)
)
{
OFstream& ofs = dynamic_cast<OFstream&>(os);
// Can do optimised
Pout<< "Optimised" << endl;
const string sFmt("%-." + Foam::name(ofs.precision()) + "lg");
string fmt("\n("+sFmt+' '+sFmt+' '+sFmt+')');
Pout<< "Format string:" << fmt << endl;
const char* fmt_ptr = fmt.c_str();
const int bufLen = 4096;
char buf[bufLen];
int free = 0;
forAll(L, i)
{
const Vector<double>& p = L[i];
const int nFree = bufLen-free;
int n = snprintf(&buf[free], nFree, fmt_ptr, p.x(), p.y(), p.z());
if (n >= nFree)
{
ofs.stdStream().write(buf, free);
free = 0;
// Re-print current entry
n = snprintf(&buf[free], bufLen, fmt_ptr, p.x(), p.y(), p.z());
}
free += n;
}
if (free > 0)
{
ofs.stdStream().write(buf, free);
}
}