5#include <unordered_set>
15 static constexpr auto kHint =
"MODE";
20 name_ =
"TILES_OUTPUT_PAL";
21 func_ = [](
const std::string &str) {
23 return std::string{
"invalid 'tiles.png' output palette mode: " + str};
31 static constexpr auto kHint =
"PATH";
36 name_ =
"NOT_ALREADY_A_FILE";
37 func_ = [](
const std::string &str) {
38 if (std::filesystem::exists(str) && std::filesystem::is_regular_file(str)) {
39 return std::string{
"file already exists: " + str};
47 static constexpr auto kHint =
"R,G,B";
53 func_ = [](
const std::string &str) {
55 if (color_components.size() != 3) {
56 return std::string{
"invalid rgb string: " + str};
59 const auto red_result = porytiles2::parse_int<int>(color_components[0]);
60 const auto green_result = porytiles2::parse_int<int>(color_components[1]);
61 const auto blue_result = porytiles2::parse_int<int>(color_components[2]);
63 if (!red_result.has_value()) {
64 return std::string{
"invalid rgb red component: " + red_result.error()};
66 if (!green_result.has_value()) {
67 return std::string{
"invalid rgb green component: " + green_result.error()};
69 if (!blue_result.has_value()) {
70 return std::string{
"invalid rgb blue component: " + blue_result.error()};
73 const auto red = red_result.value();
74 const auto green = green_result.value();
75 const auto blue = blue_result.value();
77 if (red < 0 || red > 255) {
78 return fmt::format(
"rgb red component out of range: {}", red);
80 if (green < 0 || green > 255) {
81 return fmt::format(
"rgb green component out of range: {}", green);
83 if (blue < 0 || blue > 255) {
84 return fmt::format(
"rgb blue component out of range: {}", blue);
93 static constexpr auto kHint =
"DIAG";
98 name_ =
"DIAGNOSTIC_IS_WARNING";
99 std::unordered_set<std::string> warning_diags;
103 func_ = [warning_diags](
const std::string &str) {
104 if (warning_diags.contains(str)) {
105 return std::string{};
107 return std::string{
"invalid warning diagnostic: " + str};
DiagnosticIsWarningValidator()
NotAlreadyAFileValidator()
std::vector< std::string > split(std::string input, const std::string &delimiter)
Splits a string into tokens based on a delimiter.
std::optional< TilesPalMode > tiles_pal_mode_from_str(const std::string &str)