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


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

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


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

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

示例2: writeBinary

MStatus CVData::writeBinary ( ostream& out )  
{
	out.write( (char*) &_intData, sizeof(_intData) );
	if ( !out.fail() ) {
		out.write( (char*) &_doubleData, sizeof(_doubleData) );
	} else {
		return MS::kFailure;
	}
	return out.fail() ? MS::kFailure : MS::kSuccess;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:10,代码来源:blindComplexDataCmd.cpp

示例3: checkpoint

void Simulation::checkpoint (ostream& stream, int checkpointNum) {
    util::checkpoint::header (stream);
    if (stream == NULL || !stream.good())
	throw util::checkpoint_error ("Unable to write to file");
    util::timer::startCheckpoint ();
    
    util::CommandLine::staticCheckpoint (stream);
    Population::staticCheckpoint (stream);
    Surveys & stream;
    
    Global::simulationTime & stream;
    Global::timeStep & stream;
    simPeriodEnd & stream;
    totalSimDuration & stream;
    phase & stream;
    (*_population) & stream;
    
    util::random::checkpoint (stream, checkpointNum);
    workUnitIdentifier & stream;
    cksum & stream;
    
    util::timer::stopCheckpoint ();
    if (stream.fail())
	throw util::checkpoint_error ("stream write error");
}
开发者ID:dhardy,项目名称:openmalaria,代码行数:25,代码来源:Simulation.cpp

示例4: write

bool drwnDataRecord::write(ostream& os) const
{
    // TODO: fix 32-bit/64-bit problems
    int rows = _structure.rows();
    os.write((char *)&rows, sizeof(int));
    if (rows > 0) {
        os.write((char *)_structure.data(), rows * sizeof(int));
    }

    rows = _data.rows();
    int cols = _data.cols();
    os.write((char *)&rows, sizeof(int));
    os.write((char *)&cols, sizeof(int));
    if (rows > 0) {
        os.write((char *)_data.data(), rows * cols * sizeof(double));
    }

    rows = _objective.rows();
    os.write((char *)&rows, sizeof(int));
    if (rows > 0) {
        os.write((char *)_objective.data(), rows * sizeof(double));
    }

    rows = _gradient.rows();
    cols = _gradient.cols();
    os.write((char *)&rows, sizeof(int));
    os.write((char *)&cols, sizeof(int));
    if (rows > 0) {
        os.write((char *)_gradient.data(), rows * cols * sizeof(double));
    }

    DRWN_ASSERT_MSG(!os.fail(), "bytes: " << this->numBytesOnDisk());
    _bDirty = false;
    return true;
}
开发者ID:dzenteno2,项目名称:drwn,代码行数:35,代码来源:drwnDataRecord.cpp

示例5: saveToXml

/**
 * Saves signature to file using XAdES XML format.
 *
 * @param path path, where the signature XML file is saved.
 * @throws IOException throws exception if the signature file creation failed.
 */
void SignatureBES::saveToXml(ostream &os) const
{
    if(!sigdata_.empty())
    {
        os << sigdata_;
        return;
    }

    try
    {
        NamespaceInfomap map;
        map["ds"].name = URI_ID_DSIG;
        map["xades"].name = XADES_NAMESPACE;
        if(asicsignature)
        {
            map["asic"].name = ASIC_NAMESPACE;
            XAdESSignaturesType asic;
            asic.signature().push_back(*signature);
            xAdESSignatures(os, asic, map, "UTF-8", Flags::dont_initialize);
        }
        else
            dsig::signature(os, *signature, map, "UTF-8", Flags::dont_initialize);
    }
    catch ( xsd::cxx::xml::invalid_utf8_string )
    {
        THROW_IOEXCEPTION("Failed to create signature XML file. Parameters must be in UTF-8.");
    }
    if(os.fail())
        THROW_IOEXCEPTION("Failed to create signature XML file.");
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:36,代码来源:Signature.cpp

示例6: write

int CCombineGenome::write( ostream & os ) const
{
	for(int i=0; i<paths; i++)
	{
		os << "list " << i << ":\t" ;

		YK_LLONG *cur, *head;
		GAListIter<YK_LLONG> iter(*list[i]);
		float sum = 0;
		if((head=iter.head()) != 0) 
		{
			sum +=*head;
			os << *head << " ";
		}
		for(cur=iter.next(); cur && cur != head; cur=iter.next())
		{
			sum += *cur;
			os << *cur << " ";
		}
		os<<"\t"<<"size: "<<list[i]->size()<<"\t";
		if (list[i]->size() > 0)
		{
			os<<"aver: "<<sum/list[i]->size()<<" ";
		}
		os << "\n";
	}
	return os.fail() ? 1 : 0;
}
开发者ID:backo880607,项目名称:YuKonSolution,代码行数:28,代码来源:CombineGenome.cpp

示例7: write

int Trafo::write (ostream& os) const
{
  os << NAME "(";
  for (int i = 0; i < 3; i++) 
    for (int j = 0; j < 4; j++) 
      os << m[i][j] << ((i==2 && j==3) ? ")" : ",");

  return (os.fail()) ? 1 : 0;
}
开发者ID:lucafuji,项目名称:Gene-Correlation,代码行数:9,代码来源:mptrafo.cpp

示例8:

int
RobotPathGenome::write(ostream & os) const
{
    for(int i = 0; i < n; i++)
    {
        os << "list " << i << ":\t" << *(list[i]) << "\n";
    }
    return os.fail() ? 1 : 0;
}
开发者ID:distanceModling,项目名称:GAlib,代码行数:9,代码来源:ex14.C

示例9: writeSynLines

//------------------------------------------------------------------------------
// writeSynLines (vector <Line>, ostream) : Requests the XGremlin 'syn' string
// from each Line in the vector at arg1 and sends this string to the stream at
// arg2.
//
void writeSynLines (vector <Line> Lines, ostream &Output = std::cout) throw (const char*) {
  for (unsigned int i = 0; i < Lines.size (); i ++) {
    Output << Lines[i].getLineSynString() << endl;
    if (Output.fail ()) {
      ostringstream oss;
      oss << "line " << Lines[i].line ();
      throw oss.str().c_str();
    }
  }
}
开发者ID:Christian-Clear,项目名称:xgtools,代码行数:15,代码来源:lineio.cpp

示例10: write

int MpViewLabelList::write (ostream& os) const
{
  for (vector<MpViewLabelData>::const_iterator i = list.begin(); 
       i != list.end(); ++i) {
    if (i !=  list.begin()) 
	os << ", " << endl;
    i->write(os);
  }
  return (os.fail()) ? 1 : 0;  
}
开发者ID:lucafuji,项目名称:Gene-Correlation,代码行数:10,代码来源:mpviewlabellist.cpp

示例11: write

bool drwnCompressionBuffer::write(ostream& os) const
{
    os.write((char *)&_bytesOriginal, sizeof(unsigned int));
    os.write((char *)&_bytesCompressed, sizeof(unsigned int));
    if (_bytesCompressed > 0) {
        os.write((char *)_data, _bytesCompressed * sizeof(unsigned char));
    }

    return (!os.fail());
}
开发者ID:dzenteno2,项目名称:drwn,代码行数:10,代码来源:drwnCompressionBuffer.cpp

示例12: tmpiter

//   Here we specialize the write method for the List class.  This lets us see
// exactly what we want (the default write method dumps out pointers to the
// data rather than the data contents).
//   This routine prints out the contents of each element of the list, 
// separated by a space.  It does not put a newline at the end of the list.
//   Notice that you can specialize ANY function of a template class, but 
// some compilers are more finicky about how you do it than others.  For the
// metrowerks compiler this specialization must come before the forced
// instantiation.
template<> int
GAListGenome<int>::write(ostream & os) const
{
  int *cur, *head;
  GAListIter<int> tmpiter(*this);
  if((head=tmpiter.head()) != 0) os << *head << " ";
  for(cur=tmpiter.next(); cur && cur != head; cur=tmpiter.next())
    os << *cur << " ";
  return os.fail() ? 1 : 0;
}
开发者ID:dbremner,项目名称:galib,代码行数:19,代码来源:ex11.C

示例13: toStream

bool TactileFinger::toStream(ostream &str) const
{
    str<<"name        "<<name<<endl;
    str<<"logic       "<<(directLogic?"direct":"inverse")<<endl;
    str<<"output_gain "<<outputGain<<endl;

    if (str.fail())
        return false;
    else
        return true;
}
开发者ID:Karma-Revolutions,项目名称:icub-main,代码行数:11,代码来源:tactileFingers.cpp

示例14: toStream

bool SpringyFinger::toStream(ostream &str) const
{
    str<<"name        "<<name<<endl;
    str<<"calib_vel   "<<calibratingVelocity<<endl;
    str<<"output_gain "<<outputGain<<endl;
    str<<"calibrated  "<<(calibrated?"true":"false")<<endl;
    str<<"scaler      "<<("("+string(scaler.toString().c_str())+")").c_str()<<endl;
    str<<"lssvm       "<<("("+string(lssvm.toString().c_str())+")").c_str()<<endl;

    return !str.fail();
}
开发者ID:apostroph,项目名称:icub-main,代码行数:11,代码来源:springyFingers.cpp

示例15: writeLines

//------------------------------------------------------------------------------
// writeLines (vector <Line>, ostream) : Requests the XGremlin writelines string
// from each Line in the vector at arg1 and sends this string to the stream at
// arg2.
//
void writeLines (vector <Line> Lines, ostream &Output = std::cout) throw (const char*) {
  if (Lines[0].wavCorr () != 0.0) {
    Output << "  WAVENUMBER CORRECTION APPLIED: wavcorr =   " 
      << Lines[0].wavCorr () << endl;
  }
  else {
    Output << writelines_header::WaveCorr << endl;
  }
  Output << writelines_header::AirCorr << endl;
  Output << writelines_header::IntCal << endl;
  Output << writelines_header::Columns << endl;
  if (Output.fail()) throw "the file header";
  for (unsigned int i = 0; i < Lines.size (); i ++) {
    Output << Lines[i].getLineString() << endl;
    if (Output.fail ()) {
      ostringstream oss;
      oss << "line " << Lines[i].line ();
      throw oss.str().c_str();
    }
  }
}
开发者ID:Christian-Clear,项目名称:xgtools,代码行数:26,代码来源:lineio.cpp


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