implemented basics
This commit is contained in:
69
src/util/bson2ksatConverter.h
Normal file
69
src/util/bson2ksatConverter.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#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
|
Reference in New Issue
Block a user