kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #29042
[PATCH] Add output stream operator for COLOR4D
Hi all,
Quick patch attached to add output stream operator for COLOR4D, useful for
debugging and for some future things I am working on.
-Jon
From 05ff315a03084a27cb69645c4b3dd1aeb9124217 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
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 35000d347..b0cbe0354 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 ebcf333bc..eb5300c32 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_ */
--
2.11.0
Follow ups