本文整理汇总了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;
}
示例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;
}
示例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");
}
示例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;
}
示例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.");
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
}
}