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


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

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


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

示例1: setw

void
Ice::BadMagicException::ice_print(ostream& out) const
{
    Exception::ice_print(out);
    out << ":\nunknown magic number: ";

    ios_base::fmtflags originalFlags = out.flags();     // Save stream state
    ostream::char_type originalFill = out.fill();

    out.flags(ios_base::hex);                           // Change to hex
    out.fill('0');                                      // Fill with leading zeros

    out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[0])) << ", ";
    out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[1])) << ", ";
    out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[2])) << ", ";
    out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[3]));

    out.fill(originalFill);                             // Restore stream state
    out.flags(originalFlags);

    if(!reason.empty())
    {
        out << "\n" << reason;
    }
}
开发者ID:bholl,项目名称:zeroc-ice,代码行数:25,代码来源:Exception.cpp

示例2: boxLine

//---------------------------------------------------------------------------------
// Function:	boxLine()
// Title:	Box Line
// Description:
//		draws a a line of text aligned in the middle of the box
// Programmer:	Paul Bladek
// 
// Date:	10/3/2006
//
// Version:	1.01
// 
// Environment: Hardware: i3 
//              Software: OS: Windows 7; 
//              Compiles under Microsoft Visual C++ 2012
//
// Output:	Formatted text to sout
//
// Called By:	header()
//		endbox()
//
// Parameters:	sout: ostream&;	stream to print to
//		text: const string&; text to print
//		length: unsigned short;	length of the box
//		alignment: unsigned char;   'L' (left), 'C'(center),'R'(right)
//		fillc: char; fill character
// 
// Returns:	void
//
// History Log:	
//		10/3/2006 PB completed v 1.01
//   
//---------------------------------------------------------------------------------
void boxLine(ostream& sout, const string& text, unsigned short length,
			 unsigned char alignment, char fillc)
{
	long originalformat = sout.flags(); // saves original format
	alignment = toupper(alignment);
	if(alignment != LEFT && alignment != RIGHT && alignment != CENTER)
		throw exception();
	if(length > MAX_LINE_LENGTH)
		length = MAX_LINE_LENGTH;
	sout << setfill(fillc); // change fill character
	sout.put(VERT);
	if(alignment == CENTER)
	{
		sout <<
			setw((length + static_cast<streamsize>(text.length())) / 2 - 1)
			<< text 
			<< setw((length - static_cast<streamsize>(text.length())) / 2 - 1) 
			<< fillc;
		if(text.length() % 2 == 0)
			sout << fillc; 
	}
	else
	{ 
		if(alignment == LEFT)
			sout << left;
		sout << setw(length - OFFSET) << text;
	}
    	sout.flags(originalformat); //  reset flags
	sout.put(VERT);
	sout << endl;
}
开发者ID:ZaneB1994,项目名称:Sink-the-fleet-draft-1,代码行数:63,代码来源:TextGraphics.cpp

示例3: Write

// Student::Write /////////////////////////////////////////
void Student::Write(ostream &os) const
{
	ios::fmtflags flags;
	int precision;

	// Write Person portion
	Person::Write(os);

	// Write the rest.
	if (&os == &cout || &os == &cerr)
	{
		// Get original state.
		precision = cout.precision();
		flags = os.flags();

		// Display GPA
		os << fixed << setprecision(2);
		os << "GPA:  " << GPA();
		if (Student::Debug())
		{
			os << "  (Address is 0x" << &m_gpa << ')';
		}

		// Restore original state.
		cout.precision(precision);
		os.flags(flags);
	}
	else
	{
		os << GPA();
	}
	os << '\n' << flush;
}
开发者ID:thepeoplescoder,项目名称:cpp-ecc-cs30-assignment2,代码行数:34,代码来源:Student.cpp

示例4: print

	void StackTrace::print(ostream &out, const char * const linePrefix) const
	{
		if (!m_success) {
			out << "<stack trace is unavailable>";
			return;
		}
		const ios_base::fmtflags backup = out.flags();
		for (int i = 0, n = m_elements.size(); i < n; ++i) {
			out << linePrefix;
			assert(m_elements[i] != 0);
			const StackTraceElement &element = *m_elements[i];
			out << (!element.m_function.empty() ? element.m_function.c_str() : "<unknown>") << " <" << element.m_address;
			if (element.m_offset != 0) {
				out.flags(ios::hex);
				assert(element.m_offset > 0);
				out << '+' << element.m_offset;
			}
			const afc::String * const fileNamePtr = element.m_file.get();
			out << ">\tat " << (fileNamePtr == nullptr ? "<unknown source>" : fileNamePtr->c_str());
			if (element.m_line != StackTraceElement::NO_LINE) {
				out.flags(ios::dec);
				out << ':' << element.m_line;
			}
			out << '\n';
		}
		out.flags(backup);
	}
