Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
variable_settings.hpp
Go to the documentation of this file.
1
4#pragma once
6#include <aegis2d/core/export.hpp>
7
8#include <filesystem>
9#include <span>
10#include <string>
11#include <string_view>
12#include <vector>
13
14namespace aegis2d::core {
15
17struct VarSetting {
19 std::string name{};
21 std::string value{};
23 std::string origin{};
24};
25
29 std::vector<VarSetting> settings{};
31 std::vector<std::string> errors{};
32};
33
40[[nodiscard]] AEGIS2D_CORE_EXPORT VarSettings
41settings_from_arguments(std::span<const std::string_view> arguments);
42
47[[nodiscard]] AEGIS2D_CORE_EXPORT VarSettings settings_from_arguments(int argc, char** argv);
48
61[[nodiscard]] AEGIS2D_CORE_EXPORT VarSettings settings_from_text(std::string_view text,
62 std::string_view origin);
63
67[[nodiscard]] AEGIS2D_CORE_EXPORT VarSettings settings_from_file(const std::filesystem::path& file);
68
77AEGIS2D_CORE_EXPORT std::vector<std::string> apply_settings(ConsoleVariables& variables,
78 std::span<const VarSetting> settings);
79
80} // namespace aegis2d::core
The settings a console reads and changes by name while the game runs.
Definition console_variables.hpp:80
Console variables: named, typed settings with a default, a description and flags.
Logging, time, main loop, events and configuration shared by client and server.
Definition clock.hpp:11
std::vector< std::string > apply_settings(ConsoleVariables &variables, std::span< const VarSetting > settings)
Sets variables, in order: a later setting wins over an earlier one.
VarSettings settings_from_file(const std::filesystem::path &file)
Reads settings from a file, as settings_from_text() reads text.
VarSettings settings_from_text(std::string_view text, std::string_view origin)
Reads settings from text, one per line.
VarSettings settings_from_arguments(std::span< const std::string_view > arguments)
Reads the +set name value of a command line.
A variable to set, as a command line or a settings file gives it.
Definition variable_settings.hpp:17
std::string name
Name of the variable.
Definition variable_settings.hpp:19
std::string origin
Where it comes from, for the errors: "command line" or "game.cfg:3".
Definition variable_settings.hpp:23
std::string value
Its value as text, read in the variable's type by ConsoleVariables::set_text().
Definition variable_settings.hpp:21
Settings read from a command line or a file, and what could not be read.
Definition variable_settings.hpp:27
std::vector< VarSetting > settings
Settings, in the order they were given.
Definition variable_settings.hpp:29
std::vector< std::string > errors
Such as "command line: +set needs a name and a value".
Definition variable_settings.hpp:31