# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1219827004 -7200
# Node ID d0aae16df1bb28a8cce519d53b1004399b71d9a7
# Parent  f0b89f24274560f96db7740ebb807719f5e5e369
Stream operators for Point and BoundingBox classes (ticket #126)
 - Add operator<< and operator>> for BoundingBox.
 - operator<< of Point gives space-less output.

diff -r f0b89f242745 -r d0aae16df1bb lemon/dim2.h
--- a/lemon/dim2.h	Mon Aug 18 20:33:11 2008 +0200
+++ b/lemon/dim2.h	Wed Aug 27 10:50:04 2008 +0200
@@ -221,7 +221,7 @@
   template<typename T>
   inline std::ostream& operator<<(std::ostream &os, const Point<T>& z)
   {
-    os << "(" << z.x << ", " << z.y << ")";
+    os << "(" << z.x << "," << z.y << ")";
     return os;
   }
 
@@ -533,6 +533,47 @@
     };//class Boundingbox
 
 
+  ///Read a bounding box from a stream
+
+  ///Read a bounding box from a stream.
+  ///\relates BoundingBox
+  template<typename T>
+  inline std::istream& operator>>(std::istream &is, BoundingBox<T>& b) {
+    char c;
+    Point<T> p;
+    if (is >> c) {
+      if (c != '(') is.putback(c);
+    } else {
+      is.clear();
+    }
+    if (!(is >> p)) return is;
+    b.bottomLeft(p);
+    if (is >> c) {
+      if (c != ',') is.putback(c);
+    } else {
+      is.clear();
+    }
+    if (!(is >> p)) return is;
+    b.topRight(p);
+    if (is >> c) {
+      if (c != ')') is.putback(c);
+    } else {
+      is.clear();
+    }
+    return is;
+  }
+
+  ///Write a bounding box to a stream
+
+  ///Write a bounding box to a stream.
+  ///\relates BoundingBox
+  template<typename T>
+  inline std::ostream& operator<<(std::ostream &os, const BoundingBox<T>& b)
+  {
+    os << "(" << b.bottomLeft() << "," << b.topRight() << ")";
+    return os;
+  }
+
   ///Map of x-coordinates of a \ref Point "Point"-map
 
   ///\ingroup maps