Commit f8a58710 authored by Damien Leroux's avatar Damien Leroux
Browse files

Implemented wrapper around [io]?fstream.

parent d50bbd5b
......@@ -6,7 +6,7 @@
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include "file.h"
#include "error.h"
#include "chrono.h"
......
......@@ -359,7 +359,7 @@ struct bn_message_updater_type {
}
void
file_io_computer(std::ifstream& ifs, factor_dic_type& fdic, interface_dic_type& idic)
file_io_computer(ifile& ifs, factor_dic_type& fdic, interface_dic_type& idic)
{
rw_base rw;
ptrdiff_t key;
......@@ -376,7 +376,7 @@ struct bn_message_updater_type {
}
void
file_io_computer(std::ofstream& ofs, factor_dic_type& /*fdic*/, interface_dic_type& /*idic*/)
file_io_computer(ofile& ofs, factor_dic_type& /*fdic*/, interface_dic_type& /*idic*/)
{
rw_base()(ofs, (ptrdiff_t) m_computer.get());
}
......@@ -503,7 +503,7 @@ struct bn_factor_interface_type : public bn_message_computer_type {
}
void
file_io_factors(std::ofstream& ofs, factor_dic_type&)
file_io_factors(ofile& ofs, factor_dic_type&)
{
rw_base rw;
rw(ofs, m_factors.size());
......@@ -513,7 +513,7 @@ struct bn_factor_interface_type : public bn_message_computer_type {
}
void
file_io_factors(std::ifstream& ifs, factor_dic_type& factor_dic)
file_io_factors(ifile& ifs, factor_dic_type& factor_dic)
{
rw_base rw;
ptrdiff_t f;
......@@ -835,7 +835,7 @@ struct bn_factor_type : public bn_message_computer_type {
}
void
file_io_interfaces(std::ofstream& ofs, interface_dic_type&)
file_io_interfaces(ofile& ofs, interface_dic_type&)
{
std::vector<ptrdiff_t> vitf;
vitf.reserve(m_interfaces.size());
......@@ -844,7 +844,7 @@ struct bn_factor_type : public bn_message_computer_type {
}
void
file_io_interfaces(std::ifstream& ifs, interface_dic_type& interface_dic)
file_io_interfaces(ifile& ifs, interface_dic_type& interface_dic)
{
std::vector<ptrdiff_t> vitf;
rw_base()(ifs, vitf);
......@@ -1769,7 +1769,7 @@ struct factor_graph {
#endif
template <typename V>
void file_io_dic(std::ofstream& ofs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>&)
void file_io_dic(ofile& ofs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>&)
{
rw_base rw;
if (rw.fourcc(ofs, _4cc)) { return; }
......@@ -1781,7 +1781,7 @@ struct factor_graph {
}
template <typename V>
void file_io_dic(std::ifstream& ifs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>& dic)
void file_io_dic(ifile& ifs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>& dic)
{
rw_base rw;
if (rw.fourcc(ifs, _4cc)) { return; }
......@@ -1837,8 +1837,8 @@ struct factor_graph {
MSG_DEBUG("file i/o m_noise after=" << m_noise);
}
void save(const std::string& filename) { std::ofstream ofs(filename); file_io(ofs); }
void load(const std::string& filename) { std::ifstream ifs(filename); file_io(ifs); }
void save(const std::string& filename) { ofile ofs(filename); file_io(ofs); }
void load(const std::string& filename) { ifile ifs(filename); file_io(ifs); }
private:
std::map<size_t, std::vector<bn_label_type>> m_variable_domains;
......
......@@ -257,7 +257,7 @@ struct bn_factor_interface_type {
}
void
file_io_factors(std::ofstream& ofs, factor_dic_type&)
file_io_factors(ofile& ofs, factor_dic_type&)
{
rw_base rw;
rw(ofs, (ptrdiff_t) m_f1.get());
......@@ -265,7 +265,7 @@ struct bn_factor_interface_type {
}
void
file_io_factors(std::ifstream& ifs, factor_dic_type& factor_dic)
file_io_factors(ifile& ifs, factor_dic_type& factor_dic)
{
rw_base rw;
ptrdiff_t f1, f2;
......@@ -544,7 +544,7 @@ struct bn_factor_type {
}
void
file_io_interfaces(std::ofstream& ofs, interface_dic_type&)
file_io_interfaces(ofile& ofs, interface_dic_type&)
{
std::vector<ptrdiff_t> vitf;
vitf.reserve(m_interfaces.size());
......@@ -553,7 +553,7 @@ struct bn_factor_type {
}
void
file_io_interfaces(std::ifstream& ifs, interface_dic_type& interface_dic)
file_io_interfaces(ifile& ifs, interface_dic_type& interface_dic)
{
std::vector<ptrdiff_t> vitf;
rw_base()(ifs, vitf);
......@@ -1257,7 +1257,7 @@ struct factor_graph {
}
template <typename V>
void file_io_dic(std::ofstream& ofs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>&)
void file_io_dic(ofile& ofs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>&)
{
rw_base rw;
if (rw.fourcc(ofs, _4cc)) { return; }
......@@ -1269,7 +1269,7 @@ struct factor_graph {
}
template <typename V>
void file_io_dic(std::ifstream& ifs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>& dic)
void file_io_dic(ifile& ifs, const char* _4cc, std::vector<std::shared_ptr<V>>& data, std::map<ptrdiff_t, std::shared_ptr<V>>& dic)
{
rw_base rw;
if (rw.fourcc(ifs, _4cc)) { return; }
......@@ -1318,8 +1318,8 @@ struct factor_graph {
}
}
void save(const std::string& filename) { std::ofstream ofs(filename); file_io(ofs); }
void load(const std::string& filename) { std::ifstream ifs(filename); file_io(ifs); }
void save(const std::string& filename) { ofile ofs(filename); file_io(ofs); }
void load(const std::string& filename) { ifile ifs(filename); file_io(ifs); }
private:
std::map<size_t, std::vector<bn_label_type>> m_variable_domains;
......
......@@ -8,7 +8,7 @@
#include <unordered_set>
#include <string>
#include <iostream>
#include <fstream>
#include "file.h"
#include <cstring>
#include "eigen.h"
......@@ -21,7 +21,7 @@
/** FOURCC **/
inline
bool check_fourcc(std::ifstream& ifs, const char* fourcc)
bool check_fourcc(ifile& ifs, const char* fourcc)
{
char buf[4] = {0, 0, 0, 0};
ifs.read(buf, 4);
......@@ -29,7 +29,7 @@ bool check_fourcc(std::ifstream& ifs, const char* fourcc)
}
inline
void write_fourcc(std::ofstream& ofs, const char* fourcc)
void write_fourcc(ofile& ofs, const char* fourcc)
{
ofs.write(fourcc, 4);
}
......@@ -37,13 +37,13 @@ void write_fourcc(std::ofstream& ofs, const char* fourcc)
/** SIZE_T **/
inline
void write_size(std::ofstream& ofs, size_t sz)
void write_size(ofile& ofs, size_t sz)
{
ofs.write((const char*) &sz, sizeof sz);
}
inline
size_t read_size(std::ifstream& ifs)
size_t read_size(ifile& ifs)
{
size_t ret;
ifs.read((char*) &ret, sizeof ret);
......@@ -53,13 +53,13 @@ size_t read_size(std::ifstream& ifs)
/** PTRDIFF_T **/
inline
void write_ptrdiff(std::ofstream& ofs, ptrdiff_t sz)
void write_ptrdiff(ofile& ofs, ptrdiff_t sz)
{
ofs.write((const char*) &sz, sizeof sz);
}
inline
ptrdiff_t read_ptrdiff(std::ifstream& ifs)
ptrdiff_t read_ptrdiff(ifile& ifs)
{
ptrdiff_t ret;
ifs.read((char*) &ret, sizeof ret);
......@@ -69,7 +69,7 @@ ptrdiff_t read_ptrdiff(std::ifstream& ifs)
/** STRING **/
inline
std::string read_str(std::ifstream& ifs)
std::string read_str(ifile& ifs)
{
size_t sz = read_size(ifs);
std::vector<char> tmp(sz);
......@@ -78,7 +78,7 @@ std::string read_str(std::ifstream& ifs)
}
inline
void write_str(std::ofstream& ofs, const std::string& s)
void write_str(ofile& ofs, const std::string& s)
{
write_size(ofs, s.size());
ofs.write(s.c_str(), s.size());
......@@ -87,13 +87,13 @@ void write_str(std::ofstream& ofs, const std::string& s)
/** DOUBLE **/
inline
void write_double(std::ofstream& ofs, double sz)
void write_double(ofile& ofs, double sz)
{
ofs.write((const char*) &sz, sizeof sz);
}
inline
double read_double(std::ifstream& ifs)
double read_double(ifile& ifs)
{
double ret;
ifs.read((char*) &ret, sizeof ret);
......@@ -103,13 +103,13 @@ double read_double(std::ifstream& ifs)
/** INT **/
inline
void write_int(std::ofstream& ofs, int sz)
void write_int(ofile& ofs, int sz)
{
ofs.write((const char*) &sz, sizeof sz);
}
inline
int read_int(std::ifstream& ifs)
int read_int(ifile& ifs)
{
int ret;
ifs.read((char*) &ret, sizeof ret);
......@@ -119,13 +119,13 @@ int read_int(std::ifstream& ifs)
/** CHAR **/
inline
void write_char(std::ofstream& ofs, char sz)
void write_char(ofile& ofs, char sz)
{
ofs.write((const char*) &sz, sizeof sz);
}
inline
char read_char(std::ifstream& ifs)
char read_char(ifile& ifs)
{
char ret;
ifs.read(&ret, sizeof ret);
......@@ -136,7 +136,7 @@ char read_char(std::ifstream& ifs)
/** FAST_POLYNOM **/
inline
void write_fast_polynom(std::ofstream& ofs, const fast_polynom& fp)
void write_fast_polynom(ofile& ofs, const fast_polynom& fp)
{
impl::f_polynom f = fp;
write_int(ofs, fp.value);
......@@ -149,7 +149,7 @@ void write_fast_polynom(std::ofstream& ofs, const fast_polynom& fp)
}
inline
fast_polynom read_fast_polynom(std::ifstream& ifs, int& original_key)
fast_polynom read_fast_polynom(ifile& ifs, int& original_key)
{
original_key = read_int(ifs);
impl::f_polynom ret = fast_polynom::zero;
......@@ -165,14 +165,14 @@ fast_polynom read_fast_polynom(std::ifstream& ifs, int& original_key)
/** ALGREBRAIC GENOTYPE **/
inline void write_algebraic_genotype(std::ofstream& ofs, const algebraic_genotype& ag)
inline void write_algebraic_genotype(ofile& ofs, const algebraic_genotype& ag)
{
ofs.write((const char*) &ag.genotype, sizeof ag.genotype);
ofs.write((const char*) &ag.type, sizeof ag.type);
write_int(ofs, ag.poly.value);
}
inline algebraic_genotype read_algebraic_genotype(std::ifstream& ifs, const std::map<int, fast_polynom>& pt)
inline algebraic_genotype read_algebraic_genotype(ifile& ifs, const std::map<int, fast_polynom>& pt)
{
algebraic_genotype ag;
ifs.read((char*) &ag.genotype, sizeof ag.genotype);
......@@ -183,7 +183,7 @@ inline algebraic_genotype read_algebraic_genotype(std::ifstream& ifs, const std:
/** GENOMATRIX **/
inline void write_genomatrix(std::ofstream& ofs, const GenoMatrix& mat)
inline void write_genomatrix(ofile& ofs, const GenoMatrix& mat)
{
write_fourcc(ofs, "SGEM");
/*std::map<decltype(fast_polynom::value), impl::f_polynom>*/
......@@ -209,7 +209,7 @@ inline void write_genomatrix(std::ofstream& ofs, const GenoMatrix& mat)
}
inline
void read_genomatrix(std::ifstream& ifs, GenoMatrix& mat)
void read_genomatrix(ifile& ifs, GenoMatrix& mat)
{
if (check_fourcc(ifs, "SGEM")) {
MSG_ERROR("File is not valid or has been corrupted", "");
......@@ -238,7 +238,7 @@ void read_genomatrix(std::ifstream& ifs, GenoMatrix& mat)
/** GENERATION_RS **/
inline void write_geno_matrix(std::ofstream& ofs, const geno_matrix* gen)
inline void write_geno_matrix(ofile& ofs, const geno_matrix* gen)
{
write_fourcc(ofs, "SGRS");
write_str(ofs, gen->name);
......@@ -250,7 +250,7 @@ inline void write_geno_matrix(std::ofstream& ofs, const geno_matrix* gen)
}
inline
geno_matrix* read_geno_matrix(std::ifstream& ifs)
geno_matrix* read_geno_matrix(ifile& ifs)
{
if (check_fourcc(ifs, "SGRS")) {
MSG_ERROR("File is not valid or has been corrupted", "");
......@@ -304,7 +304,7 @@ template <typename MATRIX_TYPE>
void resize_matrix(MATRIX_TYPE& m, size_t r, size_t c) { resize_matrix_impl<MATRIX_TYPE>()(m, r, c); }
template <typename SCALAR, int ROW, int COL, int C, int D, int E>
void read_matrix(std::ifstream& ifs, Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat)
void read_matrix(ifile& ifs, Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat)
{
size_t scalar_sz = read_size(ifs);
if (scalar_sz != sizeof(SCALAR)) {
......@@ -323,7 +323,7 @@ void read_matrix(std::ifstream& ifs, Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& m
}
template <typename SCALAR, int ROW, int COL, int C, int D, int E>
void write_matrix(std::ofstream& ofs, const Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat)
void write_matrix(ofile& ofs, const Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat)
{
write_size(ofs, sizeof(SCALAR));
write_size(ofs, mat.rows());
......@@ -333,7 +333,7 @@ void write_matrix(std::ofstream& ofs, const Eigen::Matrix<SCALAR, ROW, COL, C, D
template <typename V, typename READ_ELEM_FUNC>
void read_vector(std::ifstream& ifs, std::vector<V>& vec, READ_ELEM_FUNC read_elem)
void read_vector(ifile& ifs, std::vector<V>& vec, READ_ELEM_FUNC read_elem)
{
size_t sz = read_size(ifs);
vec.clear();
......@@ -345,7 +345,7 @@ void read_vector(std::ifstream& ifs, std::vector<V>& vec, READ_ELEM_FUNC read_el
template <typename V, typename WRITE_ELEM_FUNC>
void write_vector(std::ofstream& ofs, const std::vector<V>& vec, WRITE_ELEM_FUNC write_elem)
void write_vector(ofile& ofs, const std::vector<V>& vec, WRITE_ELEM_FUNC write_elem)
{
write_size(ofs, vec.size());
for (const auto& e: vec) {
......@@ -357,7 +357,7 @@ void write_vector(std::ofstream& ofs, const std::vector<V>& vec, WRITE_ELEM_FUNC
/** LABEL_TYPE **/
inline
label_type read_label(std::ifstream& ifs)
label_type read_label(ifile& ifs)
{
char f, s;
ifs >> f >> s;
......@@ -365,7 +365,7 @@ label_type read_label(std::ifstream& ifs)
}
inline
void write_label(std::ofstream& ofs, const label_type& l)
void write_label(ofile& ofs, const label_type& l)
{
ofs << l.first() << l.second();
}
......@@ -374,7 +374,7 @@ void write_label(std::ofstream& ofs, const label_type& l)
/** GENO_MATRIX **/
inline
void write_geno_matrix(std::ofstream& ofs, const geno_matrix& mat)
void write_geno_matrix(ofile& ofs, const geno_matrix& mat)
{
write_fourcc(ofs, "SGEM");
write_str(ofs, mat.name);
......@@ -391,7 +391,7 @@ void write_geno_matrix(std::ofstream& ofs, const geno_matrix& mat)
}
inline
void read_geno_matrix(std::ifstream& ifs, geno_matrix& mat)
void read_geno_matrix(ifile& ifs, geno_matrix& mat)
{
if (check_fourcc(ifs, "SGEM")) {
MSG_ERROR("File is not valid or has been corrupted", "");
......@@ -412,13 +412,13 @@ void read_geno_matrix(std::ifstream& ifs, geno_matrix& mat)
inline
void write_geno_matrix(std::ofstream& ofs, const geno_matrix* ptr)
void write_geno_matrix(ofile& ofs, const geno_matrix* ptr)
{
write_geno_matrix(ofs, *ptr);
}
inline
geno_matrix* read_geno_matrix(std::ifstream& ifs)
geno_matrix* read_geno_matrix(ifile& ifs)
{
geno_matrix* ret = new geno_matrix();
read_geno_matrix(ifs, *ret);
......@@ -431,7 +431,7 @@ geno_matrix* read_geno_matrix(std::ifstream& ifs)
template <class DERIVED>
struct rw_any {
bool fourcc(std::ifstream& ifs, const char* cc)
bool fourcc(ifile& ifs, const char* cc)
{
if (check_fourcc(ifs, cc)) {
MSG_ERROR("File is not valid or has been corrupted (expected " << cc << ')', "");
......@@ -440,7 +440,7 @@ struct rw_any {
return false;
}
bool fourcc(std::ofstream& ofs, const char* cc)
bool fourcc(ofile& ofs, const char* cc)
{
write_fourcc(ofs, cc);
return false;
......@@ -450,32 +450,32 @@ struct rw_any {
DERIVED& ref() { return *dynamic_cast<DERIVED*>(this); }
void operator () (std::ifstream& ifs, std::string& s) { s = read_str(ifs); }
void operator () (std::ofstream& ofs, const std::string& s) { write_str(ofs, s); }
void operator () (ifile& ifs, std::string& s) { s = read_str(ifs); }
void operator () (ofile& ofs, const std::string& s) { write_str(ofs, s); }
void operator () (std::ifstream& ifs, char& i) { i = read_char(ifs); }
void operator () (std::ofstream& ofs, char i) { write_char(ofs, i); }
void operator () (ifile& ifs, char& i) { i = read_char(ifs); }
void operator () (ofile& ofs, char i) { write_char(ofs, i); }
void operator () (std::ifstream& ifs, int& i) { i = read_int(ifs); }
void operator () (std::ofstream& ofs, int i) { write_int(ofs, i); }
void operator () (ifile& ifs, int& i) { i = read_int(ifs); }
void operator () (ofile& ofs, int i) { write_int(ofs, i); }
void operator () (std::ifstream& ifs, bool& i) { i = !!read_char(ifs); }
void operator () (std::ofstream& ofs, bool i) { write_char(ofs, i); }
void operator () (ifile& ifs, bool& i) { i = !!read_char(ifs); }
void operator () (ofile& ofs, bool i) { write_char(ofs, i); }
void operator () (std::ifstream& ifs, double& i) { i = read_double(ifs); }
void operator () (std::ofstream& ofs, double i) { write_double(ofs, i); }
void operator () (ifile& ifs, double& i) { i = read_double(ifs); }
void operator () (ofile& ofs, double i) { write_double(ofs, i); }
void operator () (std::ifstream& ifs, size_t& i) { i = read_size(ifs); }
void operator () (std::ofstream& ofs, size_t i) { write_size(ofs, i); }
void operator () (ifile& ifs, size_t& i) { i = read_size(ifs); }
void operator () (ofile& ofs, size_t i) { write_size(ofs, i); }
void operator () (std::ifstream& ifs, ptrdiff_t& i) { i = read_ptrdiff(ifs); }
void operator () (std::ofstream& ofs, ptrdiff_t i) { write_ptrdiff(ofs, i); }
void operator () (ifile& ifs, ptrdiff_t& i) { i = read_ptrdiff(ifs); }
void operator () (ofile& ofs, ptrdiff_t i) { write_ptrdiff(ofs, i); }
void operator () (std::ifstream& ifs, label_type& l) { l = {read_char(ifs), read_char(ifs)}; }
void operator () (std::ofstream& ofs, const label_type& l) { write_char(ofs, l.first()); write_char(ofs, l.second()); }
void operator () (ifile& ifs, label_type& l) { l = {read_char(ifs), read_char(ifs)}; }
void operator () (ofile& ofs, const label_type& l) { write_char(ofs, l.first()); write_char(ofs, l.second()); }
template <typename V>
void operator () (std::ifstream& ifs, std::set<V>& vec)
void operator () (ifile& ifs, std::set<V>& vec)
{
if (fourcc(ifs, "OSET")) { return; }
size_t sz = read_size(ifs);
......@@ -488,7 +488,7 @@ struct rw_any {
}
template <typename V>
void operator () (std::ofstream& ofs, const std::set<V>& vec)
void operator () (ofile& ofs, const std::set<V>& vec)
{
if (fourcc(ofs, "OSET")) { return; }
write_size(ofs, vec.size());
......@@ -499,7 +499,7 @@ struct rw_any {
template <typename V>
void operator () (std::ifstream& ifs, std::unordered_set<V>& vec)
void operator () (ifile& ifs, std::unordered_set<V>& vec)
{
if (fourcc(ifs, "USET")) { return; }
size_t sz = read_size(ifs);
......@@ -512,7 +512,7 @@ struct rw_any {
}
template <typename V>
void operator () (std::ofstream& ofs, const std::unordered_set<V>& vec)
void operator () (ofile& ofs, const std::unordered_set<V>& vec)
{
if (fourcc(ofs, "USET")) { return; }
write_size(ofs, vec.size());
......@@ -521,10 +521,10 @@ struct rw_any {
}
}
void operator () (std::ifstream& ifs, std::vector<bool>::reference i) { i = !!read_char(ifs); }
void operator () (ifile& ifs, std::vector<bool>::reference i) { i = !!read_char(ifs); }
template <typename V, typename A>
void operator () (std::ifstream& ifs, std::vector<V, A>& vec)
void operator () (ifile& ifs, std::vector<V, A>& vec)
{
if (fourcc(ifs, "VECT")) { return; }
size_t sz = read_size(ifs);
......@@ -537,7 +537,7 @@ struct rw_any {
}
template <typename V, typename A>
void operator () (std::ofstream& ofs, const std::vector<V, A>& vec)
void operator () (ofile& ofs, const std::vector<V, A>& vec)
{
if (fourcc(ofs, "VECT")) { return; }
write_size(ofs, vec.size());
......@@ -547,7 +547,7 @@ struct rw_any {
}
template <typename V, typename A, typename RWElem>
void operator () (std::ifstream& ifs, std::vector<V, A>& vec, RWElem rw_elem)
void operator () (ifile& ifs, std::vector<V, A>& vec, RWElem rw_elem)
{
if (fourcc(ifs, "VECT")) { return; }
size_t sz = read_size(ifs);
......@@ -560,7 +560,7 @@ struct rw_any {
}
template <typename V, typename A, typename RWElem>
void operator () (std::ofstream& ofs, std::vector<V, A>& vec, RWElem rw_elem)
void operator () (ofile& ofs, std::vector<V, A>& vec, RWElem rw_elem)
{
if (fourcc(ofs, "VECT")) { return; }
write_size(ofs, vec.size());
......@@ -570,7 +570,7 @@ struct rw_any {
}
template <typename K, typename V, typename A, typename C>
void operator () (std::ifstream& ifs, std::map<K, V, A, C>& map)
void operator () (ifile& ifs, std::map<K, V, A, C>& map)
{
if (fourcc(ifs, "MAP ")) { return; }
size_t count = read_size(ifs);
......@@ -585,7 +585,7 @@ struct rw_any {
}
template <typename K, typename V, typename A, typename C>
void operator () (std::ofstream& ofs, const std::map<K, V, A, C>& map)
void operator () (ofile& ofs, const std::map<K, V, A, C>& map)
{
if (fourcc(ofs, "MAP ")) { return; }
write_size(ofs, map.size());
......@@ -596,15 +596,15 @@ struct rw_any {
}
template <typename SCALAR, int ROW, int COL, int C, int D, int E>
void operator () (std::ifstream& ifs, Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat) { read_matrix(ifs, mat); }
void operator () (ifile& ifs, Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat) { read_matrix(ifs, mat); }
template <typename SCALAR, int ROW, int COL, int C, int D, int E>
void operator () (std::ofstream& ofs, const Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat) { write_matrix(ofs, mat); }
void operator () (ofile& ofs, const Eigen::Matrix<SCALAR, ROW, COL, C, D, E>& mat) { write_matrix(ofs, mat); }
void operator () (std::ifstream& ifs, geno_matrix& mat) { read_geno_matrix(ifs, mat); }
void operator () (std::ofstream& ofs, geno_matrix& mat) { write_geno_matrix(ofs, mat); }
void operator () (ifile& ifs, geno_matrix& mat) { read_geno_matrix(ifs, mat); }
void operator () (ofile& ofs, geno_matrix& mat) { write_geno_matrix(ofs, mat); }
void operator () (std::ifstream& ifs, std::shared_ptr<geno_matrix>& ptr)
void operator () (ifile& ifs, std::shared_ptr<geno_matrix>& ptr)
{
ptr.reset();
ptr = std::make_shared<geno_matrix>();
......@@ -614,7 +614,7 @@ struct rw_any {
}
}
void operator () (std::ofstream& ofs, const std::shared_ptr<geno_matrix>& ptr)
void operator () (ofile& ofs, const std::shared_ptr<geno_matrix>& ptr)
{
if (ptr) {
ref() (ofs, *ptr.get());
......@@ -726,7 +726,7 @@ struct LV_database {
LV_database
load_from(const std::string& filename)