Porytiles
Loading...
Searching...
No Matches
unwrap_config.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace porytiles {
6
28#define PT_UNWRAP_TILESET_CONFIG_PTR_AS(var, ptr, config, tileset_name, return_type) \
29 auto var##_result = ptr->config(ConfigScopeType::tileset, tileset_name); \
30 if (!var##_result.has_value()) { \
31 return ChainableResult<return_type>{ \
32 FormattableError{ \
33 "Failed to get config value '{}:{}:{}'.", \
34 FormatParam{"tileset", Style::bold}, \
35 FormatParam{tileset_name, Style::bold}, \
36 FormatParam{#config, Style::bold}}, \
37 var##_result}; \
38 } \
39 auto var = std::move(var##_result).value();
40
55#define PT_UNWRAP_TILESET_CONFIG_PTR(ptr, config, tileset_name, return_type) \
56 PT_UNWRAP_TILESET_CONFIG_PTR_AS(config, ptr, config, tileset_name, return_type)
57
79#define PT_UNWRAP_TILESET_CONFIG_REF_AS(var, ref, config, tileset_name, return_type) \
80 auto var##_result = ref.config(ConfigScopeType::tileset, tileset_name); \
81 if (!var##_result.has_value()) { \
82 return ChainableResult<return_type>{ \
83 FormattableError{ \
84 "Failed to get config value '{}:{}:{}'.", \
85 FormatParam{"tileset", Style::bold}, \
86 FormatParam{tileset_name, Style::bold}, \
87 FormatParam{#config, Style::bold}}, \
88 var##_result}; \
89 } \
90 auto var = std::move(var##_result).value();
91
106#define PT_UNWRAP_TILESET_CONFIG_REF(ref, config, tileset_name, return_type) \
107 PT_UNWRAP_TILESET_CONFIG_REF_AS(config, ref, config, tileset_name, return_type)
108
128#define PT_UNWRAP_LAYOUT_CONFIG_AS(var, ptr, config, layout_name, return_type) \
129 auto var##_result = ptr->config(ConfigScopeType::layout, layout_name); \
130 if (!var##_result.has_value()) { \
131 return ChainableResult<return_type>{ \
132 FormattableError{ \
133 "Failed to get config value '{}:{}:{}'.", \
134 FormatParam{"layout", Style::bold}, \
135 FormatParam{layout_name, Style::bold}, \
136 FormatParam{#config, Style::bold}}, \
137 var##_result}; \
138 } \
139 auto var = std::move(var##_result).value();
140
155#define PT_UNWRAP_LAYOUT_CONFIG(ptr, config, layout_name, return_type) \
156 PT_UNWRAP_LAYOUT_CONFIG_AS(config, ptr, config, layout_name, return_type)
157
158} // namespace porytiles