NcEngine
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
Config.h File Reference
#include <filesystem>
#include <string>

Go to the source code of this file.

Classes

struct  nc::config::ProjectSettings
 General project options. More...
 
struct  nc::config::EngineSettings
 Settings for configuring the engine run loop and executor. More...
 
struct  nc::config::AssetSettings
 Options for configuring NcAsset. More...
 
struct  nc::config::MemorySettings
 Options for configuring pre-allocated pools. More...
 
struct  nc::config::GraphicsSettings
 Options for configuring NcGraphics. More...
 
struct  nc::config::PhysicsSettings
 Options for configuring NcPhysics. More...
 
struct  nc::config::AudioSettings
 Options for configuring NcAudio. More...
 
struct  nc::config::Config
 A collection of all configuration options. More...
 

Functions

auto nc::config::Load (const std::filesystem::path &path) -> Config
 Load a Config object from a file. More...
 
void nc::config::Save (const std::filesystem::path &path, const Config &config)
 Write a Config object's contents to a file. More...
 
auto nc::config::Validate (const Config &config) -> bool
 Check if a Config object is in a valid state for initializing NcEngine. More...
 
auto nc::config::GetProjectSettings () -> const ProjectSettings &
 Get the ProjectSettings NcEngine was initialized with.
 
auto nc::config::GetEngineSettings () -> const EngineSettings &
 Get the EngineSettings NcEngine was initialized with.
 
auto nc::config::GetAssetSettings () -> const AssetSettings &
 Get the AssetSettings NcEngine was initialized with.
 
auto nc::config::GetMemorySettings () -> const MemorySettings &
 Get the MemorySettings NcEngine was initialized with.
 
auto nc::config::GetGraphicsSettings () -> const GraphicsSettings &
 Get the GraphicsSettings NcEngine was initialized with.
 
auto nc::config::GetPhysicsSettings () -> const PhysicsSettings &
 Get the PhysicsSettings NcEngine was initialized with.
 
auto nc::config::GetAudioSettings () -> const AudioSettings &
 Get the AudioSettings NcEngine was initialized with.
 

Detailed Description

Function Documentation

◆ Load()

auto nc::config::Load ( const std::filesystem::path &  path) -> Config

Load a Config object from a file.

Parameters
pathThe path to a config file.
Returns
A Config object initialized with key-value pairs from the file.
Exceptions
NcErrorif there is a failure opening or reading values from the file or if Validate() fails on the resulting Config object.

The input file may contain any config options as equals-separated key-value pairs, each on their own line. Any options absent in the file will be initialized to their default values.

The following are ignored:

  • Unrecognized options
  • Leading/trailing whitespace and empty lines
  • Line comments starting with ';' or '#'
  • Sections (e.g. [my_section])

For a listing of all keys see the Sample or create a default file with: Save("config.ini", nc::config::Config{});

◆ Save()

void nc::config::Save ( const std::filesystem::path &  path,
const Config config 
)

Write a Config object's contents to a file.

Parameters
pathThe file path to be written to.
configThe object data to be written.
Exceptions
NcErrorif the file cannot be opened or created.

◆ Validate()

auto nc::config::Validate ( const Config config) -> bool

Check if a Config object is in a valid state for initializing NcEngine.

Parameters
configThe object to verify.
Returns
A bool indicating whether or not the object is valid.
Note
This should be called on any manually constructed Config object prior to initializing the engine with it. It does not need to be called on an object returned from nc::config::Load().