开发者ID:dzidzitop,项目名称:libafc,代码行数:27,代码来源:StackTrace.cpp

示例5: Draw

void Trajectory::Draw(ostream &os) const {
	ios::fmtflags oldflags = os.flags();
	os.setf(ios::fixed);
	Context all;
	os << "time \\ var   ";
	for(ivmap::const_iterator i=traj.begin();i!=traj.end();++i) {
		os.width(5);
		os << i->first << "   ";
		all.AddVar(i->first,2);
	}
	os << endl;
	Instantiation oldv(all,-1);
	for(Index ii = Begin(all);!ii.Done();++ii) {
		//os << "_____________________________________________________________" << endl;
		os << ii.Time() << "     ";
		for(ivmap::const_iterator i=traj.begin();i!=traj.end();++i) {
			if (oldv.Value(i->first)!=ii.Values().Value(i->first)) {
				os.width(5);
				os << ii.Values().Value(i->first) << "   ";
			} else {
				os << "        ";
			}
		}
		os << endl;
		oldv = ii.Values();
	}
	os.flags(oldflags);
}
开发者ID:pierce1987,项目名称:pcim-dev,代码行数:28,代码来源:trajectory.cpp

示例6: dump

   void PackedNavBits::dump(ostream& s) const
      throw()
   {
      ios::fmtflags oldFlags = s.flags();
   
      s.setf(ios::fixed, ios::floatfield);
      s.setf(ios::right, ios::adjustfield);
      s.setf(ios::uppercase);
      s.precision(0);
      s.fill(' ');
      
      s << "****************************************************************"
        << "************" << endl
        << "Packed Nav Bits" << endl
        << endl
        << "SatID: " << getsatSys() << endl
        << endl
        << "Carrier: " << ObsID::cbDesc[obsID.band] << "      "
        << "Code: " << ObsID::tcDesc[obsID.code] 
        << "NavID: " << navID << endl;
      if (rxID.size()>0) 
         s << " RxID: " << rxID << endl;
      s << endl
        << "Number Of Bits: " << dec << getNumBits() << endl
        << endl;
  
      s << "              Week(10bt)     SOW      UTD     SOD"
        << "  MM/DD/YYYY   HH:MM:SS\n";
      s << "  Xmit Time:  ";

      s << printTime( transmitTime, "%4F(%4G) %6.0g      %3j   %5.0s  %02m/%02d/%04Y   %02H:%02M:%02S");
      s << endl;     

      s << endl << "Packed Bits, Left Justified, 32 Bits Long:\n";
      int numBitInWord = 0;
      int word_count   = 0;
      uint32_t word    = 0;
      for(size_t i = 0; i < bits.size(); ++i)
      {
         word <<= 1;
         if (bits[i]) word++;
       
         numBitInWord++;
         if (numBitInWord >= 32)
         {
            s << "  0x" << setw(8) << setfill('0') << hex << word << dec << setfill(' ');
            numBitInWord = 0;
            word_count++;
            //Print four words per line 
            if (word_count %5 == 0) s << endl;        
         }
      }
      word <<= 32 - numBitInWord;
      if (numBitInWord > 0 ) s << "  0x" << setw(8) << setfill('0') << hex << word << dec << setfill(' ');
      s.setf(ios::fixed, ios::floatfield);
      s.precision(3);
      s.flags(oldFlags);      // Reset whatever conditions pertained on entry

   } // end of PackedNavBits::dump()
开发者ID:SGL-UT,项目名称:GPSTk,代码行数:59,代码来源:PackedNavBits.cpp

示例7: print

