5#include <unordered_set>
15 static constexpr auto kHint =
"MODE";
19 name_ =
"TILES_OUTPUT_PAL";
20 func_ = [](
const std::string &str) {
22 return std::string{
"invalid 'tiles.png' output palette mode: " + str};
30 static constexpr auto kHint =
"PATH";
34 name_ =
"NOT_ALREADY_A_FILE";
35 func_ = [](
const std::string &str) {
36 if (std::filesystem::exists(str) && std::filesystem::is_regular_file(str)) {
37 return std::string{
"file already exists: " + str};
45 static constexpr auto kHint =
"R,G,B";
50 func_ = [](
const std::string &str) {
51 const std::vector<std::string> color_components =
porytiles::split(str,
",");
52 if (color_components.size() != 3) {
53 return std::string{
"invalid rgb string: " + str};
56 const auto red_result = porytiles::ParseInt<int>(color_components[0]);
57 const auto green_result = porytiles::ParseInt<int>(color_components[1]);
58 const auto blue_result = porytiles::ParseInt<int>(color_components[2]);
60 if (!red_result.has_value()) {
61 return std::string{
"invalid rgb red component: " + red_result.error()};
63 if (!green_result.has_value()) {
64 return std::string{
"invalid rgb green component: " + green_result.error()};
66 if (!blue_result.has_value()) {
67 return std::string{
"invalid rgb blue component: " + blue_result.error()};
70 const auto red = red_result.value();
71 const auto green = green_result.value();
72 const auto blue = blue_result.value();
74 if (red < 0 || red > 255) {
75 return fmt::format(
"rgb red component out of range: {}", red);
77 if (green < 0 || green > 255) {
78 return fmt::format(
"rgb green component out of range: {}", green);
80 if (blue < 0 || blue > 255) {
81 return fmt::format(
"rgb blue component out of range: {}", blue);
90 static constexpr auto kHint =
"DIAG";
94 name_ =
"DIAGNOSTIC_IS_WARNING";
95 std::unordered_set<std::string> warning_diags;
97 warning_diags.insert(name);
99 func_ = [warning_diags](
const std::string &str) {
100 if (warning_diags.contains(str)) {
101 return std::string{};
103 return std::string{
"invalid warning diagnostic: " + str};
DiagnosticIsWarningValidator()
NotAlreadyAFileValidator()
std::vector< const char * > AllDiagNames()
Gets an iterable view of all DiagTempl names in the internal table.
std::optional< TilesPalMode > TilesPalModeFromStr(const std::string &str)
std::vector< std::string > split(std::string input, const std::string &delimiter)