From f00082fdacc8a00e6ccd5e5afe11086200af191b Mon Sep 17 00:00:00 2001 From: Lev Date: Fri, 11 Jun 2021 13:54:42 -0500 Subject: [PATCH] Update implemented new version of stringsToOBE --- .../Topic 4/4.4.5/CSVReader.cpp | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/CM2005 Object Oriented Programming/Topic 4/4.4.5/CSVReader.cpp b/CM2005 Object Oriented Programming/Topic 4/4.4.5/CSVReader.cpp index 035e5e4..b9f44db 100644 --- a/CM2005 Object Oriented Programming/Topic 4/4.4.5/CSVReader.cpp +++ b/CM2005 Object Oriented Programming/Topic 4/4.4.5/CSVReader.cpp @@ -63,8 +63,8 @@ OrderBookEntry CSVReader::stringsToOBE(std::vector tokens) price = std::stod(tokens[3]); amount = std::stod(tokens[4]); }catch(const std::exception& e){ - std::cout << "Bad float! " << tokens[3]<< std::endl; - std::cout << "Bad float! " << tokens[4]<< std::endl; + std::cout << "CSVReader::stringsToOBE Bad float! " << tokens[3]<< std::endl; + std::cout << "CSVReader::stringsToOBE Bad float! " << tokens[4]<< std::endl; throw; } @@ -77,3 +77,30 @@ OrderBookEntry CSVReader::stringsToOBE(std::vector tokens) return obe; } +OrderBookEntry CSVReader::stringsToOBE(std::string priceString, + std::string amountString, + std::string timestamp, + std::string product, + OrderBookType orderType) +{ + double price, amount; + try + { + price = std::stod(priceString); + amount = std::stod(amountString); + } + catch(const std::exception& e) + { + std::cout << "CSVReader::stringsToOBE Bad float!" << priceString << std::endl; + std::cout << "CSVReader::stringsToOBE Bad float!" << amountString << std::endl; + throw; + } + + OrderBookEntry obe{price, + amount, + timestamp, + product, + orderType}; + + return obe; +} \ No newline at end of file