commit adeb378: [Minor] Css: Allow to convert css color to uint32_t
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri May 21 15:35:11 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-05-21 16:28:26 +0100
URL: https://github.com/rspamd/rspamd/commit/adeb3780e89cc42dd452280428bf46b1a0efc63b
[Minor] Css: Allow to convert css color to uint32_t
---
src/libserver/css/css_value.hxx | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/libserver/css/css_value.hxx b/src/libserver/css/css_value.hxx
index 4c013124c..9e192acb6 100644
--- a/src/libserver/css/css_value.hxx
+++ b/src/libserver/css/css_value.hxx
@@ -40,6 +40,12 @@ struct alignas(int) css_color {
css_color(std::uint8_t _r, std::uint8_t _g, std::uint8_t _b, std::uint8_t _alpha = 255) :
r(_r), g(_g), b(_b), alpha(_alpha) {}
css_color() = default;
+ constexpr auto to_number() const -> std::uint32_t {
+ return (std::uint32_t)alpha << 24 |
+ (std::uint32_t)r << 16 |
+ (std::uint32_t)g << 8 |
+ (std::uint32_t)b << 0;
+ }
friend bool operator==(const css_color& l, const css_color& r) {
return (memcmp(&l, &r, sizeof(css_color)) == 0);
}
More information about the Commits
mailing list