kraken: refactor to interleave input and output
This commit is contained in:
parent
8bba52d3b9
commit
3998b9839f
|
@ -1,5 +1,6 @@
|
|||
#include <iostream>
|
||||
|
||||
#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<kraken::engine::CsvEngineListener>();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue