VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
Driver.hpp
Go to the documentation of this file.
1#pragma once
2
5#include <optional>
6#include <string>
7#include <string_view>
8
9namespace VoltMod
10{
11
12/** Database backend selected at runtime by @ref DatabaseConfig::driver. */
13enum class Driver
14{
16 MariaDb,
17 Sqlite
18};
19
20/** Parse a config `driver` value ("postgres", "mariadb", "sqlite"); nullopt for anything else. */
21inline std::optional<Driver> ParseDriver(std::string_view name)
22{
23 return Parse<Driver>(name);
24}
25
26/** The config spelling of @p driver; also the per-dialect migrations folder name. */
27inline std::string DriverName(Driver driver)
28{
29 return Strings::ToLower(Name(driver));
30}
31
32} // namespace VoltMod
Enumerator names without a hand-written switch.
static std::string ToLower(std::string_view str)
Definition Strings.cpp:100
std::optional< Driver > ParseDriver(std::string_view name)
Definition Driver.hpp:21
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::string DriverName(Driver driver)
Definition Driver.hpp:27