#include "utils.hpp"

#include <iostream>
#include <fstream>

using namespace std;

void openWriteScientificPrecision(ofstream& out, const string& filename, const int& precision) {
  ::openWritePrecision(out, filename, precision);
  out.setf(ios::scientific);
}

void openWritePrecision(ofstream& out, const string& filename, const int& precision) {
  out.open(filename.c_str(), ios::binary);
  ::checkFileOpening(out, filename, "openWritePrecision");
  out.precision(precision);
}

bool openCheck(ifstream& f, const string& filename, const string& callingFunctionName) {
  if (!f.is_open()) {
    cerr << "Pb opening file " << filename << " in " << callingFunctionName << endl;
    return false;
  } else
    return true;
}

bool openCheck(ofstream& f, const string& filename, const string& callingFunctionName) {
  if (!f.is_open()) {
    cerr << "Pb opening file " << filename << " in " << callingFunctionName << endl;
    return false;
  } else
    return true;
}
