Boost.UI
User Interface Boost library
color_io.hpp
Go to the documentation of this file.
1 // Copyright (c) 2017 Kolya Kosenko
2 
3 // Distributed under the Boost Software License, Version 1.0.
4 // See http://www.boost.org/LICENSE_1_0.txt
5 
7 
8 #ifndef BOOST_UI_COLOR_IO_HPP
9 #define BOOST_UI_COLOR_IO_HPP
10 
11 #include <boost/ui/config.hpp>
12 
13 #ifdef BOOST_HAS_PRAGMA_ONCE
14 #pragma once
15 #endif
16 
17 #include <boost/ui/color.hpp>
18 
19 #include <ostream>
20 
21 namespace boost {
22 namespace ui {
23 
26 
27 template <class CharT, class Traits>
28 std::basic_ostream<CharT, Traits>&
29 operator<<(std::basic_ostream<CharT, Traits>& os, const boost::ui::color& c)
30 {
31  const bool is_transparent = c.alpha255() != 255;
32  os << 'r' << 'g' << 'b';
33  if ( is_transparent )
34  os << 'a';
35  os << '(' << static_cast<int>(c.red255());
36  os << ',' << static_cast<int>(c.green255());
37  os << ',' << static_cast<int>(c.blue255());
38  if ( is_transparent )
39  os << ',' << static_cast<int>(c.alpha255());
40  os << ')';
41  return os;
42 }
43 
44 } // namespace ui
45 } // namespace boost
46 
47 #endif // BOOST_UI_COLOR_IO_HPP
boost::ui::color::alpha255
channel255_type alpha255() const noexcept
Returns color value in [0, 255] range.
Definition: color.hpp:53
config.hpp
Configuration options.
boost::ui::color::green255
channel255_type green255() const noexcept
Returns color value in [0, 255] range.
Definition: color.hpp:51
boost
Boost C++ libraries namespace.
Definition: window.hpp:19
boost::ui::operator<<
std::basic_ostream< char, Traits > & operator<<(std::basic_ostream< char, Traits > &os, const uistring &str)
Writes string into the stream.
Definition: string_io.hpp:31
boost::ui::color::red255
channel255_type red255() const noexcept
Returns color value in [0, 255] range.
Definition: color.hpp:50
color.hpp
Color class.
boost::ui::color
Color class.
Definition: color.hpp:31
boost::ui::color::blue255
channel255_type blue255() const noexcept
Returns color value in [0, 255] range.
Definition: color.hpp:52