plugify 1.2.8
Loading...
Searching...
No Matches
config_provider.hpp
1#pragma once
2
3#include <any>
4#include <filesystem>
5#include <string>
6
7#include "plugify/types.hpp"
8
9namespace plugify {
10 // Configuration interface
11 /*class IConfigProvider {
12 public:
13 virtual ~IConfigProvider() = default;
14 virtual Result<std::any> GetValue(std::string_view key) = 0;
15 virtual Result<void> SetValue(std::string_view key, std::any value) = 0;
16 virtual Result<void> LoadFromFile(const std::filesystem::path& path) = 0;
17 virtual Result<void> SaveToFile(const std::filesystem::path& path) = 0;
18 [[nodiscard]] virtual bool IsDirty() const = 0;
19
20 // Type-safe getters using concepts
21 template<typename T>
22 Result<T> GetAs(std::string_view key) {
23 auto result = GetValue(key);
24 if (!result) return std::unexpected(result.error());
25
26 try {
27 return std::any_cast<T>(*result);
28 } catch (const std::bad_any_cast&) {
29 return std::unexpected("Type mismatch for config key");
30 }
31 }
32 };*/
33}