1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 14:53:21 +02:00

Improved debug output

This commit is contained in:
Martin Tůma 2017-08-14 11:16:48 +02:00
parent b3f1596918
commit afe9a14d5b
10 changed files with 36 additions and 6 deletions

View File

@ -19,9 +19,10 @@ qreal Coordinates::distanceTo(const Coordinates &c) const
QDebug operator<<(QDebug dbg, const Coordinates &coordinates) QDebug operator<<(QDebug dbg, const Coordinates &coordinates)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "Coordinates(" << coordinates.lon() << ", " dbg.nospace() << "Coordinates(" << coordinates.lon() << ", "
<< coordinates.lat() << ")"; << coordinates.lat() << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }

View File

@ -2,8 +2,9 @@
QDebug operator<<(QDebug dbg, const GraphPoint &point) QDebug operator<<(QDebug dbg, const GraphPoint &point)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "GraphPoint(" << point.s() << ", " << point.t() << ", " dbg.nospace() << "GraphPoint(" << point.s() << ", " << point.t() << ", "
<< point.y() << ")"; << point.y() << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }

View File

@ -115,3 +115,20 @@ void Matrix::zeroize()
for (size_t i = 0; i < _h * _w; i++) for (size_t i = 0; i < _h * _w; i++)
_m[i] = 0; _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();
}

View File

@ -3,6 +3,7 @@
#include <cstddef> #include <cstddef>
#include <cfloat> #include <cfloat>
#include <QDebug>
class Matrix { class Matrix {
public: public:
@ -30,4 +31,6 @@ private:
size_t _w; size_t _w;
}; };
QDebug operator<<(QDebug dbg, const Matrix &matrix);
#endif // MATRIX_H #endif // MATRIX_H

View File

@ -39,8 +39,9 @@ void Palette::reset()
QDebug operator<<(QDebug dbg, const Palette &palette) QDebug operator<<(QDebug dbg, const Palette &palette)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift() dbg.nospace() << "Palette(" << palette.color() << ", " << palette.shift()
<< ")"; << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }

View File

@ -14,8 +14,9 @@ RectC Path::boundingRect() const
QDebug operator<<(QDebug dbg, const PathPoint &point) QDebug operator<<(QDebug dbg, const PathPoint &point)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "PathPoint(" << point.distance() << ", " dbg.nospace() << "PathPoint(" << point.distance() << ", "
<< point.coordinates() << ")"; << point.coordinates() << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }

View File

@ -10,6 +10,8 @@ void RangeF::resize(qreal size)
QDebug operator<<(QDebug dbg, const RangeF &range) QDebug operator<<(QDebug dbg, const RangeF &range)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "RangeF(" << range.min() << ", " << range.max() << ")"; dbg.nospace() << "RangeF(" << range.min() << ", " << range.max() << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }

View File

@ -58,6 +58,8 @@ void RectC::unite(const Coordinates &c)
QDebug operator<<(QDebug dbg, const RectC &rect) QDebug operator<<(QDebug dbg, const RectC &rect)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "RectC(" << rect.topLeft() << ", " << rect.size() << ")"; dbg.nospace() << "RectC(" << rect.topLeft() << ", " << rect.size() << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }

View File

@ -2,10 +2,11 @@
QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint) QDebug operator<<(QDebug dbg, const Trackpoint &trackpoint)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", " dbg.nospace() << "Trackpoint(" << trackpoint.coordinates() << ", "
<< trackpoint.timestamp() << ", " << trackpoint.elevation() << ", " << trackpoint.timestamp() << ", " << trackpoint.elevation() << ", "
<< trackpoint.speed() << ", " << trackpoint.heartRate() << ", " << trackpoint.speed() << ", " << trackpoint.heartRate() << ", "
<< trackpoint.temperature() << ")"; << trackpoint.temperature() << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }

View File

@ -2,8 +2,9 @@
QDebug operator<<(QDebug dbg, const Waypoint &waypoint) QDebug operator<<(QDebug dbg, const Waypoint &waypoint)
{ {
const bool ais = dbg.autoInsertSpaces();
dbg.nospace() << "Waypoint(" << waypoint.coordinates() << ", " dbg.nospace() << "Waypoint(" << waypoint.coordinates() << ", "
<< waypoint.name() << ", " << waypoint.description() << ")"; << waypoint.name() << ", " << waypoint.description() << ")";
dbg.setAutoInsertSpaces(ais);
return dbg.maybeSpace(); return dbg.maybeSpace();
} }