From e9b4aae524c768e0bd24eb390381b0856a91158f Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Fri, 23 Aug 2024 20:47:29 -0500 Subject: [PATCH] istream parse rectangles --- src/location.cpp | 17 +++++++++++++++++ src/location.hpp | 1 + 2 files changed, 18 insertions(+) diff --git a/src/location.cpp b/src/location.cpp index 91e8844c..e4b267a6 100644 --- a/src/location.cpp +++ b/src/location.cpp @@ -269,6 +269,23 @@ std::ostream& operator<< (std::ostream& out, rectangle r) { return out; } +std::istream& operator>> (std::istream& in, rectangle& r) { + location tl; + location br; + in.get(); // { + in >> tl; + in.get(); // + in.get(); // - + in.get(); // + in >> br; + in.get(); // } + r.top = tl.y; + r.left = tl.x; + r.bottom = br.y; + r.right = br.x; + return in; +} + std::ostream& operator<< (std::ostream& out, info_rect_t r) { out << static_cast(r); out << " -- \"" << r.descr << '"'; diff --git a/src/location.hpp b/src/location.hpp index da69c67c..7080794f 100644 --- a/src/location.hpp +++ b/src/location.hpp @@ -169,6 +169,7 @@ std::istream& operator>> (std::istream& in, location& l); std::ostream& operator<< (std::ostream& out, spec_loc_t l); std::ostream& operator<< (std::ostream& out, sign_loc_t l); std::ostream& operator<< (std::ostream& out, rectangle r); +std::istream& operator>> (std::istream& in, rectangle& r); std::ostream& operator<< (std::ostream& out, info_rect_t r); #endif