summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-13 00:52:27 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-13 00:56:47 +0100
commitcc162d170bcaf7d5b3f47ffde346b1849f905662 (patch)
tree5eba85d323d6cf01c9f68cf130b88f360b081646 /src/utils
parent510ac65eb36cbb4f888df9dc1b54cacdf93a0db2 (diff)
downloadmanaserv-cc162d170bcaf7d5b3f47ffde346b1849f905662.tar.gz
manaserv-cc162d170bcaf7d5b3f47ffde346b1849f905662.tar.xz
manaserv-cc162d170bcaf7d5b3f47ffde346b1849f905662.zip
For streaming things to cout better implement stream operator
More convenient since it doesn't require calling any methods, and a bit faster. Also added stream operator for Rectangle.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/point.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/utils/point.h b/src/utils/point.h
index 8436b8c..4402aa0 100644
--- a/src/utils/point.h
+++ b/src/utils/point.h
@@ -22,8 +22,7 @@
#define POINT_H
#include <algorithm>
-#include <string>
-#include <sstream>
+#include <ostream>
/**
* A point in positive space. Usually represents pixel coordinates on a map.
@@ -60,13 +59,6 @@ class Point
{
return (x != other.x || y != other.y);
}
-
- std::string str() const
- {
- std::ostringstream ssPoint;
- ssPoint << "(" << x << ", " << y << ")";
- return ssPoint.str();
- }
};
/**
@@ -96,4 +88,17 @@ class Rectangle
}
};
+inline std::ostream &operator <<(std::ostream &os, const Point &point)
+{
+ os << '(' << point.x << ", " << point.y << ')';
+ return os;
+}
+
+inline std::ostream &operator <<(std::ostream &os, const Rectangle &rect)
+{
+ os << '(' << rect.x << ',' << rect.y
+ << ' ' << rect.w << 'x' << rect.h << ')';
+ return os;
+}
+
#endif // POINT_H