Browse Source

Custom @debugoperator command instead of hiding the functions.

Uses @relates, so the operator is tied to related class.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
208b6ce93e
  1. 1
      Doxyfile
  2. 31
      src/Math/Matrix.h
  3. 3
      src/Math/Matrix3.h
  4. 3
      src/Math/Matrix4.h
  5. 25
      src/Math/Vector.h
  6. 3
      src/Math/Vector2.h
  7. 3
      src/Math/Vector3.h
  8. 3
      src/Math/Vector4.h

1
Doxyfile

@ -195,6 +195,7 @@ TAB_SIZE = 8
# You can put \n's in the value part of an alias to insert newlines.
ALIASES = \
"debugoperator{1}=@relates \1\n@brief Debug output operator" \
"todoc=@xrefitem todox \"Documentation todo\" \"Documentation-related todo list\"" \
"requires_gl30=@xrefitem RequiresGL30 \"Requires OpenGL 3.0\" \"Functionality requiring OpenGL 3.0\"" \
"requires_gl31=@xrefitem RequiresGL31 \"Requires OpenGL 3.1\" \"Functionality requiring OpenGL 3.1\"" \

31
src/Math/Matrix.h

@ -260,6 +260,22 @@ template<size_t size, class T> class Matrix {
T _data[size*size];
};
/** @debugoperator{Matrix} */
template<class T, size_t size> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix<size, T>& value) {
debug << "Matrix(";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false);
for(size_t row = 0; row != size; ++row) {
if(row != 0) debug << ",\n ";
for(size_t col = 0; col != size; ++col) {
if(col != 0) debug << ", ";
debug << value[col][row];
}
}
debug << ')';
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true);
return debug;
}
#ifndef DOXYGEN_GENERATING_OUTPUT
#define MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(Type, VectorType, size) \
inline constexpr static Type<T>& from(T* data) { \
@ -330,21 +346,6 @@ template<class T> class MatrixDeterminant<1, T> {
};
}
template<class T, size_t size> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix<size, T>& value) {
debug << "Matrix(";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false);
for(size_t row = 0; row != size; ++row) {
if(row != 0) debug << ",\n ";
for(size_t col = 0; col != size; ++col) {
if(col != 0) debug << ", ";
debug << value[col][row];
}
}
debug << ')';
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true);
return debug;
}
#endif
}}

3
src/Math/Matrix3.h

@ -50,11 +50,10 @@ template<class T> class Matrix3: public Matrix<3, T> {
MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(Matrix3, Vector3, 3)
};
#ifndef DOXYGEN_GENERATING_OUTPUT
/** @debugoperator{Matrix3} */
template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix3<T>& value) {
return debug << static_cast<const Magnum::Math::Matrix<3, T>&>(value);
}
#endif
}}

3
src/Math/Matrix4.h

@ -137,11 +137,10 @@ template<class T> class Matrix4: public Matrix<4, T> {
MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(Matrix4, Vector4, 4)
};
#ifndef DOXYGEN_GENERATING_OUTPUT
/** @debugoperator{Matrix4} */
template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Matrix4<T>& value) {
return debug << static_cast<const Magnum::Math::Matrix<4, T>&>(value);
}
#endif
}}

25
src/Math/Vector.h

@ -266,6 +266,19 @@ template<size_t size, class T> class Vector {
T _data[size];
};
/** @debugoperator{Vector} */
template<class T, size_t size> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector<size, T>& value) {
debug << "Vector(";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false);
for(size_t i = 0; i != size; ++i) {
if(i != 0) debug << ", ";
debug << value[i];
}
debug << ')';
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true);
return debug;
}
#ifndef DOXYGEN_GENERATING_OUTPUT
#define MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Type, size) \
inline constexpr static Type<T>& from(T* data) { \
@ -312,18 +325,6 @@ template<size_t size, class T> class Vector {
\
inline Type<T> operator-() const { return Vector<size, T>::operator-(); } \
inline Type<T> normalized() const { return Vector<size, T>::normalized(); }
template<class T, size_t size> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector<size, T>& value) {
debug << "Vector(";
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false);
for(size_t i = 0; i != size; ++i) {
if(i != 0) debug << ", ";
debug << value[i];
}
debug << ')';
debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, true);
return debug;
}
#endif
}}

3
src/Math/Vector2.h

@ -48,11 +48,10 @@ template<class T> class Vector2: public Vector<2, T> {
MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Vector2, 2)
};
#ifndef DOXYGEN_GENERATING_OUTPUT
/** @debugoperator{Vector2} */
template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector2<T>& value) {
return debug << static_cast<const Magnum::Math::Vector<2, T>&>(value);
}
#endif
}}

3
src/Math/Vector3.h

@ -95,11 +95,10 @@ template<class T> class Vector3: public Vector<3, T> {
MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Vector3, 3)
};
#ifndef DOXYGEN_GENERATING_OUTPUT
/** @debugoperator{Vector3} */
template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector3<T>& value) {
return debug << static_cast<const Magnum::Math::Vector<3, T>&>(value);
}
#endif
}}

3
src/Math/Vector4.h

@ -98,11 +98,10 @@ template<class T> class Vector4: public Vector<4, T> {
MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Vector4, 4)
};
#ifndef DOXYGEN_GENERATING_OUTPUT
/** @debugoperator{Vector4} */
template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Magnum::Math::Vector4<T>& value) {
return debug << static_cast<const Magnum::Math::Vector<4, T>&>(value);
}
#endif
}}

Loading…
Cancel
Save