File size: 681 Bytes
d6bb3fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
 * @file config.hpp
 * @brief Application configuration using modern C++23 features.
 */

#pragma once

#include <string>
#include <optional>
#include <expected>
#include <format>

namespace app::core {

/**
 * @brief Runtime configuration loaded from environment or defaults.
 */
struct Config {
    std::string app_name{"MyApp"};
    std::string database_url{"sqlite:///app.db"};
    std::string secret_key{"change-me"};
    int port{8080};
    bool debug{false};

    /**
     * @brief Load configuration from environment variables.
     * @return Config object or error string.
     */
    static std::expected<Config, std::string> from_env();
};

} // namespace app::core