From afe9a14d5be98418a473c4f5fbc27d944080148c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 14 Aug 2017 11:16:48 +0200 Subject: [PATCH] Improved debug output --- src/coordinates.cpp | 3 ++- src/graph.cpp | 3 ++- src/matrix.cpp | 17 +++++++++++++++++ src/matrix.h | 3 +++ src/palette.cpp | 3 ++- src/path.cpp | 3 ++- src/range.cpp | 2 ++ src/rectc.cpp | 2 ++ src/trackpoint.cpp | 3 ++- src/waypoint.cpp | 3 ++- 10 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/coordinates.cpp b/src/coordinates.cpp index 0cfab3e3..62b364a3 100644 --- a/src/coordinates.cpp +++ b/src/coordinates.cpp @@ -19,9 +19,10 @@ qreal Coordinates::distanceTo(const Coordinates &c) const QDebug operator<<(QDebug dbg, const Coordinates &coordinates) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "Coordinates(" << coordinates.lon() << ", " << coordinates.lat() << ")"; - + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); } diff --git a/src/graph.cpp b/src/graph.cpp index 229ae621..6021e9ac 100644 --- a/src/graph.cpp +++ b/src/graph.cpp @@ -2,8 +2,9 @@ QDebug operator<<(QDebug dbg, const GraphPoint &point) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "GraphPoint(" << point.s() << ", " << point.t() << ", " << point.y() << ")"; - + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); } diff --git a/src/matrix.cpp b/src/matrix.cpp index d0e70d32..02335218 100644 --- a/src/matrix.cpp +++ b/src/matrix.cpp @@ -115,3 +115,20 @@ void Matrix::zeroize() for (size_t i = 0; i < _h * _w; i++) _m[i] = 0; } + +QDebug operator<<(QDebug dbg, const Matrix &matrix) +{ + const bool ais = dbg.autoInsertSpaces(); + + dbg.nospace() << "Matrix(" << endl; + for (size_t i = 0; i < matrix.h(); i++) { + for (size_t j = 0; j < matrix.w(); j++) + dbg << "\t" << matrix.m(i, j); + dbg << endl; + } + dbg << ")"; + + dbg.setAutoInsertSpaces(ais); + + return dbg.maybeSpace(); +} diff --git a/src/matrix.h b/src/matrix.h index ee7c511c..35912074 100644 --- a/src/matrix.h +++ b/src/matrix.h @@ -3,6 +3,7 @@ #include #include +#include class Matrix { public: @@ -30,4 +31,6 @@ private: size_t _w; }; +QDebug operator<<(QDebug dbg, const Matrix &matrix); + #endif // MATRIX_H diff --git a/src/palette.cpp b/src/palette.cpp index 6025768f..13f1a256 100644 --- a/src/palette.cpp +++ b/src/palette.cpp @@ -39,8 +39,9 @@ void Palette::reset() QDebug operator<<(QDebug dbg, const Palette &palette) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift() << ")"; - + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); } diff --git a/src/path.cpp b/src/path.cpp index 957ca655..8c2bda7e 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -14,8 +14,9 @@ RectC Path::boundingRect() const QDebug operator<<(QDebug dbg, const PathPoint &point) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "PathPoint(" << point.distance() << ", " << point.coordinates() << ")"; - + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); } diff --git a/src/range.cpp b/src/range.cpp index 21639106..b837b722 100644 --- a/src/range.cpp +++ b/src/range.cpp @@ -10,6 +10,8 @@ void RangeF::resize(qreal size) QDebug operator<<(QDebug dbg, const RangeF &range) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "RangeF(" << range.min() << ", " << range.max() << ")"; + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); } diff --git a/src/rectc.cpp b/src/rectc.cpp index 89b11801..7b670c43 100644 --- a/src/rectc.cpp +++ b/src/rectc.cpp @@ -58,6 +58,8 @@ void RectC::unite(const Coordinates &c) QDebug operator<<(QDebug dbg, const RectC &rect) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "RectC(" << rect.topLeft() << ", " << rect.size() << ")"; + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); } diff --git a/src/trackpoint.cpp b/src/trackpoint.cpp index a65baea0..649a3b15 100644 --- a/src/trackpoint.cpp +++ b/src/trackpoint.cpp @@ -2,10 +2,11 @@ QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", " << trackpoint.timestamp() << ", " << trackpoint.elevation() << ", " << trackpoint.speed() << ", " << trackpoint.heartRate() << ", " << trackpoint.temperature() << ")"; - + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); } diff --git a/src/waypoint.cpp b/src/waypoint.cpp index 17480d0d..6307e46c 100644 --- a/src/waypoint.cpp +++ b/src/waypoint.cpp @@ -2,8 +2,9 @@ QDebug operator<<(QDebug dbg, const Waypoint &waypoint) { + const bool ais = dbg.autoInsertSpaces(); dbg.nospace() << "Waypoint(" << waypoint.coordinates() << ", " << waypoint.name() << ", " << waypoint.description() << ")"; - + dbg.setAutoInsertSpaces(ais); return dbg.maybeSpace(); }