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

Go to the source code of this file.

Namespaces

namespace  porytiles
 

Macros

#define PT_UNWRAP_TILESET_CONFIG_PTR(ptr, config, tileset_name, return_type)
 Unwraps a tileset-scoped config value via pointer access, returning early if the value is not available.
 
#define PT_UNWRAP_TILESET_CONFIG_REF(ref, config, tileset_name, return_type)
 Unwraps a tileset-scoped config value via reference access, returning early if the value is not available.
 
#define PT_UNWRAP_LAYOUT_CONFIG(ptr, config, layout_name, return_type)
 Unwraps a layout-scoped config value from a DomainConfig, AppConfig, or InfraConfig object, returning early if the value is not available.
 

Macro Definition Documentation

◆ PT_UNWRAP_LAYOUT_CONFIG

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

Unwraps a layout-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 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
layout_nameThe layout name to pass to the config method
return_typeThe template parameter for ChainableResult in case of error

Definition at line 77 of file unwrap_config.hpp.

◆ PT_UNWRAP_TILESET_CONFIG_PTR

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

Unwraps a tileset-scoped config value via pointer access, returning early if the value is not available.

This macro retrieves a config value for a given tileset using pointer syntax (ptr->config) 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 DomainConfig, AppConfig, or InfraConfig object
configThe name of the config method to call and the resulting variable name
tileset_nameThe tileset name to pass to the config method
return_typeThe template parameter for ChainableResult in case of error
See also
PT_UNWRAP_TILESET_CONFIG_REF for reference-based access

Definition at line 22 of file unwrap_config.hpp.

◆ PT_UNWRAP_TILESET_CONFIG_REF

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

Unwraps a tileset-scoped config value via reference access, returning early if the value is not available.

This macro retrieves a config value for a given tileset using reference syntax (ref.config) 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
refA reference to a DomainConfig, AppConfig, or InfraConfig object
configThe name of the config method to call and the resulting variable name
tileset_nameThe tileset name to pass to the config method
return_typeThe template parameter for ChainableResult in case of error
See also
PT_UNWRAP_TILESET_CONFIG_PTR for pointer-based access

Definition at line 50 of file unwrap_config.hpp.