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


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

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


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

示例1: _handleResponse

/**

    Process HTTP response message from cimserver

    @param   httpResponse        Array<char> reply from cimserver

    @param   ostream             the ostream to which output should be written

    @param   estream             the ostream to which errors should be written

    @return  true  = wait for data from challenge response
    @return  false = client response has been received

 */
void WbemExecCommand::_handleResponse( Array<char>           responseMessage,
                                          ostream&           oStream,
                                          ostream&           eStream
                                       )
{
    String                       startLine;
    Array<HTTPHeader>            headers;
    Uint32                       contentLength;
    Uint32                       contentOffset       = 0;
    HTTPMessage*                 httpMessage;
    Boolean                      needsAuthentication = false;

    httpMessage = new HTTPMessage( responseMessage, 0 );
    httpMessage->parse( startLine, headers, contentLength );
    if( contentLength > 0 )
      {
    contentOffset = responseMessage.size() - contentLength;
      }
    else
      {
        contentOffset = responseMessage.size();
      }

    String httpVersion;
    Uint32 statusCode;
    String reasonPhrase;

    Boolean parsableMessage = HTTPMessage::parseStatusLine(
        startLine, httpVersion, statusCode, reasonPhrase);
    if (!parsableMessage || (statusCode != HTTP_STATUSCODE_OK))
      {

    // Received an HTTP error response
    // Output the HTTP error message and exit
    for (Uint32 i = 0; i < contentOffset; i++)
      {
        oStream << responseMessage[i];
      }
    oStream.flush();
    if( contentLength > 0 )
      {
        _printContent( oStream, responseMessage, contentOffset );
      }
    exit( 1 );
      }

    //
    // Received a valid HTTP response from the server.
    //
    if (_debugOutput2)
      {
        for (Uint32 i = 0; i < contentOffset; i++)
          {
                oStream << responseMessage[i];
          }
        oStream.flush();
      }
    _printContent( oStream, responseMessage, contentOffset );
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:73,代码来源:WbemExecCommand.cpp

示例2: write

void clustalFormat::write(ostream &out, const sequenceContainer& sd) {
	// setting some parameters
	const int numOfPositionInLine = 60;
	int maxLengthOfSeqName =0;
	for (sequenceContainer::constTaxaIterator p=sd.constTaxaBegin(); p != sd.constTaxaEnd(); ++p ) {
		int nameLen = (*p).name().size();
		if (nameLen>maxLengthOfSeqName) maxLengthOfSeqName=nameLen;
	}
	if (maxLengthOfSeqName<15) maxLengthOfSeqName=16;
	else maxLengthOfSeqName=maxLengthOfSeqName+4; // all this maxLengthOfSeqName is the 

	out<<"CLUSTAL V"<<endl;
	           // num. of space after the name.
	int currentPosition = 0;
	int charLen = sd.seqLen();
	//in case of codon alphabet the character length is : 3*(sequence_length)
	//	codon codonAlph;
	if (sd.alphabetSize()>=60) charLen*=3; 
	out<<endl<<endl;
	while (currentPosition < charLen ) {
		out.flush();
		//for (vector<const sequenceContainer::sequenceDatum*>::const_iterator it5= vec.begin(); it5!=vec.end(); ++ it5) {
		for (sequenceContainer::constTaxaIterator it5=sd.constTaxaBegin();it5!=sd.constTaxaEnd();++it5) {
			for (int iName = 0 ;iName<maxLengthOfSeqName; ++iName) {
				if (iName<(*it5).name().size()) {
					out<<(*it5).name()[iName];
					out.flush();
				}
				else out<<" ";
			}
			out.flush();
			out<<" ";
			
			if (charLen<numOfPositionInLine) 
				out<<it5->toString()<<endl;
			else {
				for (int k=currentPosition; k < currentPosition+numOfPositionInLine; ++k) {
					if (k>=charLen) 
						break;
					out<<it5->toString()[k];
					//in case of codon alphabet each position is three characters
					
					if (sd.alphabetSize()>=60){ 
						out<<it5->toString()[++k];
						out<<it5->toString()[++k];
					}
				}
				out<<endl;
			}
		}
		currentPosition +=numOfPositionInLine;
		out<<endl<<endl;
	}

	return;
}
开发者ID:AidanDelaney,项目名称:fastml2,代码行数:56,代码来源:clustalFormat.cpp

示例3: makeArrowObject

void makeArrowObject(ostream& os)
{
    GluTriStripAdder adder(&os);
    g_adder = &adder;
    //float barRadius = 0.7, barLen = 15.0, triStartRadius = 1.5, triLen = 5.0;
    //float barRadius = 1.5, barLen = 12.0, triStartRadius = 2.4, triLen = 8.0;
    float barRadius = 1, barLen = 13.0, triStartRadius = 2, triLen = 7.0;

    int slices = 20;

    GLUquadric q;
    q.orientation = GLU_OUTSIDE;
    sgluCylinder(&q, barRadius, barRadius, barLen, slices, 1);

    q.orientation = GLU_INSIDE;
    sgluDisk(&q, 0, barRadius, slices, 1);

    adder.m_translate.z = barLen;

    q.orientation = GLU_OUTSIDE;
    sgluCylinder(&q, triStartRadius, 0, triLen, slices, 1);

    q.orientation = GLU_INSIDE;
    sgluDisk(&q, barRadius, triStartRadius, slices, 1);

    os << "\nVTX " << adder.m_addedVtx.size() << endl;

    adder.printJs(os);

    os.flush();

    g_adder = nullptr;
}
开发者ID:shooshx,项目名称:happysolver,代码行数:33,代码来源:QuadMaker.cpp

示例4: write

void TextWriter::write(ostream & output, map<int, list<Rule> > rules) {
	map<int, list<Rule> >::iterator im;
	for (im=rules.begin(); im!=rules.end(); ++im) {
		output << "====================" << endl;
		output << im->second.front().class_attribute.second << ": ";
		output << im->second.front().decision << endl;
		output << "--------------------" << endl;

		list<Rule>::iterator ir;
		for (ir=im->second.begin(); ir!=im->second.end(); ++ir) {
			map<string, string>::iterator ia;
			for (ia=ir->attributes.begin(); ia!=ir->attributes.end(); ++ia) {
				if (ia->second == "") continue;
                output << ia->first << "(" << ia->second << ")";
				if (ir->attributes.size() > 1 && ia!=--ir->attributes.end()) {
					output << ", ";
				}
			}
			output << endl;
		}
		output << endl;
	}
    
    output.flush();
}
开发者ID:piotrdubiel,项目名称:c-charm,代码行数:25,代码来源:text_writer.cpp

示例5: log

void despoof::log(ostream &target, int severity, const string &text)
{
	auto prev = target.imbue(loglocale());
	target << "[" << severitytext(severity) << " " << as::datetime << time(0) << "] " << text << endl;
	target.flush();
	target.imbue(prev);
}
开发者ID:raphaelr,项目名称:despoof,代码行数:7,代码来源:logger-util.cpp

示例6: timer

/** Pop bubbles discovered previously. */
size_t NetworkSequenceCollection::
performNetworkPopBubbles(ostream& out)
{
	Timer timer("NetworkPopBubbles");

	// Deal with any packets still in the queue. The barrier
	// synchronization guarantees that the packets have been
	// delivered, but we may not have dealt with them yet.
	pumpNetwork();
	assert(m_comm.receiveEmpty());

	size_t numPopped = 0;
	for (BranchGroupMap::iterator iter = m_bubbles.begin();
			iter != m_bubbles.end(); iter++) {
		assert(iter->second.getStatus() == BGS_JOINED);
		// Check whether this bubble has already been popped.
		if (!iter->second.isAmbiguous(m_data))
			continue;
		numPopped++;
		AssemblyAlgorithms::writeBubble(out,
				iter->second, m_numPopped + numPopped);
		AssemblyAlgorithms::collapseJoinedBranches(
				this, iter->second);
		assert(!iter->second.isAmbiguous(m_data));
		assert(m_comm.receiveEmpty());
	}
	m_bubbles.clear();
	out.flush();
	assert(out.good());

	logger(0) << "Removed " << numPopped << " bubbles.\n";
	return numPopped;
}
开发者ID:genome-vendor,项目名称:abyss,代码行数:34,代码来源:NetworkSequenceCollection.cpp

示例7: fstPrint

/**
 * Print an FST to an ostream.
 * @param fst	[in] FST to print.
 * @param os	[in,out] ostream.
 *
 * @return 0 on success; negative POSIX error code on error.
 */
int fstPrint(IFst *fst, ostream &os)
{
	if (!fst) {
		// Invalid parameters.
		return -EINVAL;
	}

	vector<uint8_t> tree_lines;
	tree_lines.reserve(16);

	FstFileCount fc = {0, 0};
	int ret = fstPrint(fst, os, "/", 0, tree_lines, fc);
	if (ret != 0) {
		return ret;
	}

	// Print the file count.
	// NOTE: Formatting numbers using ostringstream() because
	// MSVC's printf() doesn't support thousands separators.
	// TODO: CMake checks?
	ostringstream dircount, filecount;
	dircount << fc.dirs;
	filecount << fc.files;

	os << '\n' <<
		// tr: Parameter is a number; it's formatted elsewhere.
		rp_sprintf(NC_("FstPrint", "%s directory", "%s directories", fc.dirs), dircount.str().c_str()) << ", " <<
		// tr: Parameter is a number; it's formatted elsewhere.
		rp_sprintf(NC_("FstPrint", "%s file", "%s files", fc.files), filecount.str().c_str()) << '\n';

	os.flush();
	return 0;
}
开发者ID:GerbilSoft,项目名称:rom-properties,代码行数:40,代码来源:FstPrint.cpp

示例8: respond

void PoK_point_Prover::respond(ostream &os, const ZZ_p &chall)
{
	if (!announced)
	{
		throw runtime_error("respond() invoked before announce().");
	}
	if (responded)
	{
		throw runtime_error("respond() invoked twice.");
	}

	ZZ_p fi = eval(com.f, index);

	// Compute the responses
	ZZ_p u1 = s1 - chall / gamma;
	ZZ_p u2 = s2 - fi * chall;

	responded = true;

	//    cout << "p:chall=" << chall << "\n";
	//    cout << "p:u1 = " << u1 << "\n";
	//    cout << "p:u2 = " << u2 << "\n";
	os << u1 << ' ' << u2;
	os.flush();
}
开发者ID:mahdiz,项目名称:mpclib,代码行数:25,代码来源:PolyCommitProofs.cpp

示例9: write

void CsvWriter::write(ostream & output, map<int, list<Rule> > rules) {
    // write header
	if (rules.empty()) return;
	map<string, string>::iterator at;
	for (at=rules.begin()->second.front().attributes.begin(); at!=rules.begin()->second.front().attributes.end(); ++at) {
		output << at->first << ";";		
	}
	output << rules.begin()->second.front().class_attribute.second << endl;

	map<int, list<Rule> >::iterator im;
	for (im=rules.begin(); im!=rules.end(); ++im) {
		list<Rule>::iterator ir;
		for (ir=im->second.begin(); ir!=im->second.end(); ++ir) {
            map<string, string>::iterator ia;
			for (ia=ir->attributes.begin(); ia!=ir->attributes.end(); ++ia) {
				if (ia->second!="") {
					output << ia->second;
				}
				output << ";";
			}
			output << ir->decision;
			output << endl;
		}
	}
    
    output.flush();
}
开发者ID:piotrdubiel,项目名称:c-charm,代码行数:27,代码来源:csv_writer.cpp

示例10: ReportResultsHeader

void  RandomSampleJob::ReportResultsHeader (ostream&   r)
{
  r << "Job"        << "\t"
    << "SVM"        << "\t"
    << "Feature"    << "\t"
    << "Compresion" << "\t"
    << ""           << "\t"   // C
    << ""           << "\t"   // Gamma
    << "Order"      << "\t" 
    << "Num"        << "\t"   // Examples
    << "Sample"     << "\t"   // Sample Accurcay
    << "Support"    << "\t"
    << "Train"      << "\t"
    << "Test"       << "\t"
    << endl;

  r << "Id"         << "\t"
    << "Kernel"     << "\t"
    << "Encoding"   << "\t"
    << "Method"     << "\t"
    << "C"          << "\t"
    << "Gamma"      << "\t"
    << "Num"        << "\t"
    << "Examples"   << "\t"  
    << "Accuracy"   << "\t"   // Sample Accuracy
    << "Points"     << "\t" 
    << "Time"       << "\t"   // Train Time
    << "Time"       << "\t"   // Test Time
    << endl;

  r.flush ();

}  /* ReportResultsHeader */
开发者ID:jizhihang,项目名称:Pices-XXX-,代码行数:33,代码来源:RandomSampleJob.cpp

示例11: prunionalignment

//compute union alignment
int prunionalignment(ostream& out,int m,int *a,int n,int* b)
{

  ostringstream sout;

  for (int j=1; j<=m; j++)
    if (a[j])
      sout << j-1 << "-" << a[j]-1 << " ";

  for (int i=1; i<=n; i++)
    if (b[i] && a[b[i]]!=i)
      sout << b[i]-1 <<  "-" << i-1 << " ";

  //fix the last " "
  string str = sout.str();
  if (str.length() == 0)
    str = "\n";
  else
    str.replace(str.length()-1,1,"\n");

  out << str;
  out.flush();

  return 1;
}
开发者ID:EktaGupta28,项目名称:mosesdecoder,代码行数:26,代码来源:symal.cpp

示例12: transfer

streamsize cb::transfer(istream &in, ostream &out, streamsize length,
                        SmartPointer<TransferCallback> callback) {
  char buffer[BUFFER_SIZE];
  streamsize total = 0;

  while (!in.fail() && !out.fail()) {
    in.read(buffer, length ? min(length, BUFFER_SIZE) : BUFFER_SIZE);
    streamsize bytes = in.gcount();
    out.write(buffer, bytes);

    total += bytes;
    if (!callback.isNull() && !callback->transferCallback(bytes)) break;

    if (length) {
      length -= bytes;
      if (!length) break;
    }
  }

  out.flush();

  if (out.fail() || length) THROW("Transfer failed");

  return total;
}
开发者ID:kbernhagen,项目名称:cbang,代码行数:25,代码来源:Transfer.cpp

示例13: multiSizeBenchmarkBestPositionAndSubmatrixQueries

void SubmatrixQueriesTest::multiSizeBenchmarkBestPositionAndSubmatrixQueries(size_t maxNRows, size_t maxNCols, size_t minNRows, size_t minNCols, size_t stepSize, size_t nSamplePerSize, size_t nPosQueries, size_t nSMQueries, ostream &outputStream)
{
    size_t nRows = minNRows, nCols = minNCols;
    for (; nRows <= maxNRows && nCols <= maxNCols; nRows += stepSize, nCols += stepSize) {
        bench_time_t *benchmarks = new bench_time_t [2];
        
#ifdef __MACH__
        benchmarks[0] = 0;
        benchmarks[1] = 0;
#else
        benchmarks[0].tv_sec = 0; benchmarks[0].tv_nsec = 0;
        benchmarks[1].tv_sec = 0; benchmarks[1].tv_nsec = 0;
#endif
        
        cout << "Fastest queries benchmarks for size: " << nRows << " x " << nCols << " ...";
        
        SubmatrixQueriesTest::multipleBenchmarkBestPositionAndSubmatrixQueries(nRows,nCols, nSamplePerSize, nPosQueries, nSMQueries, benchmarks, benchmarks+1);
        
        cout << " done\n";
        
        outputStream << ((int)nRows) << " ; " << benchTimeAsMiliSeconds(benchmarks[0]) << " ; " << benchTimeAsMiliSeconds(benchmarks[1]) << "\n";
        outputStream.flush();
        
        delete [] benchmarks;
    }
    
}
开发者ID:rbost,项目名称:SubmatrixQueries,代码行数:27,代码来源:tests.cpp

示例14: printShardInfo

 void Shard::printShardInfo( ostream& out ) {
     vector<Shard> all;
     staticShardInfo.getAllShards( all );
     for ( unsigned i=0; i<all.size(); i++ )
         out << all[i].toString() << "\n";
     out.flush();
 }
开发者ID:7segments,项目名称:mongo,代码行数:7,代码来源:shard.cpp

示例15: Write

//------------------------------------------------------------------------//
bool TokenFile::Write(ostream &Output, TokenList* pTokenList, DWORD dwFlags)
{
	Clear();
	
	if(dwFlags & TF_CASE_SENSITIVE)
		m_bCaseSensitive = true;
	else
		m_bCaseSensitive = false;

	// clear the queue
	while(!m_queBuffer.empty())
		m_queBuffer.pop();

	m_pTokenList = pTokenList;
	WriteHeader();
	GenerateTables();
	WriteTables();
	WriteTokens();

	while(!m_queBuffer.empty())
	{
		Output.put(m_queBuffer.front());
		m_queBuffer.pop();
	}

	Output.flush();
	return true;
}
开发者ID:F5000,项目名称:spree,代码行数:29,代码来源:TokenFile.cpp


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