mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 17:40:05 +00:00
Refactor color validator from settings to utility source
This commit is contained in:
parent
8fc392681a
commit
c8dc8ed630
3 changed files with 18 additions and 11 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include <scwx/qt/util/color.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <re2/re2.h>
|
||||
#include <QColor>
|
||||
|
||||
namespace scwx
|
||||
|
|
@ -38,6 +39,12 @@ boost::gil::rgba32f_pixel_t ToRgba32fPixelT(const std::string& argbString)
|
|||
rgba8Pixel[3] / 255.0f};
|
||||
}
|
||||
|
||||
bool ValidateArgbString(const std::string& argbString)
|
||||
{
|
||||
static constexpr LazyRE2 re = {"#[0-9A-Fa-f]{8}"};
|
||||
return RE2::FullMatch(argbString, *re);
|
||||
}
|
||||
|
||||
} // namespace color
|
||||
} // namespace util
|
||||
} // namespace qt
|
||||
|
|
|
|||
|
|
@ -39,6 +39,15 @@ boost::gil::rgba8_pixel_t ToRgba8PixelT(const std::string& argbString);
|
|||
*/
|
||||
boost::gil::rgba32f_pixel_t ToRgba32fPixelT(const std::string& argbString);
|
||||
|
||||
/**
|
||||
* Validates an ARGB string used by Qt libraries.
|
||||
*
|
||||
* @param argbString
|
||||
*
|
||||
* @return Validity of ARGB string
|
||||
*/
|
||||
bool ValidateArgbString(const std::string& argbString);
|
||||
|
||||
} // namespace color
|
||||
} // namespace util
|
||||
} // namespace qt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue