#include "qlang.hpp" #include #include #include #include #include struct Doctor { std::string nombre_; std::string apellidos_; public: Doctor(const std::string & nombre, const std::string & apellidos) : nombre_(nombre), apellidos_(apellidos) {} }; BOOST_FUSION_ADAPT_STRUCT(Doctor, (std::string, nombre_) (std::string, apellidos_)) using namespace boost::qlang; using namespace std; #define foreach BOOST_FOREACH int main(int argc, char * argv[]) { vector numeros = {2, 4, 37, 5, 8, 20, 34}; vector doctores = { {"German", "Gallardone"}, {"Pedro", "Ruiz"}, {"Hilario", "Pinose"}, {"Manolito", "Gafotas"}, {"Tomas", "Todonte"} }; auto consulta = from(numeros).where([](int i) { return i < 10; }). select(fields::full_object); auto consulta2 = from(doctores).where([](const Doctor & d) { return d.apellidos_ == "Ruiz"; }). select(fields::_1); /*Nested query: Planned auto consulta3 = from(consulta2).where([](const Doctor & d) { return d.nombre_ == "Pedro"; }). select(fields::full_object); */ for (auto it = consulta.begin(); it != consulta.end(); ++it) { cout << *it << endl; } for (auto it = consulta2.begin(); it != consulta2.end(); ++it) { cout << it->get<0>() << endl; } cout << endl; doctores.push_back({"Manolo", "Ruiz"}); for (auto it = consulta2.begin(); it != consulta2.end(); ++it) { cout << it->get<0>() << endl; } /* for (auto it = consulta3.begin(); it != consulta2.end(); ++it) { cout << it->get<0>() << endl; } */ }