diff --git a/src/kraken.cc b/src/kraken.cc index 6adfd8f..e228e55 100644 --- a/src/kraken.cc +++ b/src/kraken.cc @@ -1,5 +1,6 @@ #include +#include "csv/read-csv.hh" #include "csv/write-csv.hh" #include "engine/csv-engine-listener.hh" #include "engine/engine.hh" @@ -15,13 +16,17 @@ int main(int argc, char** argv) { } } - auto const orders = kraken::parse::parse_orders(std::cin); - auto listener = std::make_shared(); - auto engine = kraken::engine::Engine(listener, cross_behaviour); - engine.process_orders(orders); + for (std::string line; std::getline(std::cin, line);) { + auto const order = kraken::parse::parse_single_order( + kraken::csv::read_csv_line(line)); - kraken::csv::write_csv(std::cout, listener->output()); + engine.process_single_order(order); + + auto& output = listener->output(); + kraken::csv::write_csv(std::cout, output); + output.resize(0); + } }