void MetaNumeric::print(ostream& stream) {
	stream << resetiosflags(stream.flags());
	stream << setfill(' ');

	if (!numeric) {
		stream << " '" << actual_name << "' : non-numeric values are present or all values are missing" << endl;
	}
	else {
		stream << resetiosflags(stream.flags());
		stream << setprecision(7);
		stream << setw(12) << left << " N" << " = " << n << endl;
		stream << setw(12) << left << " Mean" << " = " << mean << endl;
		stream << setw(12) << left << " StdDev" << " = " << sd << endl;
		if (print_min == true) {
			stream << setw(12) << left << " Min" << " = " << min << endl;
		}
		if (print_max == true) {
			stream << setw(12) << left << " Max" << " = " << max << endl;
		}
		if (print_median == true) {
			stream << setw(12) << left << " Median" << " = " << median << endl;
		}
		if (print_skewness == true) {
			stream << setw(12) << left << " Skewness" << " = " << skew << endl;
		}
		if (print_kurtosis == true) {
			stream << setw(12) << left << " Kurtosis" << " = " << kurtosis << endl;
		}
		stream << setw(12) << left << " No. of NAs" << " = " << na << endl;

		if (print_quantiles == true) {
			stream << endl;
			stream << " Quantiles:" << endl;
			stream << fixed;
			stream << setprecision(0);
			stream << " Min (" << quantiles[0][0] * 100 << "%)";
			stream << "\t = " << setprecision(3) << quantiles[0][1] << endl;
			for (unsigned int j = 1; j < 4; j++) {
				stream << setprecision(0);
				stream << " " << quantiles[j][0] * 100 << "%";
				stream << "\t\t = " << setprecision(3) << quantiles[j][1] << endl;
			}
			stream << setprecision(0);
			stream << " Median (" << quantiles[4][0] * 100 << "%)";
			stream << "\t = " << setprecision(3) << quantiles[4][1] << endl;
			for (unsigned int j = 5; j < 8; j++) {
				stream << setprecision(0);
				stream << " " << quantiles[j][0] * 100 << "%";
				stream << "\t\t = " << setprecision(3) << quantiles[j][1] << endl;
			}
			stream << setprecision(0);
			stream << " Max (" << quantiles[8][0] * 100 << "%)";
			stream << "\t = " << setprecision(3) << quantiles[8][1] << endl;
		}

		stream << resetiosflags(stream.flags());
		stream << setfill(' ');
	}
}
开发者ID:rforge,项目名称:gwatoolbox,代码行数:59,代码来源:MetaNumeric.cpp

示例8: dump

   void BrcKeplerOrbit::dump(ostream& s) const
      throw()
   {
      const ios::fmtflags oldFlags = s.flags();
      s.setf(ios::fixed, ios::floatfield);
      s.setf(ios::right, ios::adjustfield);
      s.setf(ios::uppercase);
      s.precision(0);
      s.fill(' ');
      
      s << "****************************************************************"
        << "************" << endl
        << "Broadcast Ephemeris (Engineering Units)" << endl
        << endl
        << "PRN : " << setw(2) << PRNID << endl
        << endl;
  
      s << "              Week(10bt)     SOW     DOW   UTD     SOD"
        << "   MM/DD/YYYY   HH:MM:SS\n";
      
      s << endl;
      s << "Eph Epoch:    ";
      timeDisplay(s, getOrbitEpoch());
      s << endl;

      s.setf(ios::scientific, ios::floatfield);
      s.precision(8);
       
      s << endl
        << "           ORBIT PARAMETERS"
        << endl
        << endl
        << "Semi-major axis:       " << setw(16) << Ahalf  << " m**.5" << endl
        << "Motion correction:     " << setw(16) << dn     << " rad/sec"
        << endl
        << "Eccentricity:          " << setw(16) << ecc    << endl
        << "Arg of perigee:        " << setw(16) << w      << " rad" << endl
        << "Mean anomaly at epoch: " << setw(16) << M0     << " rad" << endl
        << "Right ascension:       " << setw(16) << OMEGA0 << " rad    "
        << setw(16) << OMEGAdot << " rad/sec" << endl
        << "Inclination:           " << setw(16) << i0     << " rad    "
        << setw(16) << idot     << " rad/sec" << endl;
      
      s << endl
        << "           HARMONIC CORRECTIONS"
        << endl
        << endl
        << "Radial        Sine: " << setw(16) << Crs << " m    Cosine: "
        << setw(16) << Crc << " m" << endl
        << "Inclination   Sine: " << setw(16) << Cis << " rad  Cosine: "
        << setw(16) << Cic << " rad" << endl
        << "In-track      Sine: " << setw(16) << Cus << " rad  Cosine: "
        << setw(16) << Cuc << " rad" << endl;    
      
      s << endl;

      s.flags(oldFlags);
   } // end of BrcKeplerOrbit::dump()
