#ifndef BSON2KSATCLAUSE_CONVERTER_H
#define BSON2KSATCLAUSE_CONVERTER_H

#include "util/convert.h"
#include "util/ksatinstance.h"

#include "bsoncxx/document/view.hpp"
#include "bsoncxx/array/view.hpp"
#include "bsoncxx/document/element.hpp"
#include "bsoncxx/types.hpp"

namespace satlab
{
/*
using BSON2KSATCLAUSE_CONVERTER = Converter<KSATinstance::CLAUSE,
                                            bsoncxx::array::element>;
                                            
template<>
class Converter<KSATinstance::CLAUSE, bsoncxx::array::element>
{
public:
    KSATinstance::CLAUSE convert(const bsoncxx::array::element& docView);
};

KSATinstance::CLAUSE
BSON2KSATCLAUSE_CONVERTER::convert(const bsoncxx::array::element& docView)
{
    KSATinstance::CLAUSE clause;
    
    for(auto lit : static_cast<bsoncxx::array::view>(docView.get_array()))
    {
        clause.push_back(lit.get_int32());
    }
    
    return clause;
}
*/

namespace types
{
    
template<typename = KSATinstance::CLAUSE, typename = bsoncxx::array::element>
KSATinstance::CLAUSE convert(const bsoncxx::array::element& docView)
{
    KSATinstance::CLAUSE clause;
    
    for(auto lit : static_cast<bsoncxx::array::view>(docView.get_array()))
    {
        clause.push_back(lit.get_int32());
    }
    
    return clause;
}

}

}

#endif // BSON2KSATCLAUSE_CONVERTER_H
