70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#ifndef BSON2KSAT_CONVERTER_H
|
|
#define BSON2KSAT_CONVERTER_H
|
|
|
|
#include "bsoncxx/document/view.hpp"
|
|
#include "bsoncxx/array/view.hpp"
|
|
#include "bsoncxx/types.hpp"
|
|
|
|
#include "util/convert.h"
|
|
#include "util/ksatinstance.h"
|
|
#include "util/bson2ksatClauseConverter.h"
|
|
|
|
namespace satlab
|
|
{
|
|
|
|
namespace types
|
|
{
|
|
|
|
template<typename = KSATinstance, typename = bsoncxx::document::view>
|
|
KSATinstance convert(const bsoncxx::document::view& docView)
|
|
{
|
|
using CLAUSE = KSATinstance::CLAUSE;
|
|
using CLAUSE_DOC = const bsoncxx::array::element&;
|
|
|
|
KSATinstance ksat;
|
|
|
|
bsoncxx::array::view clauses = docView["clauses"].get_array();
|
|
|
|
for(auto clause : clauses)
|
|
{
|
|
ksat.addClause(convert<CLAUSE, CLAUSE_DOC>(clause));
|
|
}
|
|
|
|
|
|
return ksat;
|
|
}
|
|
|
|
}
|
|
/*
|
|
using BSON2KSAT_CONVERTER = Converter<KSATinstance, bsoncxx::document::view>;
|
|
|
|
template<>
|
|
class Converter<KSATinstance, bsoncxx::document::view>
|
|
{
|
|
public:
|
|
KSATinstance convert(const bsoncxx::document::view& docView);
|
|
|
|
private:
|
|
BSON2KSATCLAUSE_CONVERTER clauseConverter;
|
|
};
|
|
|
|
KSATinstance BSON2KSAT_CONVERTER::convert(const bsoncxx::document::view& docView)
|
|
{
|
|
KSATinstance ksat;
|
|
|
|
bsoncxx::array::view clauses = docView["clauses"].get_array();
|
|
|
|
for(auto clause : clauses)
|
|
{
|
|
ksat.addClause(clauseConverter.convert(clause));
|
|
}
|
|
|
|
|
|
return ksat;
|
|
}
|
|
*/
|
|
|
|
}
|
|
|
|
#endif // BSON2KSAT_CONVERTER_H
|