Porytiles
Loading...
Searching...
No Matches
unwrap_config.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace porytiles {
6
22#define PT_UNWRAP_TILESET_CONFIG_PTR(ptr, config, tileset_name, return_type) \
23 auto config##_result = ptr->config(ConfigScopeType::tileset, tileset_name); \
24 if (!config##_result.has_value()) { \
25 return ChainableResult<return_type>{ \
26 FormattableError{ \
27 "Failed to get config value '{}:{}:{}'.", \
28 FormatParam{"tileset", Style::bold}, \
29 FormatParam{tileset_name, Style::bold}, \
30 FormatParam{#config, Style::bold}}, \
31 config##_result}; \
32 } \
33 auto config = std::move(config##_result).value();
34
50#define PT_UNWRAP_TILESET_CONFIG_REF(ref, config, tileset_name, return_type) \
51 auto config##_result = ref.config(ConfigScopeType::tileset, tileset_name); \
52 if (!config##_result.has_value()) { \
53 return ChainableResult<return_type>{ \
54 FormattableError{ \
55 "Failed to get config value '{}:{}:{}'.", \
56 FormatParam{"tileset", Style::bold}, \
57 FormatParam{tileset_name, Style::bold}, \
58 FormatParam{#config, Style::bold}}, \
59 config##_result}; \
60 } \
61 auto config = std::move(config##_result).value();
62
77#define PT_UNWRAP_LAYOUT_CONFIG(ptr, config, layout_name, return_type) \
78 auto config##_result = ptr->config(ConfigScopeType::layout, layout_name); \
79 if (!config##_result.has_value()) { \
80 return ChainableResult<return_type>{ \
81 FormattableError{ \
82 "Failed to get config value '{}:{}:{}'.", \
83 FormatParam{"layout", Style::bold}, \
84 FormatParam{layout_name, Style::bold}, \
85 FormatParam{#config, Style::bold}}, \
86 config##_result}; \
87 } \
88 auto config = std::move(config##_result).value();
89
90} // namespace porytiles