1
Fork 0
This repository has been archived on 2025-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
puzzle-wuzzle-generator/include/analyzed_grid.hpp
2014-02-18 16:13:35 +01:00

42 lines
895 B
C++

#pragma once
#include "dynamic_grid.hpp"
#include "solver.hpp"
#include "rules.hpp"
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/serialization.hpp>
#include <fstream>
template <typename Grid>
struct AnalyzedGrid {
Grid grid;
Solution<Grid> analysis;
BasicRules rules;
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int version){
ar & grid & analysis.solution_traces;
}
};
inline auto grid_from_file(std::string file_path){
std::ifstream file(file_path);
boost::archive::text_iarchive ar(file);
AnalyzedGrid<DynamicGrid> ret;
ar >> ret;
return ret;
}
inline auto grid_to_file(AnalyzedGrid<DynamicGrid> const & grid, std::string file_path){
std::ofstream file(file_path);
boost::archive::text_oarchive ar(file);
ar << grid;
}