From 8cd1df052436d6133198c9f9728a45ee6876bf73 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 30 Mar 2017 22:09:19 -0400 Subject: [PATCH] Add output stream operator for COLOR4D --- common/gal/color4d.cpp | 7 ++++++- include/gal/color4d.h | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/gal/color4d.cpp b/common/gal/color4d.cpp index 35000d3475..b0cbe03549 100644 --- a/common/gal/color4d.cpp +++ b/common/gal/color4d.cpp @@ -73,7 +73,7 @@ COLOR4D::COLOR4D( EDA_COLOR_T aColor ) } - wxString COLOR4D::ToWxString( long flags ) + wxString COLOR4D::ToWxString( long flags ) const { wxColour c = ToColour(); return c.GetAsString( flags ); @@ -256,6 +256,11 @@ const bool operator!=( const COLOR4D& lhs, const COLOR4D& rhs ) return !( lhs == rhs ); } +std::ostream &operator<<( std::ostream &aStream, COLOR4D const &aColor ) +{ + return aStream << aColor.ToWxString( wxC2S_CSS_SYNTAX ); +} + } diff --git a/include/gal/color4d.h b/include/gal/color4d.h index ebcf333bcc..eb5300c32c 100644 --- a/include/gal/color4d.h +++ b/include/gal/color4d.h @@ -87,7 +87,7 @@ public: */ bool SetFromWxString( const wxString& aColorString ); - wxString ToWxString( long flags ); + wxString ToWxString( long flags ) const; wxColour ToColour() const { @@ -297,6 +297,9 @@ const bool operator==( const COLOR4D& lhs, const COLOR4D& rhs ); /// @brief Not equality operator, are two colors not equal const bool operator!=( const COLOR4D& lhs, const COLOR4D& rhs ); +/// Syntactic sugar for outputting colors to strings +std::ostream &operator<<( std::ostream &aStream, COLOR4D const &aColor ); + } // namespace KIGFX #endif /* COLOR4D_H_ */