summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2013-10-15 11:27:23 +0300
committerTor Lillqvist <tml@collabora.com>2013-10-15 15:45:18 +0300
commit8a8d1e5b4961ada276a660b8b842f2f012a8ae85 (patch)
treebf6163b2886fae7bd8e2bd5c2391e2c9e051ab7a
parent12947fd00d5192e7a448eb94faf0ab7b03f442c1 (diff)
Add operator<< to some classes for debugging output
Change-Id: I74a4c1217cc89e9d5da02a47ed45d6ce5fceb815
-rw-r--r--include/basegfx/point/b2dpoint.hxx12
-rw-r--r--include/basegfx/polygon/b2dpolygon.hxx21
-rw-r--r--include/basegfx/polygon/b2dpolypolygon.hxx24
-rw-r--r--include/basegfx/range/b2drange.hxx12
-rw-r--r--include/basegfx/range/b2ibox.hxx16
-rw-r--r--include/basegfx/range/b2irange.hxx16
-rw-r--r--include/basegfx/vector/b2ivector.hxx10
7 files changed, 92 insertions, 19 deletions
diff --git a/include/basegfx/point/b2dpoint.hxx b/include/basegfx/point/b2dpoint.hxx
index ef73c8ab46c9..c5b87d95e40b 100644
--- a/include/basegfx/point/b2dpoint.hxx
+++ b/include/basegfx/point/b2dpoint.hxx
@@ -20,12 +20,12 @@
#ifndef _BGFX_POINT_B2DPOINT_HXX
#define _BGFX_POINT_B2DPOINT_HXX
+#include <ostream>
+
#include <basegfx/tuple/b2dtuple.hxx>
#include <basegfx/point/b2ipoint.hxx>
#include <basegfx/basegfxdllapi.h>
-//////////////////////////////////////////////////////////////////////////////
-
namespace basegfx
{
// predeclaration
@@ -129,7 +129,6 @@ namespace basegfx
};
// external operators
- //////////////////////////////////////////////////////////////////////////
/** Transform B2DPoint by given transformation matrix.
@@ -139,7 +138,12 @@ namespace basegfx
BASEGFX_DLLPUBLIC B2DPoint operator*( const B2DHomMatrix& rMat, const B2DPoint& rPoint );
} // end of namespace basegfx
-//////////////////////////////////////////////////////////////////////////////
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const basegfx::B2DPoint& point )
+{
+ return stream << "(" << point.getX() << "," << point.getY() << ")";
+}
#endif /* _BGFX_POINT_B2DPOINT_HXX */
diff --git a/include/basegfx/polygon/b2dpolygon.hxx b/include/basegfx/polygon/b2dpolygon.hxx
index 7c854fdc8a0e..712de7787d2c 100644
--- a/include/basegfx/polygon/b2dpolygon.hxx
+++ b/include/basegfx/polygon/b2dpolygon.hxx
@@ -20,13 +20,14 @@
#ifndef _BGFX_POLYGON_B2DPOLYGON_HXX
#define _BGFX_POLYGON_B2DPOLYGON_HXX
+#include <ostream>
+
#include <sal/types.h>
#include <o3tl/cow_wrapper.hxx>
#include <basegfx/vector/b2enums.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/basegfxdllapi.h>
-//////////////////////////////////////////////////////////////////////////////
// predeclarations
class ImplB2DPolygon;
@@ -39,8 +40,6 @@ namespace basegfx
class B2DCubicBezier;
} // end of namespace basegfx
-//////////////////////////////////////////////////////////////////////////////
-
namespace basegfx
{
class BASEGFX_DLLPUBLIC B2DPolygon
@@ -223,7 +222,21 @@ namespace basegfx
} // end of namespace basegfx
-//////////////////////////////////////////////////////////////////////////////
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const basegfx::B2DPolygon& poly )
+{
+ stream << "<" << poly.count() << ":";
+ for (sal_uInt32 i = 0; i < poly.count(); i++)
+ {
+ if (i > 0)
+ stream << "--";
+ stream << poly.getB2DPoint(i);
+ }
+ stream << ">";
+
+ return stream;
+}
#endif /* _BGFX_POLYGON_B2DPOLYGON_HXX */
diff --git a/include/basegfx/polygon/b2dpolypolygon.hxx b/include/basegfx/polygon/b2dpolypolygon.hxx
index cd22644ab8ce..efe58337a886 100644
--- a/include/basegfx/polygon/b2dpolypolygon.hxx
+++ b/include/basegfx/polygon/b2dpolypolygon.hxx
@@ -20,23 +20,23 @@
#ifndef _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
#define _BGFX_POLYGON_B2DPOLYPOLYGON_HXX
+#include <ostream>
+#include <vector>
+
#include <sal/types.h>
#include <o3tl/cow_wrapper.hxx>
#include <basegfx/range/b2drange.hxx>
#include <basegfx/basegfxdllapi.h>
-#include <vector>
+#include <basegfx/polygon/b2dpolygon.hxx>
// predeclarations
class ImplB2DPolyPolygon;
namespace basegfx
{
- class B2DPolygon;
class B2DHomMatrix;
} // end of namespace basegfx
-//////////////////////////////////////////////////////////////////////////////
-
namespace basegfx
{
class BASEGFX_DLLPUBLIC B2DPolyPolygon
@@ -132,6 +132,22 @@ namespace basegfx
} // end of namespace basegfx
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const basegfx::B2DPolyPolygon& poly )
+{
+ stream << "[" << poly.count() << ":";
+ for (sal_uInt32 i = 0; i < poly.count(); i++)
+ {
+ if (i > 0)
+ stream << ",";
+ stream << poly.getB2DPolygon(i);
+ }
+ stream << "]";
+
+ return stream;
+}
+
#endif /* _BGFX_POLYGON_B2DPOLYPOLYGON_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/range/b2drange.hxx b/include/basegfx/range/b2drange.hxx
index 1f3884c1c9ce..52277e42465e 100644
--- a/include/basegfx/range/b2drange.hxx
+++ b/include/basegfx/range/b2drange.hxx
@@ -20,14 +20,15 @@
#ifndef _BGFX_RANGE_B2DRANGE_HXX
#define _BGFX_RANGE_B2DRANGE_HXX
+#include <ostream>
+#include <vector>
+
#include <basegfx/vector/b2dvector.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/tuple/b2dtuple.hxx>
#include <basegfx/range/basicrange.hxx>
-#include <vector>
#include <basegfx/basegfxdllapi.h>
-
namespace basegfx
{
// predeclarations
@@ -315,6 +316,13 @@ namespace basegfx
} // end of namespace basegfx
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const basegfx::B2DRange& range )
+{
+ return stream << range.getWidth() << "x" << range.getHeight() << "@" << range.getMinimum();
+}
+
#endif /* _BGFX_RANGE_B2DRANGE_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/range/b2ibox.hxx b/include/basegfx/range/b2ibox.hxx
index 7c182a4ab327..20bf7c11a07c 100644
--- a/include/basegfx/range/b2ibox.hxx
+++ b/include/basegfx/range/b2ibox.hxx
@@ -20,15 +20,16 @@
#ifndef _BGFX_RANGE_B2IBOX_HXX
#define _BGFX_RANGE_B2IBOX_HXX
+#include <ostream>
+#include <vector>
+
#include <basegfx/point/b2ipoint.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/tuple/b2ituple.hxx>
#include <basegfx/tuple/b2i64tuple.hxx>
#include <basegfx/range/basicbox.hxx>
-#include <vector>
#include <basegfx/basegfxdllapi.h>
-
namespace basegfx
{
/** A two-dimensional interval over integers
@@ -256,6 +257,17 @@ namespace basegfx
} // end of namespace basegfx
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const basegfx::B2IBox& box )
+{
+ if (box.isEmpty())
+ return stream << "EMPTY";
+ else
+ return stream << box.getWidth() << 'x' << box.getHeight()
+ << "@(" << box.getMinX() << "," << box.getMinY() << ")";
+}
+
#endif /* _BGFX_RANGE_B2IBOX_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/range/b2irange.hxx b/include/basegfx/range/b2irange.hxx
index 60f9fc79fa67..6befb1efd2f4 100644
--- a/include/basegfx/range/b2irange.hxx
+++ b/include/basegfx/range/b2irange.hxx
@@ -20,15 +20,16 @@
#ifndef _BGFX_RANGE_B2IRANGE_HXX
#define _BGFX_RANGE_B2IRANGE_HXX
+#include <ostream>
+#include <vector>
+
#include <basegfx/point/b2ipoint.hxx>
#include <basegfx/point/b2dpoint.hxx>
#include <basegfx/tuple/b2ituple.hxx>
#include <basegfx/tuple/b2i64tuple.hxx>
#include <basegfx/range/basicrange.hxx>
-#include <vector>
#include <basegfx/basegfxdllapi.h>
-
namespace basegfx
{
/** A two-dimensional interval over integers
@@ -282,6 +283,17 @@ namespace basegfx
} // end of namespace basegfx
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const basegfx::B2IRange& range )
+{
+ if (range.isEmpty())
+ return stream << "EMPTY";
+ else
+ return stream << range.getWidth() << 'x' << range.getHeight()
+ << "@(" << range.getMinX() << "," << range.getMinY() << ")";
+}
+
#endif /* _BGFX_RANGE_B2IRANGE_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/basegfx/vector/b2ivector.hxx b/include/basegfx/vector/b2ivector.hxx
index 63ce2ae28fba..71f438d11062 100644
--- a/include/basegfx/vector/b2ivector.hxx
+++ b/include/basegfx/vector/b2ivector.hxx
@@ -20,6 +20,8 @@
#ifndef _BGFX_VECTOR_B2IVECTOR_HXX
#define _BGFX_VECTOR_B2IVECTOR_HXX
+#include <ostream>
+
#include <basegfx/tuple/b2ituple.hxx>
#include <basegfx/vector/b2enums.hxx>
#include <basegfx/basegfxdllapi.h>
@@ -130,7 +132,6 @@ namespace basegfx
};
// external operators
- //////////////////////////////////////////////////////////////////////////
/** Transform vector by given transformation matrix.
@@ -141,6 +142,13 @@ namespace basegfx
} // end of namespace basegfx
+template< typename charT, typename traits >
+inline std::basic_ostream<charT, traits> & operator <<(
+ std::basic_ostream<charT, traits> & stream, const basegfx::B2IVector& vector )
+{
+ return stream << "(" << vector.getX() << "," << vector.getY() << ")";
+}
+
#endif /* _BGFX_VECTOR_B2IVECTOR_HXX */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */