diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2021-11-17 22:34:57 +0100 |
| commit | 6232d13f5321b87ddf12a1aa36b4545da45f173d (patch) | |
| tree | 23f3316470a14136debd9d02f9e920ca2b06f4cc /src/config.hh | |
Travel3: Simple image and video display site
Reads the images and videos from filesystem and builds a site in
memroy.
Diffstat (limited to 'src/config.hh')
| -rw-r--r-- | src/config.hh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/config.hh b/src/config.hh new file mode 100644 index 0000000..fd0f067 --- /dev/null +++ b/src/config.hh @@ -0,0 +1,48 @@ +#ifndef CONFIG_HH +#define CONFIG_HH + +#include <filesystem> +#include <memory> +#include <optional> +#include <stdint.h> +#include <string> +#include <string_view> +#include <unordered_map> + +class Logger; + +class Config { +public: + virtual ~Config() = default; + + static std::unique_ptr<Config> create(Logger* logger, + std::filesystem::path const& filepath); + + static std::unique_ptr<Config> create( + std::unordered_map<std::string, std::string> data, + std::filesystem::path root); + static std::unique_ptr<Config> create_empty(); + + virtual std::string_view get(std::string const& key, + std::string_view default_) const = 0; + virtual char const* get(std::string const& key, + char const* default_) const = 0; + virtual std::optional<uint64_t> get(std::string const& key, + uint64_t default_) const = 0; + + virtual std::optional<uint64_t> get_size(std::string const& key, + uint64_t default_) const = 0; + + virtual std::optional<double> get_duration(std::string const& key, + double default_) const = 0; + + virtual std::filesystem::path get_path(std::string const& key, + std::string_view default_) const = 0; + +protected: + Config() = default; + Config(Config const&) = delete; + Config& operator=(Config const&) = delete; +}; + +#endif // CONFIG_HH |