开发者ID:SGL-UT,项目名称:GPSTk,代码行数:58,代码来源:BrcKeplerOrbit.cpp

示例9: dump

void OrbElemRinex :: dump(ostream& s) const
throw( InvalidRequest )
{
    ios::fmtflags oldFlags = s.flags();
    dumpHeader(s);
    dumpBody(s);
    s.flags(oldFlags);

} // end of dump()
开发者ID:xiangyan66,项目名称:GPSTk,代码行数:9,代码来源:OrbElemRinex.cpp

示例10: save

//*****************************************************************************
//  METHOD: ossimDblGrid::save()
//  
//  Saves the grid to the stream in compact ASCII format (not necessarily
//  human readable).
//  
//*****************************************************************************
bool ossimDblGrid::save(ostream& os, const char* descr) const
{
   static const char MODULE[] = "ossimDblGrid::save()";
   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entering...\n";

   //***
   // Preserve the stream's settings:
   //***
   ios::fmtflags new_options = ios::scientific|ios::dec;
   //ios::streamsize new_precision = 12;
   int new_precision = 12;

   ios::fmtflags old_options = os.flags(new_options);
   int old_precision = os.precision(new_precision);

   //***
   // Verify the description string is not too long:
   //***
   char descr_buf[81];
   std::strncpy(descr_buf, descr, 80);
   descr_buf[80] = '\0';

   //***
   // write magic number tag and the grid size X, Y, num params:
   //***
   os << MAGIC_NUMBER << " " << descr_buf << "\n"
      << theSize.x << "  "
      << theSize.y << "  "
      << theOrigin.u << "  "
      << theOrigin.v << "  "
      << theSpacing.u << "  "
      << theSpacing.v << "  "
      << theNullValue << "  "
      << (int) theDomainType << "\n";

   if(theGridData)
   {
      //***
      // Loop to write grid points:
      //***
      int max_index = theSize.x*theSize.y;
      for (int i=0; i<max_index; i++)
         os << theGridData[i] << "  ";
   }
   os << "\n";

   //***
   // Restore the stream's state:
   //***
   os.flags(old_options);
   os.precision(old_precision);

   if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " returning...\n";
   return true;
}
开发者ID:ossimlabs,项目名称:ossim,代码行数:62,代码来源:ossimDblGrid.cpp

示例11: dumpHeader

   void CNavDataElement::dumpHeader(ostream& s) const
      throw( InvalidRequest )
   {
      s << "****************************************************************"
        << "************" << endl
        << "Broadcast Data (Engineering Units) - " << getNameLong();
      s << endl;

      SVNumXRef svNumXRef;
      int NAVSTARNum = 0;

      s << endl;
      s << "PRN : " << setw(2) << satID.id << " / "
        << "SVN : " << setw(2);
      try
      {
         NAVSTARNum = svNumXRef.getNAVSTAR(satID.id, ctXmit );
         s << NAVSTARNum << "  ";
      }
      catch(NoNAVSTARNumberFound)
      {
         s << "XX";
      }
      s << endl
        << endl;
      const ios::fmtflags oldFlags = s.flags();

      s.setf(ios::fixed, ios::floatfield);
      s.setf(ios::right, ios::adjustfield);
      s.setf(ios::uppercase);
      s.precision(0);
      s.fill(' ');

      s << endl;
      s << "           TIMES OF INTEREST"
        << endl << endl;
      s << "              Week(10bt)     SOW     DOW   UTD     SOD"
        << "   MM/DD/YYYY   HH:MM:SS\n";
      s << "Transmit Time:";
      timeDisplay(s, ctXmit);
      s << endl;

         // Special case for those data elements that do not possess an
         // epoch time.
      if (ctEpoch>CommonTime::BEGINNING_OF_TIME)
      {
         s << "Epoch Time:   ";
         timeDisplay(s, ctEpoch);
         s << endl;
      }

      s.flags(oldFlags);
   }
开发者ID:REC-SPb-ETU,项目名称:GPSTk,代码行数:53,代码来源:CNavDataElement.cpp

示例12: exc

