Simplify operator<< implementations

This commit is contained in:
Chris Thrasher 2022-07-04 23:57:04 -06:00 committed by Vittorio Romeo
parent 25fa30afc6
commit e44a4b305d
4 changed files with 12 additions and 22 deletions

View File

@ -9,19 +9,16 @@ namespace sf
{ {
std::ostream& operator<<(std::ostream& os, const BlendMode& blendMode) std::ostream& operator<<(std::ostream& os, const BlendMode& blendMode)
{ {
os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation << ", " return os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation
<< blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation << " )"; << ", " << blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation
<< " )";
return os;
} }
std::ostream& operator<<(std::ostream& os, const Color& color) std::ostream& operator<<(std::ostream& os, const Color& color)
{ {
os << "0x" << std::hex << color.toInteger() << std::dec << " (r=" << static_cast<int>(color.r) return os << "0x" << std::hex << color.toInteger() << std::dec << " (r=" << static_cast<int>(color.r)
<< ", g=" << static_cast<int>(color.g) << ", b=" << static_cast<int>(color.b) << ", g=" << static_cast<int>(color.g) << ", b=" << static_cast<int>(color.b)
<< ", a=" << static_cast<int>(color.a) << ")"; << ", a=" << static_cast<int>(color.a) << ")";
return os;
} }
std::ostream& operator<<(std::ostream& os, const Transform& transform) std::ostream& operator<<(std::ostream& os, const Transform& transform)
@ -30,7 +27,6 @@ std::ostream& operator<<(std::ostream& os, const Transform& transform)
os << matrix[0] << ", " << matrix[4] << ", " << matrix[12] << ", "; os << matrix[0] << ", " << matrix[4] << ", " << matrix[12] << ", ";
os << matrix[1] << ", " << matrix[5] << ", " << matrix[13] << ", "; os << matrix[1] << ", " << matrix[5] << ", " << matrix[13] << ", ";
os << matrix[3] << ", " << matrix[7] << ", " << matrix[15]; os << matrix[3] << ", " << matrix[7] << ", " << matrix[15];
return os; return os;
} }
} // namespace sf } // namespace sf

View File

@ -11,20 +11,17 @@ namespace sf
std::ostream& operator<<(std::ostream& os, const Angle& angle) std::ostream& operator<<(std::ostream& os, const Angle& angle)
{ {
os << std::fixed << std::setprecision(std::numeric_limits<float>::max_digits10); os << std::fixed << std::setprecision(std::numeric_limits<float>::max_digits10);
os << angle.asDegrees() << " deg"; return os << angle.asDegrees() << " deg";
return os;
} }
std::ostream& operator<<(std::ostream& os, const String& string) std::ostream& operator<<(std::ostream& os, const String& string)
{ {
os << string.toAnsiString(); return os << string.toAnsiString();
return os;
} }
std::ostream& operator<<(std::ostream& os, Time time) std::ostream& operator<<(std::ostream& os, Time time)
{ {
os << time.asMicroseconds() << "us"; return os << time.asMicroseconds() << "us";
return os;
} }
} // namespace sf } // namespace sf

View File

@ -28,15 +28,13 @@ template <typename T>
std::ostream& operator<<(std::ostream& os, const Vector2<T>& vector) std::ostream& operator<<(std::ostream& os, const Vector2<T>& vector)
{ {
os << std::fixed << std::setprecision(std::numeric_limits<T>::max_digits10); os << std::fixed << std::setprecision(std::numeric_limits<T>::max_digits10);
os << "(" << vector.x << ", " << vector.y << ")"; return os << "(" << vector.x << ", " << vector.y << ")";
return os;
} }
template <typename T> template <typename T>
std::ostream& operator<<(std::ostream& os, const Vector3<T>& vector) std::ostream& operator<<(std::ostream& os, const Vector3<T>& vector)
{ {
os << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")"; return os << "(" << vector.x << ", " << vector.y << ", " << vector.z << ")";
return os;
} }
} // namespace sf } // namespace sf

View File

@ -7,7 +7,6 @@ namespace sf
{ {
std::ostream& operator<<(std::ostream& os, const VideoMode& videoMode) std::ostream& operator<<(std::ostream& os, const VideoMode& videoMode)
{ {
os << videoMode.size.x << "x" << videoMode.size.y << "x" << videoMode.bitsPerPixel; return os << videoMode.size.x << "x" << videoMode.size.y << "x" << videoMode.bitsPerPixel;
return os;
} }
} // namespace sf } // namespace sf