void solver_out (const ShExpPanel& pan, ofstream& out) throw (ShExpException) { if (!out) throw ShExpException ("Error: bad stream for results output.\n"); out.exceptions (ios_base:: badbit | ios_base:: failbit); out << scientific << setprecision (6); try { out << "\nPanel: " << pan.id() << endl; out << "----------------------------------------\n"; out << "Mach number: " << setw(15) << pan.mach() << endl; out << "pressure: " << setw(15) << pan.p() << " [Pa]\n"; out << "pressure coefficient: " << setw(15) << pan.cp() << endl; out << "density: " << setw(15) << pan.ro() << " [kg*m^-3]\n"; out << "temperature: " << setw(15) << pan.t() << " [K]\n"; out << "velocity: " << setw(15) << pan.vel() << " [m*s^-2]\n"; out << "velocity u: " << setw(15) << pan.u() << " [m*s^-2]\n"; out << "velocity v: " << setw(15) << pan.v() << " [m*s^-2]\n"; out << "local speed of sound: " << setw(15) << pan.a() << " [m*s^-2]\n"; out << "----------------------------------------\n"; } catch (ios_base:: failure) { throw; } }
void CRunner::CheckAndOpenFileForWriting(ofstream & file, const string& fileName) { file.open(fileName); file.exceptions(ofstream::badbit); if (!file.is_open()) { throw ofstream::failure(MESSAGE_FAILED_OPEN + fileName + MESSAGE_FAILED_OPEN_FOR_WRITING); } }
void openOutputFile(const string fileName, ofstream &handle){ handle.exceptions(ofstream::failbit | ofstream::badbit); try{ handle.open(fileName); } catch (const ofstream::failure &e){ cerr << e.what() << endl; cerr << "File " << fileName << " cannot be opened!" << endl; terminate(); } }
void __stdcall vcamOpenLog(int verbosity, char* message) { #ifdef _DEBUG { CAutoLock l(&debugLock); if (numUsers == 0) { BOOL ok = CreateDirectory(VCAM_DEBUG_DIRNAME, NULL); if (!ok && GetLastError() == ERROR_ALREADY_EXISTS) { ok = TRUE; } if (ok) { try { debugOut.exceptions(ios::failbit); debugOut.open(VCAM_DEBUG_FNAME, ios_base::app); // Truncate log if it's too big debugOut.seekp(0, ios_base::end); if (debugOut.tellp() > 1024 * 256) { debugOut.close(); debugOut.open(VCAM_DEBUG_FNAME, ios_base::trunc); } openedOK = TRUE; } catch (...) { openedOK = FALSE; } } else { openedOK = FALSE; } if (!openedOK && !showedLogWarning) { Msg("Couldn't open multicam log file,\r\nso no logging will be performed"); showedLogWarning = TRUE; } } numUsers++; } vcamLog(verbosity, "%s opened log, numUsers = %d", message, numUsers); #endif }
void parser_out (const ShExpPanel& pan, ofstream& out) throw (ShExpException) { if (!out) throw ShExpException ("Error: bad stream for results output.\n"); out.exceptions (ios_base:: badbit | ios_base:: failbit); out << scientific << setprecision (6); try { out << "\nPanel: " << pan.id() << endl; out << "----------------------------------------\n"; out << "Node 1: (" << pan.x1() << ":" << pan.y1() << ")\n"; out << "Node 2: (" << pan.x2() << ":" << pan.y2() << ")\n"; out << "Slope: " << setw(15) << pan.slp(RAD) << " [rad]\n"; out << "Relative area: " << setw(15) << pan.ar() << endl; out << "----------------------------------------\n"; } catch (ios_base:: failure) { throw; } }
int KiCadSCH::patchFile(ofstream &oFile) { string iline, oline, last_oline; modiFile_t currentpatch; int line_n; unsigned i; unsigned olineNbr = 0; iSCHfile.exceptions(std::ifstream::failbit | std::ifstream::badbit); oFile.exceptions(std::ifstream::failbit | std::ifstream::badbit); try{ last_oline = ""; for(line_n=0; true; line_n++){ getline(iSCHfile, iline); oline = iline; currentpatch.add = false; currentpatch.del = false; currentpatch.line = ""; currentpatch.lineNbr = 0; for(i=0;i<patchvec.size();i++){ if(line_n == patchvec[i].lineNbr){ currentpatch = patchvec[i]; patchvec[i].prevline = last_oline; if(currentpatch.add){ oFile << currentpatch.line << endl; olineNbr++; patchvec[i].olineNbr = olineNbr; } } } if(!currentpatch.del){ oFile << oline << endl; last_oline = oline; olineNbr++; if(patchvec.size()>i){ // if patchvec is empty patchvec[i].olineNbr = olineNbr; } }else{ if(patchvec.size()<i) patchvec[i].deletedline = oline; } } } catch(std::fstream::failure e){ if(iSCHfile.bad()) return -1; if(oFile.bad()) return -2; if(iSCHfile.fail()) return -1; if(oFile.fail()) return -2; if(iSCHfile.eof()){ iSCHfile.clear(); iSCHfile.seekg(0, ios::beg); return 0; } if(oFile.eof()) { oFile.clear(); return -2; } return -255; } return 0; }