本文整理汇总了C++中std::ostream::flags方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::flags方法的具体用法?C++ ostream::flags怎么用?C++ ostream::flags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ostream
的用法示例。
在下文中一共展示了ostream::flags方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print_vector4f_col
void print_vector4f_col(std::ostream& os, const cml::vector4f& vec, int prec = 4, int width = 8)
{
std::ios::fmtflags old_flags = os.flags();
os.setf(ios::left, ios::adjustfield);
os << std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< vec[0] << ' ' << std::endl
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< vec[1] << ' ' << std::endl
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< vec[2] << ' ' << std::endl
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< vec[3] << endl;
os.setf(old_flags);
}
示例2: print_matrix
void print_matrix(std::ostream& os, const cml::matrix44f& mat, int prec = 4, int width = 8)
{
std::ios::fmtflags old_flags = os.flags();
os.setf(ios::left, ios::adjustfield);
// row #1
os << std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(0, 0) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(0, 1) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(0, 2) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(0, 3) << endl;
// row #2
os << std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(1, 0) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(1, 1) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(1, 2) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(1, 3) << endl;
// row #3
os << std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(2, 0) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(2, 1) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(2, 2) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(2, 3) << endl;
// row #4
os << std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(3, 0) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(3, 1) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(3, 2) << ' '
<< std::setprecision(prec) << std::setw(width) << std::setfill(' ')
<< mat(3, 3) << endl;
os.setf(old_flags);
}
示例3: T
inline
void
arma_ostream::print_elem(std::ostream& o, const std::complex<T>& x, const bool modify)
{
if( (x.real() != T(0)) || (x.imag() != T(0)) || (modify == false) )
{
std::ostringstream ss;
ss.flags(o.flags());
//ss.imbue(o.getloc());
ss.precision(o.precision());
ss << '(';
const T a = x.real();
if(arma_isfinite(a))
{
ss << a;
}
else
{
ss << ( arma_isinf(a) ? ((a <= T(0)) ? "-inf" : "+inf") : "nan" );
}
ss << ',';
const T b = x.imag();
if(arma_isfinite(b))
{
ss << b;
}
else
{
ss << ( arma_isinf(b) ? ((b <= T(0)) ? "-inf" : "+inf") : "nan" );
}
ss << ')';
o << ss.str();
}
else
{
o << "(0,0)";
}
}
示例4: report
void Container::report(std::ostream& out) {
std::map<int, double> gpad;
std::map<int, int> gpan;
for (int i = 0; i < count; i++) {
gpan[p[i].group] = 0;
gpad[p[i].group] = 0;
}
for (int i = 0; i < count; i++)
{
gpan[p[i].group] = gpan[p[i].group] + 1;
gpad[p[i].group] = gpad[p[i].group] + (p[i].gpa - gpad[p[i].group]) / gpan[p[i].group];
}
out.flags(std::ios::left);
out << std::setw(10) << "√руппа" << std::setw(20) << "—редний балл" << "\n\n";
for (std::map<int, double>::iterator it = gpad.begin(); it != gpad.end(); ++it)
out << std::setw(10) << it->first << std::setw(20) << it->second << '\n';
}
示例5:
inline
void
arma_ostream::print_elem(std::ostream& o, const std::complex<T>& x, const bool modify)
{
if( (x.real() != T(0)) || (x.imag() != T(0)) || (modify == false) )
{
std::ostringstream ss;
ss.flags(o.flags());
//ss.imbue(o.getloc());
ss.precision(o.precision());
ss << '(' << x.real() << ',' << x.imag() << ')';
o << ss.str();
}
else
{
o << "(0,0)";
}
}
示例6: outFmtFlags
void outFmtFlags(std::ios_base::fmtflags fmtFlags, std::ostream& os, const char* term)
{ //! Output strings describing all bits in @c std::ios_base::fmtflags.
/*! @b Usage: @c outFmtFlags();
For example, by default outputs to @c std::cerr \n
\verbatim
FormatFlags: skipws showbase right dec."
\endverbatim
\n
Default parameter values are:\n
\code
void outFmtFlags(fmtflags fmtFlags = cout.flags(), ostream& os = cerr, const char* term = ".\n");
\endcode
*/
const int up = 16; // Words across page.
const int count = 16; // 16 because using unsigned short int (must be at least 16 bits).
std::ios_base::fmtflags flags = os.flags(); // Save to restore.
fmtFlags &= static_cast<std::ios_base::fmtflags>(0x7FFF); // _Fmtmask // clear un-used bits.
os << "IOS format flags (" << std::showbase << std::hex << fmtFlags << std::dec << ")" ; // hex value.
if (fmtFlags != 0)
{
for(int i = 0, j = 1, hit = 0; i < count; ++i)
{
if ((fmtFlags & j) != 0)
{
if (hit == 0)
{ // First word no separator.
os << ' ';
}
else
{
os << (( (hit % up) == 0) ? ",\n" : ", ");
}
os << fmtFlagWords[i];
++hit; // Count to add space or newline as appropriate.
}
j <<= 1;
}
}
os << term; // eg "\n" or ". "
os.setf(flags); // Restore.
} // outFmtFlags
示例7: SetScientificImpl
SetScientificImpl (std::ostream& out) :
out_ (out), originalFlags_ (out.flags())
{
typedef Teuchos::ScalarTraits<scalar_type> STS;
typedef typename STS::magnitudeType magnitude_type;
typedef Teuchos::ScalarTraits<magnitude_type> STM;
// Print floating-point values in scientific notation.
out << std::scientific;
// We're writing decimal digits, so compute the number of
// digits we need to get reasonable accuracy when reading
// values back in.
//
// There is actually an algorithm, due to Guy Steele (yes,
// Java's Guy Steele) et al., for idempotent printing of
// finite-length floating-point values. We should actually
// implement that algorithm, but I don't have time for that
// now. Currently, I just print no more than (one decimal
// digit more than (the number of decimal digits justified
// by the precision of magnitude_type)).
//
// We need to use STM's log10() rather than (say) std::log10
// here, because STM::base() returns a magnitude_type, not
// one of C++'s standard integer types.
const magnitude_type numDecDigits = STM::t() * STM::log10 (STM::base());
// Round and add one. The cast to int should not overflow
// unless STM::t() is _extremely_ large, so we don't need to
// check for that case here.
const magnitude_type one = STM::one();
const magnitude_type two = one + one;
// Cast from magnitude_type to int, since std::ostream's
// precision() method expects an int input.
const int prec = 1 + Teuchos::as<int> ((two*numDecDigits + one) / two);
// Set the number of (decimal) digits after the decimal
// point to print.
out.precision (prec);
}
示例8: write
void LVector::write(std::ostream& os, int maxorder) const
{
int oldprec = os.precision(8);
std::ios::fmtflags oldf = os.setf(std::ios::scientific,std::ios::floatfield);
if (maxorder < 0 || maxorder > _order)
maxorder = _order;
os << _order << std::endl;
for (int n=0; n<=maxorder; n++) {
for(PQIndex pq(n,0); !pq.needsConjugation(); pq.decm()) {
os << " " << std::setw(2) << pq.getP()
<< " " << std::setw(2) << pq.getQ() ;
if (pq.isReal()) {
os << " " << std::setw(15) << (*this)[pq].real() << std::endl;
} else {
os << " " << std::setw(15) << (*this)[pq].real()
<< " " << std::setw(15) << (*this)[pq].imag() << std::endl;
}
}
}
os.precision(oldprec);
os.flags(oldf);
}
示例9: runtime_error
void Terminal_std
::legend(std::ostream &stream) const
{
std::vector<const Reporter::group_t*> cols_groups;
for(auto& r : this->reporters)
if (r != nullptr)
for (auto& g : r->get_groups())
cols_groups.push_back(&g);
else
throw tools::runtime_error(__FILE__, __LINE__, __func__, "'this->reporters' contains null pointer.");
std::ios::fmtflags f(stream.flags());
// stream << "# " << "----------------------------------------------||---------------------------------" << std::endl; // line 1
// stream << "# " << " cols_groups[0].first.first || cols_groups[1].first.first " << std::endl; // line 2
// stream << "# " << " cols_groups[0].first.second || cols_groups[1].first.second " << std::endl; // line 3
// stream << "# " << "----------------------------------------------||---------------------------------" << std::endl; // line 4
// stream << "# " << "----------|-----------|-----------|-----------||----------|----------|-----------" << std::endl; // line 5
// stream << "# " << " (1.1) | (2.1) | (3.1) | (4.1) || (5.1) | (6.1) | (7.1) " << std::endl; // line 6
// stream << "# " << " (1.2) | (2.2) | (3.2) | (4.2) || (5.2) | (6.2) | (7.2) " << std::endl; // line 7
// stream << "# " << "----------|-----------|-----------|-----------||----------|----------|-----------" << std::endl; // line 8
// note (1.1) is "cols_groups[0].second[0].first"
// note (1.2) is "cols_groups[0].second[0].second"
// note (2.1) is "cols_groups[0].second[1].first"
// note (2.2) is "cols_groups[0].second[1].second"
// note (3.1) is "cols_groups[0].second[2].first"
// note (3.2) is "cols_groups[0].second[2].second"
// note (4.1) is "cols_groups[0].second[3].first"
// note (4.2) is "cols_groups[0].second[3].second"
// note (5.1) is "cols_groups[1].second[0].first"
// note (5.2) is "cols_groups[1].second[0].second"
// note (6.1) is "cols_groups[1].second[1].first"
// note (6.2) is "cols_groups[1].second[1].second"
// note (7.1) is "cols_groups[1].second[2].first"
// note (7.2) is "cols_groups[1].second[2].second"
assert(!cols_groups.empty());
// print line 1 of the table
stream << rang::tag::comment;
for (unsigned i = 0; i < cols_groups.size(); i++)
{
assert(!cols_groups[i]->second.empty());
const unsigned group_width = get_group_width(*cols_groups[i]);
const auto n_separators = group_width + extra_spaces(cols_groups[i]->first, group_width);
stream << legend_style << std::string(n_separators, line_separator) << rang::style::reset ;
if (i < (cols_groups.size() -1)) // print group separator except for last
stream << legend_style << group_separator << rang::style::reset ;
}
stream << std::endl;
// print line 2 and 3 of the table (group title lines)
for (auto l = 0; l < 2; l++)
{
stream << rang::tag::comment;
for (unsigned i = 0; i < cols_groups.size(); i++)
{
const auto& text = l == 0 ? cols_groups[i]->first.first : cols_groups[i]->first.second;
const unsigned group_width = get_group_width(*cols_groups[i]);
int n_spaces = (int)group_width - (int)text.size();
if (text.size() != std::max(cols_groups[i]->first.first.size(), cols_groups[i]->first.second.size()))
n_spaces += extra_spaces(cols_groups[i]->first, group_width);
const unsigned n_spaces_left = (n_spaces >= 0) ? (unsigned)n_spaces/2 : 0;
const unsigned n_spaces_right = (n_spaces >= 0) ? n_spaces - n_spaces_left : 0;
stream << legend_style << std::string(n_spaces_left, ' ') << rang::style::reset;
stream << legend_style << text << rang::style::reset;
stream << legend_style << std::string(n_spaces_right, ' ') << rang::style::reset;
if (i < (cols_groups.size() -1)) // print group separator except for last
stream << legend_style << group_separator << rang::style::reset;
}
stream << std::endl;
}
// print line 4 of the table
stream << rang::tag::comment;
for (unsigned i = 0; i < cols_groups.size(); i++)
{
const unsigned group_width = get_group_width(*cols_groups[i]);
const auto n_separators = group_width + extra_spaces(cols_groups[i]->first, group_width);
stream << legend_style << std::string(n_separators, line_separator) << rang::style::reset;
if (i < (cols_groups.size() -1)) // print group separator except for last
stream << legend_style << group_separator << rang::style::reset;
}
stream << std::endl;
// print line 5 of the table
stream << rang::tag::comment;
//.........这里部分代码省略.........
示例10: writeAttr
void MetadataWriter::writeAttr(std::ostream& out, TSK_INUM_T addr, const TSK_FS_ATTR* a) {
out << "{"
<< j("flags", attrFlags(a->flags), true)
<< j("id", a->id)
<< j("name", a->name ? std::string(a->name): std::string(""))
<< j("size", a->size)
<< j("type", a->type)
<< j("rd_buf_size", a->rd.buf_size)
<< j("nrd_allocsize", a->nrd.allocsize)
<< j("nrd_compsize", a->nrd.compsize)
<< j("nrd_initsize", a->nrd.initsize)
<< j("nrd_skiplen", a->nrd.skiplen);
if (a->flags & TSK_FS_ATTR_RES && a->rd.buf_size && a->rd.buf) {
out << ", " << j(std::string("rd_buf")) << ":\"";
std::ios::fmtflags oldFlags = out.flags();
out << std::hex << std::setfill('0');
size_t numBytes = std::min(a->rd.buf_size, (size_t)a->size);
for (size_t i = 0; i < numBytes; ++i) {
out << std::setw(2) << (unsigned int)a->rd.buf[i];
}
out.flags(oldFlags);
out << "\"";
}
if (a->flags & TSK_FS_ATTR_NONRES) {
out << ", \"nrd_runs\":[";
uint64_t fo = 0; // file offset
uint64_t slackFo = 0;
uint64_t skipBytes = a->nrd.skiplen; // up from 32 bits to 64 for convenience
const uint64_t mainSize = (a->flags & TSK_FS_ATTR_COMP) ? a->nrd.allocsize: a->nrd.initsize;
// if (addr == 3240) {
// std::cerr << "mainSize = " << mainSize << "\n";
// }
bool first = true;
for (TSK_FS_ATTR_RUN* curRun = a->nrd.run; curRun; curRun = curRun->next) {
if (TSK_FS_ATTR_RUN_FLAG_FILLER == curRun->flags) {
// TO-DO: check on the exact semantics of this flag
continue;
}
// normal case - make absolute offsets
uint64_t beg = (curRun->addr * Fs->block_size) + Fs->offset,
runEnd = beg + (curRun->len * Fs->block_size),
end = runEnd;
bool trueSlack = false;
// if (addr == 3240) {
// std::cerr << "beg = " << beg << ", end = " << end << ", len = " << (end - beg) << ", fo = " << fo << ", slackFo = " << slackFo << "\n";
// }
// if skipping, advance beg and decrement skipBytes accordingly
if (skipBytes > 0) { // still towards beginning where skiplen is > 0
uint64_t toSkip = std::min(end - beg, skipBytes);
beg += toSkip;
skipBytes -= toSkip;
}
if (beg < end) { // past skipping, we're onto data
uint64_t bytesRemaining = mainSize - fo; // how much data left in file stream?
if (beg + bytesRemaining < end) {
end = beg + bytesRemaining; // end is now beginning of true slack
trueSlack = true;
// if (3240 == addr) {
// std::cerr << "bytesRemaining = " << bytesRemaining << ", end now =" << end << "\n";
// }
}
if (beg < end) { // if false, we're fully into true slack, nothing of file left
if (TSK_FS_ATTR_RUN_FLAG_NONE == curRun->flags) {
// just normal data; sparse blocks will be made available as unallocated
markDataRun(beg, end, fo, addr, a->id, false);
}
fo += (end - beg); // advances fo even if data run is sparse, which is critical
}
if (trueSlack) {
// mark slack at end of allocated space
if (TSK_FS_ATTR_RUN_FLAG_NONE == curRun->flags) { // but only if not sparse (yes, could have sparse slack)
markDataRun(end, runEnd, slackFo, addr, a->id, true);
}
slackFo += (runEnd - end);
}
}
// output data run as json
if (!first) {
out << ", ";
}
out << "{"
<< j("addr", curRun->addr, true)
<< j("flags", curRun->flags)
<< j("len", curRun->len)
<< j("offset", curRun->offset)
<< "}";
first = false;
}
out << "]" << j("slack_size", slackFo);
}
out << "}";
}
示例11: timeTag
void
EncodeLocationForecast4::
encodePrecipitationPercentiles( const boost::posix_time::ptime &from,
std::ostream &ost,
miutil::Indent &indent )
{
WEBFW_USE_LOGGER( "encode" );
log4cpp::Priority::Value loglevel = WEBFW_GET_LOGLEVEL();
int hours[] = { 6, 12, 24 };
int n=sizeof( hours )/sizeof(hours[0]);
ptime fromTime;
ptime toTime;
bool first;
string prevProvider;
string provider;
ostringstream percentileOst;
ostringstream outOst;
percentileOst.flags( ost.flags() );
percentileOst.precision( ost.precision() );
outOst.flags( ost.flags() );
outOst.precision( ost.precision() );
for( int i=0; i<n; ++i ) {
if( ! locationData->init( from ) )
return;
prevProvider.erase();
first = true;
percentileOst.str("");
while( locationData->hasNext() ) {
LocationElem& location = *locationData->next();
if( ! percentileOst.str().empty() ) {
++nElements;
ost << outOst.str();
percentileOst.str("");
}
outOst.str("");
IndentLevel level3( indent );
provider = location.forecastprovider();
if( prevProvider != provider && loglevel >= log4cpp::Priority::DEBUG )
ost << level3.indent() << "<!-- Dataprovider: " << provider << " -->\n";
prevProvider = provider;
if( first ) {
if( loglevel >= log4cpp::Priority::DEBUG )
ost << level3.indent() << "<!-- PrecipPercentiles: " << hours[i] << " hours -->\n";
first = false;
}
toTime = location.time();
fromTime = toTime - boost::posix_time::hours( hours[i] );
TimeTag timeTag( fromTime, toTime );
timeTag.output( outOst, level3.indent() );
IndentLevel level4( indent );
LocationTag locationTag( latitude, longitude, altitude );
locationTag.output( outOst, level4.indent() );
IndentLevel level5( indent );
PrecipitationPercentileTags precipPercentileTag( location, hours[i] );
precipPercentileTag.output( percentileOst, level5.indent() );
if( ! percentileOst.str().empty() )
outOst << percentileOst.str();
}
//May have one left over.
if( ! percentileOst.str().empty() ) {
++nElements;
ost << outOst.str();
}
}
}
示例12: Flagger
Flagger(std::ostream& os) : os(os), flags(os.flags()) {}
示例13: zero
/*!
Pretty print a velocity twist matrix. The data are tabulated.
The common widths before and after the decimal point
are set with respect to the parameter maxlen.
\param s Stream used for the printing.
\param length The suggested width of each matrix element.
The actual width grows in order to accomodate the whole integral part,
and shrinks if the whole extent is not needed for all the numbers.
\param intro The introduction which is printed before the matrix.
Can be set to zero (or omitted), in which case
the introduction is not printed.
\return Returns the common total width for all matrix elements
\sa std::ostream &operator<<(std::ostream &s, const vpArray2D<Type> &A)
*/
int
vpVelocityTwistMatrix::print(std::ostream& s, unsigned int length, char const* intro) const
{
typedef std::string::size_type size_type;
unsigned int m = getRows();
unsigned int n = getCols();
std::vector<std::string> values(m*n);
std::ostringstream oss;
std::ostringstream ossFixed;
std::ios_base::fmtflags original_flags = oss.flags();
// ossFixed <<std::fixed;
ossFixed.setf ( std::ios::fixed, std::ios::floatfield );
size_type maxBefore=0; // the length of the integral part
size_type maxAfter=0; // number of decimals plus
// one place for the decimal point
for (unsigned int i=0;i<m;++i) {
for (unsigned int j=0;j<n;++j){
oss.str("");
oss << (*this)[i][j];
if (oss.str().find("e")!=std::string::npos){
ossFixed.str("");
ossFixed << (*this)[i][j];
oss.str(ossFixed.str());
}
values[i*n+j]=oss.str();
size_type thislen=values[i*n+j].size();
size_type p=values[i*n+j].find('.');
if (p==std::string::npos){
maxBefore=vpMath::maximum(maxBefore, thislen);
// maxAfter remains the same
} else{
maxBefore=vpMath::maximum(maxBefore, p);
maxAfter=vpMath::maximum(maxAfter, thislen-p-1);
}
}
}
size_type totalLength=length;
// increase totalLength according to maxBefore
totalLength=vpMath::maximum(totalLength,maxBefore);
// decrease maxAfter according to totalLength
maxAfter=std::min(maxAfter, totalLength-maxBefore);
if (maxAfter==1) maxAfter=0;
// the following line is useful for debugging
//std::cerr <<totalLength <<" " <<maxBefore <<" " <<maxAfter <<"\n";
if (intro) s <<intro;
s <<"["<<m<<","<<n<<"]=\n";
for (unsigned int i=0;i<m;i++) {
s <<" ";
for (unsigned int j=0;j<n;j++){
size_type p=values[i*n+j].find('.');
s.setf(std::ios::right, std::ios::adjustfield);
s.width((std::streamsize)maxBefore);
s <<values[i*n+j].substr(0,p).c_str();
if (maxAfter>0){
s.setf(std::ios::left, std::ios::adjustfield);
if (p!=std::string::npos){
s.width((std::streamsize)maxAfter);
s <<values[i*n+j].substr(p,maxAfter).c_str();
} else{
assert(maxAfter>1);
s.width((std::streamsize)maxAfter);
s <<".0";
}
}
s <<' ';
}
s <<std::endl;
}
//.........这里部分代码省略.........
示例14: CK_SyntaxError
/**
*
* Read species data from THERMO section records.
*
* @param names List of species names (input).
* @param species Table of species objects holding data from records
* in THERMO section (output).
* @param temp Devault vector of temperature region boundaries
* There are one more temperatures than there are
* temperature regions.
* @param allowExtThermoData True if 'THERMO' specified, false if
* 'THERMO ALL' specified.
*
* @return True, if the THERMO section exists and the species
* have all been successfully processed. False, if
* the THERMO section doesn't exist or there were
* additional problems.
*/
bool CKParser::readNASA9ThermoSection(std::vector<string>& names,
speciesTable& species, vector_fp& temp,
int& optionFlag, std::ostream& log) {
// String buffer for lines
string s;
vector<string> toks;
string defaultDate="";
int nreg = 2;
int i;
int nsp = static_cast<int>(names.size());
// Comment string
string comment;
// if "THERMO ALL" specified, or if optionFlag is set to HasTempRange,
// then the next line must be the default temperatures for the database.
//
// This line will have nreg+2 tokens on it
// The last token is a date.
if (0) {
if (optionFlag == NoThermoDatabase || optionFlag == HasTempRange) {
getCKLine(s, comment);
getTokens(s, static_cast<int>(s.size()), toks);
nreg = toks.size();
if (nreg >= 1) {
temp.resize(nreg+1);
for (i = 0; i <= nreg; i++) {
temp[i] = de_atof(toks[i]);
}
defaultDate = toks[nreg+1];
}
if (verbose) {
log.flags(ios::showpoint | ios::fixed);
log.precision(2);
log << endl << " Default # of temperature regions: " << nreg << endl;
log << " ";
for (i = 0; i <= nreg; i++) {
log << temp[i] << " ";
}
log << endl;
}
checkNASA9Temps(log, temp);
}
}
// Check to see that we expect to be reading a NASA9 formatted file
if (!m_nasa9fmt) {
throw CK_SyntaxError(log,
"In NASA9 parser. However, we expect a different file format",
-1);
}
// now read in all species records that have names in list 'names'
bool getAllSpecies = (nsp > 0 && match(names[0], "<ALL>"));
if (getAllSpecies) names.clear();
// Map between the number of times a species name appears in the database
map<string, int> dup; // used to check for duplicate THERMO records
bool already_read;
while (1 > 0) {
// If we don't have any more species to read, break
if (nsp == 0) break;
already_read = false;
// Read a new species record from the section
Species spec;
readNASA9ThermoRecord(spec);
// we signal the end of the section by putting <END> as a
// species name. Break if you find the end of the section.
if (spec.name == "<END>") {
break;
}
// check for duplicate thermo data
if (dup[spec.name] == 2) {
log << "Warning: more than one THERMO record for "
//.........这里部分代码省略.........
示例15: writeCluster
static bool writeCluster(
std::ostream &out, int depth,
const ClusterArray < std::vector<edge> > &edgeMap,
const ClusterGraph &C, const ClusterGraphAttributes *CA, const cluster &c,
int &clusterId)
{
std::ios_base::fmtflags currentFlags = out.flags();
out.flags(currentFlags | std::ios::fixed);
bool result = out.good();
if(result) {
if (C.rootCluster() == c) {
writeHeader(out, depth++, CA);
} else {
GraphIO::indent(out, depth++) << "subgraph cluster" << clusterId << " {\n";
}
clusterId++;
bool whitespace; // True if a whitespace should printed (readability).
whitespace = false;
if (CA) {
writeAttributes(out, depth, *CA, c);
whitespace = true;
}
if (whitespace) {
out << "\n";
}
// Recursively export all subclusters.
whitespace = false;
for (cluster child : c->children) {
writeCluster(out, depth, edgeMap, C, CA, child, clusterId);
whitespace = true;
}
if (whitespace) {
out << "\n";
}
// Then, print all nodes whithout an adjacent edge.
whitespace = false;
for (node v : c->nodes) {
whitespace |= writeNode(out, depth, CA, v);
}
if (whitespace) {
out << "\n";
}
// Finally, we print all edges for this cluster (ugly version for now).
const std::vector<edge> &edges = edgeMap[c];
whitespace = false;
for (auto &e : edges) {
whitespace |= writeEdge(out, depth, CA, e);
}
GraphIO::indent(out, --depth) << "}\n";
}
out.flags(currentFlags);
return result;
}