Porytiles
Loading...
Searching...
No Matches
unwrap_config.hpp File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  porytiles2
 

Macros

#define PT_UNWRAP_SCOPED_CONFIG(ptr, config, tileset, return_type)
 Unwraps a scoped config value from a DomainConfig, AppConfig, or InfraConfig object, returning early if the value is not available.
 

Macro Definition Documentation

◆ PT_UNWRAP_SCOPED_CONFIG

#define PT_UNWRAP_SCOPED_CONFIG (   ptr,
  config,
  tileset,
  return_type 
)
Value:
auto config##_result = ptr->config(tileset); \
if (!config##_result.has_value()) { \
return ChainableResult<return_type>{ \
FormattableError{ \
"failed to get config value '{}:{}'", \
FormatParam{tileset, Style::bold}, \
FormatParam{#config, Style::bold}}, \
config##_result}; \
} \
auto config = std::move(config##_result).value();

Unwraps a scoped config value from a DomainConfig, AppConfig, or InfraConfig object, returning early if the value is not available.

This macro retrieves a config value for a given tileset or layout and automatically handles the error case. If the config value is not available, it returns a ChainableResult error with a formatted message. Otherwise, it unwraps the value and creates a local variable with the name specified by the config parameter.

Parameters
ptrA pointer to a config object
configThe name of the config method to call and the resulting variable name
tilesetThe tileset parameter to pass to the config method
return_typeThe template parameter for ChainableResult in case of error

Definition at line 19 of file unwrap_config.hpp.