Mercurial > hg > nsaunier > traffic-intelligence
comparison c/utils.cpp @ 20:ef0d7caf8e91
draft code for feature saving (UBC format)
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Sat, 28 Nov 2009 01:56:46 -0500 |
| parents | ace29ecfb846 |
| children | a52653dca25d |
comparison
equal
deleted
inserted
replaced
| 19:5a21d2cfee44 | 20:ef0d7caf8e91 |
|---|---|
| 1 // | 1 #include "utils.hpp" |
| 2 | |
| 3 #include <iostream> | |
| 4 #include <fstream> | |
| 5 | |
| 6 using namespace std; | |
| 7 | |
| 8 void openWriteScientificPrecision(ofstream& out, const string& filename, const int& precision) { | |
| 9 ::openWritePrecision(out, filename, precision); | |
| 10 out.setf(ios::scientific); | |
| 11 } | |
| 12 | |
| 13 void openWritePrecision(ofstream& out, const string& filename, const int& precision) { | |
| 14 out.open(filename.c_str(), ios::binary); | |
| 15 ::checkFileOpening(out, filename, "openWritePrecision"); | |
| 16 out.precision(precision); | |
| 17 } | |
| 18 | |
| 19 bool openCheck(ifstream& f, const string& filename, const string& callingFunctionName) { | |
| 20 if (!f.is_open()) { | |
| 21 cerr << "Pb opening file " << filename << " in " << callingFunctionName << endl; | |
| 22 return false; | |
| 23 } else | |
| 24 return true; | |
| 25 } | |
| 26 | |
| 27 bool openCheck(ofstream& f, const string& filename, const string& callingFunctionName) { | |
| 28 if (!f.is_open()) { | |
| 29 cerr << "Pb opening file " << filename << " in " << callingFunctionName << endl; | |
| 30 return false; | |
| 31 } else | |
| 32 return true; | |
| 33 } |
