xbot/settings.cpp

22 lines
883 B
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{}),
.service = config["service"].value_or(std::string{}),
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{}),
.sasl_password = config["sasl_password"].value_or(std::string{})
2023-11-22 19:59:34 -08:00
};
}