#ifndef MINISAT_RESULT_2_BSON
#define MINISAT_RESULT_2_BSON

#include "util/convert.h"
#include "util/minisatresult.h"
#include "util/ksatModel2bson.h"
#include "util/minisatStats2bson.h"

#include "bsoncxx/document/value.hpp"
#include "bsoncxx/builder/stream/document.hpp"

namespace satlab
{

    
template<typename = bsoncxx::builder::stream::document, typename = MinisatResult>
bsoncxx::builder::stream::document convert(const MinisatResult& result)
{
    using ARRAY_BUILDER = bsoncxx::builder::stream::array;
    using DOCUMENT_BUILDER = bsoncxx::builder::stream::document;
    
    DOCUMENT_BUILDER builder;
    
    builder << "satisfiable" << result.getSatisfiable()
            << "model" << convert<ARRAY_BUILDER>(result.getModel()).view()
            << "stats" << convert<DOCUMENT_BUILDER>(result.getStats()).view();
    
    return builder;
}


}

#endif // MINISAT_RESULT_2_BSON
