本文整理汇总了C++中std::ostream::width方法的典型用法代码示例。如果您正苦于以下问题:C++ ostream::width方法的具体用法?C++ ostream::width怎么用?C++ ostream::width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std::ostream
的用法示例。
在下文中一共展示了ostream::width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display_normalized_enodes
/**
\brief Display enode definitions #n := (f #i_1 ... #i_n), where #i_k is the root
of the k-th argument of the enode #n.
*/
void context::display_normalized_enodes(std::ostream & out) const {
out << "normalized enodes:\n";
ptr_vector<enode>::const_iterator it = m_enodes.begin();
ptr_vector<enode>::const_iterator end = m_enodes.end();
for (; it != end; ++it) {
enode * n = *it;
out << "#";
out.width(5);
out << std::left << n->get_owner_id() << " #";
out.width(5);
out << n->get_root()->get_owner_id() << " := " << std::right;
unsigned num = n->get_owner()->get_num_args();
if (num > 0)
out << "(";
out << n->get_decl()->get_name();
if (!n->get_decl()->private_parameters())
display_parameters(out, n->get_decl()->get_num_parameters(), n->get_decl()->get_parameters());
for (unsigned i = 0; i < num; i++) {
expr * arg = n->get_owner()->get_arg(i);
if (e_internalized(arg)) {
enode * n = get_enode(arg)->get_root();
out << " #" << n->get_owner_id();
}
else {
out << " #" << arg->get_id();
}
}
if (num > 0)
out << ")";
if (is_relevant(n))
out << "\t*";
out << "\n";
}
}
示例2: hexDump
void hexDump(std::ostream &o,void const *v,uint cb,uint cbDone)
{
boost::io::ios_all_saver streamStateSaver(o);
PConstBuffer b = (PConstBuffer) v;
uint cbLine = 16, cbThis;
o.fill('0');
for (; cb; cb -= cbThis, cbDone += cbThis) {
cbThis = std::min(cbLine, cb);
o << std::hex;
o.width(4);
o << cbDone << ": ";
uint i;
for (i = 0; i < cbThis; i++, b++) {
o.width(2);
o << (uint) *b << " ";
}
for (i = cbThis; i < cbLine; i++) {
o << " ";
}
o << "| ";
for (i = 0, b -= cbThis; i < cbThis; i++, b++) {
if (isprint(*b)) {
o << *b;
} else {
o << " ";
}
}
o << std::endl;
}
}
示例3: output
void DataDisplay::output( std::ostream& os)
{
int rows = DataTable->numRows();
int cols = DataTable->numCols();
os << "! LEGEND:"<< std::endl;
os << "! " << std::endl;
int k = 0;
for (int i=0; i<cols; i++)
{
if ( ! DataTable->isColumnHidden(i) ) {
os << "! Column " << ++k << " : "
<< DataTable->horizontalHeader( )->label(i).replace('\n', ',') << std::endl;
}
}
os << "!" << std::endl;
k = 0 ;
QString tmp_heading;
for ( int i=0; i <cols; i++)
{
if ( ! DataTable->isColumnHidden(i) ) {
tmp_heading = "Column " + QString::number(++k);
if ( k == 1){
os.width(1); os <<"!"; os.width(17);
os << tmp_heading;
}
else {
os.width(18);
os.setf(std::ios_base::right | std::ios_base::scientific);
os << tmp_heading;
}
}
}
os << std::endl;
os << "!" << std::endl;
for (int i=0; i< rows; i++)
{
for (int j=0; j< cols; j++)
{
if ( !DataTable->isColumnHidden(j) ) {
os.width(18);
os.setf(std::ios_base::right | std::ios_base::scientific);
os << DataTable->text(i,j);
}
}
os << std::endl;
}
}
示例4: display
void Order::display(std::ostream & os) const {
eanOrd.display(os);
os.width(9);
os << ordered;
os.width(11);
os << delivered;
}
示例5: stream_state
inline
void
arma_ostream::print(std::ostream& o, const subview_field<oT>& x)
{
arma_extra_debug_sigprint();
const arma_ostream_state stream_state(o);
const std::streamsize cell_width = o.width();
const uword x_n_rows = x.n_rows;
const uword x_n_cols = x.n_cols;
for(uword col=0; col<x_n_cols; ++col)
{
o << "[field column " << col << ']' << '\n';
for(uword row=0; row<x_n_rows; ++row)
{
o.width(cell_width);
o << x.at(row,col) << '\n';
}
o << '\n';
}
o.flush();
stream_state.restore(o);
}
示例6: chooseOptions
/** Ouptut a bonmin.opt file with options default values and short descritpions.*/
void
RegisteredOptions::writeBonminOpt(std::ostream &os, ExtraCategoriesInfo which){
std::list< Ipopt::RegisteredOption * > options;
chooseOptions(which, options);
//Create journalist to write to os
Ipopt::Journalist jnlst;
Ipopt::SmartPtr<Ipopt::StreamJournal> J = new Ipopt::StreamJournal("options_journal", Ipopt::J_ALL);
J->SetOutputStream(&os);
J->SetPrintLevel(Ipopt::J_DOCUMENTATION, Ipopt::J_SUMMARY);
jnlst.AddJournal(GetRawPtr(J));
std::string registeringCategory = "";
for(std::list< Ipopt::RegisteredOption * >::iterator i = options.begin();
i != options.end() ; i++)
{
if((*i)->RegisteringCategory() != registeringCategory){
registeringCategory = (*i)->RegisteringCategory();
os<<std::endl<<"# registering category: "<<registeringCategory<<std::endl<<std::endl;
}
os<<"bonmin.";
os.setf(std::ios::left);
os.width(37);
os<<(*i)->Name()<<" ";
os.width(10);
os<<makeNumber(defaultAsString(*i))<<"\t#";
os<<(*i)->ShortDescription();
os<<std::endl;
}
}
示例7: print
void Timing::print(std::ostream & out) {
map_t & tagMap = instance().m_tagMap;
//list_t & timers = instance().m_timers;
out << "SM Timing\n";
out << "-----------\n";
map_t::iterator t = tagMap.begin();
for( ; t != tagMap.end(); t++) {
size_t i = t->second;
out.width((std::streamsize)instance().m_maxTagLength);
out.setf(std::ios::left,std::ios::adjustfield);
out << t->first << "\t";
out.width(7);
out.setf(std::ios::right,std::ios::adjustfield);
out << getNumSamples(i) << "\t";
if(getNumSamples(i) > 0)
{
out << secondsToTimeString(getTotalSeconds(i)) << "\t";
double meansec = getMeanSeconds(i);
double stddev = sqrt(getVarianceSeconds(i));
out << "(" << secondsToTimeString(meansec) << " +- ";
out << secondsToTimeString(stddev) << ")\t";
double minsec = getMinSeconds(i);
double maxsec = getMaxSeconds(i);
// The min or max are out of bounds.
out << "[" << secondsToTimeString(minsec) << "," << secondsToTimeString(maxsec) << "]";
}
out << std::endl;
}
}
示例8: display_subexprs_info
void context::display_subexprs_info(std::ostream & out, expr * n) const {
ptr_buffer<expr> todo;
todo.push_back(n);
while (!todo.empty()) {
expr * n = todo.back();
todo.pop_back();
out << "#";
out.width(6);
out << std::left << n->get_id();
out << ", relevant: " << is_relevant(n);
if (m_manager.is_bool(n)) {
out << ", val: ";
out.width(7);
out << std::right;
if (lit_internalized(n))
out << get_assignment(n);
else
out << "l_undef";
}
if (e_internalized(n)) {
enode * e = get_enode(n);
out << ", root: #" << e->get_root()->get_owner_id();
}
out << "\n";
if (is_app(n)) {
for (unsigned i = 0; i < to_app(n)->get_num_args(); i++)
todo.push_back(to_app(n)->get_arg(i));
}
}
}
示例9: stream_stacktrace
// Custom streaming for stacktraces.
inline void stream_stacktrace(std::ostream &os, const stacktrace &st)
{
os << '\n';
const auto w = os.width();
const auto max_idx_width = std::to_string(st.size()).size();
// NOTE: the overflow check is because we will have to cast to std::streamsize
// later, due to the iostreams API.
// LCOV_EXCL_START
if (unlikely(max_idx_width > static_cast<std::make_unsigned<std::streamsize>::type>(
std::numeric_limits<std::streamsize>::max()))) {
// Not much left to do here really.
std::cerr << "Overflow in the size of a stacktrace, aborting now.\n";
std::abort();
}
// LCOV_EXCL_STOP
// We customize a bit the printing of the stacktrace, and we traverse
// it backwards.
auto i = st.size();
for (auto it = st.rbegin(); it != st.rend(); --i, ++it) {
os << "#";
os.width(static_cast<std::streamsize>(max_idx_width));
os << i;
os.width(w);
os << "| " << *it << '\n';
}
}
示例10:
void Node1D::print(std::ostream &out)
{
out << " ID = ";
out.width(4);
out << _id;
out << ", X = ";
out.width(4);
out.left;
out << _x;
out << std::endl;
}
示例11: printSyntaxTree
void printSyntaxTree (std::ostream & os, Nonterm const & nonterm)
{
LRRule const & rule = nonterm.getRule ();
os << rule.str;
// info->name is node name
NontermInfo const * info = rule.nonterm_info;
os << " [" << info->name << "]";
os << '\n';
typedef std::pair <Nonterm const *, int> ChildIter;
std::deque <ChildIter> stack;
stack.push_back (ChildIter (& nonterm, 1));
int indent = 1;
for (;;)
{
ChildIter & iter = stack.back ();
Nonterm const & nonterm = * iter.first;
if (iter.second > nonterm.getNumChild ())
{
stack.pop_back ();
if (stack.empty ())
{
break;
}
-- indent;
}
else
{
Node & node = nonterm.getChild (iter.second ++);
Token const & token = node.getToken ();
if (token.isSet ())
{
os.width (indent * 2);
os << "";
os << identToString (token.getLexeme ()) << '\n';
}
Nonterm const & nonterm = node.getNonterm ();
if (nonterm.isSet ())
{
LRRule const & rule = nonterm.getRule ();
os.width (indent * 2);
os << "";
os << rule.str;
// info->name is node name
NontermInfo const * info = rule.nonterm_info;
os << " [" << info->name << "]";
os << '\n';
stack.push_back (ChildIter (& nonterm, 1));
++ indent;
}
}
}
}
示例12: WriteTag
void ILogger::WriteTag(std::ostream& theOstream, SeverityType theSeverity,
const char* theSourceFile, int theSourceLine)
{
const struct std::tm* anTm; // Pointer to Time structure
std::time_t anNow;
// Get current time in seconds since Jan 1, 1970
anNow = std::time(NULL);
// Convert current time value into local time (with help from OS)
anTm = std::localtime(&anNow);
// Output time in timestamp format
theOstream << anTm->tm_year + 1900 << "-";
theOstream.fill('0');
theOstream.width(2);
theOstream << anTm->tm_mon + 1 << "-";
theOstream.fill('0');
theOstream.width(2);
theOstream << anTm->tm_mday << " ";
theOstream.fill('0');
theOstream.width(2);
theOstream << anTm->tm_hour + 1 << ":";
theOstream.fill('0');
theOstream.width(2);
theOstream << anTm->tm_min << ":";
theOstream.fill('0');
theOstream.width(2);
theOstream << anTm->tm_sec << " ";
// Now print the log level as a single character
switch(theSeverity)
{
case SeverityInfo:
theOstream << "I";
break;
case SeverityWarning:
theOstream << "W";
break;
case SeverityError:
theOstream << "E";
break;
case SeverityFatal:
theOstream << "F";
break;
default:
theOstream << "U";
break;
}
theOstream << " " << theSourceFile << ":" << theSourceLine << " ";
}
示例13: a
void
DenseMatrix<T>::printOn(std::ostream& os) const
{
std::streamsize width = os.width();
os.width(0);
for(size_t i = 0; i < numRows; ++i)
{
os << "[ ";
for(size_t j = 0; j < numCols; ++j)
{
os << std::setw(width) << a(i, j) << ' ';
}
os << "]\n";
}
}
示例14: printAlignedFP
// printAlignedFP - Simulate the printf "%A.Bf" format, where A is the
// TotalWidth size, and B is the AfterDec size.
//
static void printAlignedFP(double Val, unsigned AfterDec, unsigned TotalWidth,
std::ostream &OS) {
assert(TotalWidth >= AfterDec+1 && "Bad FP Format!");
OS.width(TotalWidth-AfterDec-1);
char OldFill = OS.fill();
OS.fill(' ');
OS << (int)Val; // Integer part;
OS << ".";
OS.width(AfterDec);
OS.fill('0');
unsigned ResultFieldSize = 1;
while (AfterDec--) ResultFieldSize *= 10;
OS << (int)(Val*ResultFieldSize) % ResultFieldSize;
OS.fill(OldFill);
}
示例15: getElement
void
TridiagonalMatrix<T>::printOn(std::ostream& os) const
{
const std::streamsize width = os.width();
os.width(0);
for(size_t i = 0; i < size; ++i)
{
os << "[ ";
for(size_t j = 0; j < size; ++j)
{
os << std::setw(width) << getElement(i, j) << ' ';
}
os << "]\n";
}
}