void OrbElemRinex :: dumpTerse(ostream& s) const
throw(InvalidRequest )
{

    // Check if the subframes have been loaded before attempting
    // to dump them.
    if (!dataLoaded())
    {
        InvalidRequest exc("No data in the object");
        GPSTK_THROW(exc);
    }

    ios::fmtflags oldFlags = s.flags();

    s.setf(ios::fixed, ios::floatfield);
    s.setf(ios::right, ios::adjustfield);
    s.setf(ios::uppercase);
    s.precision(0);
    s.fill(' ');

    SVNumXRef svNumXRef;
    int NAVSTARNum = 0;
    try
    {
        NAVSTARNum = svNumXRef.getNAVSTAR(satID.id, ctToe );


        s << setw(2) << " " << NAVSTARNum << "  ";
    }
    catch(NoNAVSTARNumberFound)
    {
        s << "  XX  ";
    }

    s << setw(2) << satID.id << " ! ";

    string tform = "%3j %02H:%02M:%02S";

    s << printTime(beginValid, tform) << " ! ";
    s << printTime(ctToe, tform) << " ! ";
    s << printTime(endValid, tform) << " !  ";

    s << setw(4) << setprecision(1) << getAccuracy() << "  ! ";
    s << "0x" << setfill('0') << hex << setw(3) << IODC << " ! ";
    s << "0x" << setfill('0')  << setw(2) << health;
    s << setfill(' ') << dec;
    s << "   " << setw(2) << health << " ! ";

    s << endl;
    s.flags(oldFlags);

} // end of dumpTerse()
开发者ID:xiangyan66,项目名称:GPSTk,代码行数:52,代码来源:OrbElemRinex.cpp

示例13: printCorrelations

//--------------------------------------------------------------------------------------------------
void printCorrelations(ostream& os, RooFitResult *res)
{
  ios_base::fmtflags flags = os.flags();
  const RooArgList parlist = res->floatParsFinal();
  
  os << "  Correlation Matrix" << endl;
  os << " --------------------" << endl;
  for(Int_t i=0; i<parlist.getSize(); i++) {
    for(Int_t j=0; j<parlist.getSize(); j++) 
      os << "  " << setw(7) << setprecision(4) << fixed << res->correlationMatrix()(i,j);    
    os << endl;
  }
  os.flags(flags);
}
开发者ID:ksung25,项目名称:UserCode,代码行数:15,代码来源:fitWm.C

示例14: DumpTags

void CPicture::DumpTags( ostream& os, bool bRaw /*=false*/ ) {
	CTagMap::const_iterator i;
	int	idx = os.xalloc();
	for( i = TAGMAP.begin(); i != TAGMAP.end(); ++i ) {
		os << (*i).second;
		if( (*i).first > 30000 ) {
			if( PICT_DATA_PSHORT == (*i).second.Type() ) {
				LPWORD	pWord = (LPWORD) (*i).second.pVal();
				if( !bRaw )
					os << endl << szT1;
				for( int ii = 0; ii < (*i).second.Count(); ii++ ) {
					if( !bRaw && ii > 0 && ii % 4 == 0 )
						os << endl;
					if( ii > 0 )
						os << szT1;
					os << pWord[ii];
				}
			} else if( PICT_DATA_PDOUBLE == (*i).second.Type() ) {
				if( !bRaw )
					os << endl << szT1;
				int f = os.flags();
				os.flags( f | ios::fixed );
				os.precision( 5 );
				double	*pDbl = (double*) (*i).second.pVal();
				for( int ii = 0; ii < (*i).second.Count(); ii++ ) {
					if( !bRaw && ii > 0 && ii % 6 == 0 )
						os << endl;
					if( ii > 0 )
						os << szT1;
					os << pDbl[ii];
				}
				os.flags(f);
			} else if( PICT_DATA_PLONG == (*i).second.Type() ) {
				if( !bRaw )
					os << endl << szT1;
				long	*pLng = (long*) (*i).second.pVal();
				for( int ii = 0; ii < (*i).second.Count(); ii++ ) {
					if( !bRaw && ii > 0 && ii % 6 == 0 )
						os << endl;
					if( ii > 0 )
						os << szT1;
					os << pLng[ii];
				}
			}
		}
		os << endl;
	}
}
开发者ID:hkaiser,项目名称:TRiAS,代码行数:48,代码来源:TagMgr.cpp

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


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