xbot/driver/settings.cpp

31 lines
1.5 KiB
C++
Raw Normal View History

2023-11-22 19:59:34 -08:00
#include "settings.hpp"
#define TOML_ENABLE_FORMATTERS 0
#include <toml++/toml.hpp>
2025-01-25 15:45:31 -08:00
auto Settings::from_stream(std::istream &in) -> Settings
2023-11-22 19:59:34 -08:00
{
2025-01-25 15:45:31 -08:00
const auto config = toml::parse(in);
2023-11-22 19:59:34 -08:00
return Settings{
2025-01-25 15:45:31 -08:00
.host = config["host"].value_or(std::string{}),
2025-01-26 14:38:13 -08:00
.service = config["port"].value_or(std::uint16_t{6667}),
2025-01-25 12:25:38 -08:00
.password = config["password"].value_or(std::string{}),
.username = config["username"].value_or(std::string{}),
.realname = config["realname"].value_or(std::string{}),
.nickname = config["nickname"].value_or(std::string{}),
.sasl_mechanism = config["sasl_mechanism"].value_or(std::string{}),
.sasl_authcid = config["sasl_authcid"].value_or(std::string{}),
.sasl_authzid = config["sasl_authzid"].value_or(std::string{}),
2025-01-26 14:38:13 -08:00
.sasl_password = config["sasl_password"].value_or(std::string{}),
2025-01-30 16:39:23 -08:00
.sasl_key_file = config["sasl_key_file"].value_or(std::string{}),
.sasl_key_password = config["sasl_key_password"].value_or(std::string{}),
2025-01-26 14:38:13 -08:00
.tls_hostname = config["tls_hostname"].value_or(std::string{}),
2025-01-27 18:55:19 -08:00
.tls_certfile = config["tls_certfile"].value_or(std::string{}),
.tls_keyfile = config["tls_keyfile"].value_or(std::string{}),
2025-01-28 17:15:13 -08:00
. challenge_username = config["challenge_username"].value_or(std::string{}),
. challenge_key_file = config["challenge_key_file"].value_or(std::string{}),
. challenge_key_password = config["challenge_key_password"].value_or(std::string{}),
2025-01-26 14:38:13 -08:00
.use_tls = config["use_tls"].value_or(false),
2023-11-22 19:59:34 -08:00
};
}