Porytiles
Loading...
Searching...
No Matches
layer_value.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <optional>
4#include <string>
5#include <vector>
6
7namespace porytiles {
8
17enum class ValidationState {
18 not_provided, // Provider doesn't supply this config
19 valid, // Provider supplies valid config
20 invalid // Provider found invalid config
21};
22
33template <typename T>
34struct LayerValue {
35 std::optional<T> value;
36 std::string source_key;
37 std::string source_info;
38 std::vector<std::string> source_details;
40 std::string error_message;
41
48 static LayerValue valid(T val, std::string source_key, std::string source_info)
49 {
50 return LayerValue{
51 std::move(val), std::move(source_key), std::move(source_info), {}, ValidationState::valid, ""};
52 }
53
62 static LayerValue
63 valid(T val, std::string source_key, std::string source_info, std::vector<std::string> source_details)
64 {
65 return LayerValue{
66 std::move(val),
67 std::move(source_key),
68 std::move(source_info),
69 std::move(source_details),
71 ""};
72 }
73
79 static LayerValue invalid(std::string error, std::string source_info)
80 {
81 return LayerValue{std::nullopt, "", std::move(source_info), {}, ValidationState::invalid, std::move(error)};
82 }
83
90 static LayerValue invalid(std::string error, std::string source_info, std::vector<std::string> source_details)
91 {
92 return LayerValue{
93 std::nullopt,
94 "",
95 std::move(source_info),
96 std::move(source_details),
98 std::move(error)};
99 }
100
105 {
106 return LayerValue{std::nullopt, "", "", {}, ValidationState::not_provided, ""};
107 }
108};
109
118template <typename T>
120 std::string provider_name;
122};
123
124} // namespace porytiles
@ not_provided
nothing attribute-related was found; other providers should be consulted
@ valid
one or more usable candidate sets were inferred
@ invalid
no layout could be determined from what the project declares (fatal at resolution time)
@ error
Emit a formatted error and fail decompilation.
ValidationState
Represents the validation state of a configuration value from a ConfigProvider.
A small container that holds an optional-wrapped value, validation state, and metadata about the valu...
static LayerValue valid(T val, std::string source_key, std::string source_info)
Creates a LayerValue representing a valid configuration value.
std::optional< T > value
std::vector< std::string > source_details
static LayerValue invalid(std::string error, std::string source_info, std::vector< std::string > source_details)
Creates a LayerValue representing an invalid configuration value with detailed source context.
static LayerValue valid(T val, std::string source_key, std::string source_info, std::vector< std::string > source_details)
Creates a LayerValue representing a valid configuration value with detailed source context.
std::string error_message
static LayerValue not_provided()
Creates a LayerValue representing that the provider does not supply this configuration.
ValidationState state
static LayerValue invalid(std::string error, std::string source_info)
Creates a LayerValue representing an invalid configuration value.