123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #include "galaxy.h"
- #include <ostream>
- bool buysell::operator==(const buysell &rhs) const {
- return ((foe[0] == rhs.foe[0]) && (foe[1] == rhs.foe[1]) &&
- (foe[2] == rhs.foe[2]));
- }
- std::ostream &operator<<(std::ostream &os, const buysell &bs) {
- os << bs.foe[0] << bs.foe[1] << bs.foe[2];
- return os;
- }
- bool buysell_text::operator==(const buysell_text &rhs) const {
- return ((txt[0] == rhs.txt[0]) && (txt[1] == rhs.txt[1]) &&
- (txt[2] == rhs.txt[2]));
- }
- std::ostream &operator<<(std::ostream &os, const buysell_text &bst) {
- os << '"' << bst.txt[0] << bst.txt[1] << bst.txt[2] << '"';
- return os;
- }
- #define GTEST_COUT std::cerr << "[ ] [ INFO ]"
- struct port parse_portcim(const std::string line) {
- struct port p;
- p.sector = std::stoi(line);
-
- static std::regex portrx(
- "[ ]*([0-9]+) (.)[ ]+([0-9]+)[ ]+([0-9]+%) (.)[ "
- "]+([0-9]+)[ ]+([0-9]+%) (.)[ ]+([0-9]+)[ ]+([0-9]+%)[ ]*",
- std::regex_constants::ECMAScript);
-
-
-
-
-
-
-
-
-
-
-
-
-
- buysell port_buysell;
- std::smatch matches;
- if (std::regex_match(line, matches, portrx)) {
-
- if (matches.size() != 11) {
-
- p.sector = 0;
- p.type = 0;
- return p;
- }
-
- p.sector = stoi(matches[1]);
-
-
-
-
- for (int x = 0; x < 3; ++x) {
- int pos = x * 3;
- port_buysell.foe[x] = matches[pos + 2] == "-";
- p.amount[x] = stoi(matches[pos + 3]);
- p.percent[x] = stoi(matches[pos + 4]);
- }
- p.type = type_from_buysell(port_buysell);
-
- return p;
- } else {
-
- p.type = 0;
- p.sector = 0;
- return p;
- }
- }
|