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)
{
os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation << ", "
<< blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation << " )";
return os;
return os << "( " << blendMode.colorSrcFactor << ", " << blendMode.colorDstFactor << ", " << blendMode.colorEquation
<< ", " << blendMode.alphaSrcFactor << ", " << blendMode.alphaDstFactor << ", " << blendMode.alphaEquation
<< " )";
}
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)
<< ", a=" << static_cast<int>(color.a) << ")";
return os;
}
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[1] << ", " << matrix[5] << ", " << matrix[13] << ", ";
os << matrix[3] << ", " << matrix[7] << ", " << matrix[15];
return os;
}
} // namespace sf

View File

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

View File

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

View File

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