summaryrefslogtreecommitdiffstats
path: root/src/core/io/config_map.hh
blob: 2e3f18ff31394cf94694f478a050277fa7996c47 (plain)
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
34
35
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (c) 2025 Kirill Dmitrievich
// File: config_map.hh
// Description: Config parser

#ifndef CORE_IO_CONFIG_MAP_HH
#define CORE_IO_CONFIG_MAP_HH
#pragma once

namespace config
{
class IValue;
} // namespace config

class ConfigMap final {
public:
    ConfigMap(void) = default;
    virtual ~ConfigMap(void) = default;

    void load_cmdline(void);
    bool load_file(std::string_view path);
    bool save_file(std::string_view path) const;

    bool set_value(std::string_view name, std::string_view value);
    std::string_view get_value(std::string_view name) const;

    void add_value(std::string_view name, config::IValue& vref);

    const config::IValue* find(std::string_view name) const;

private:
    std::unordered_map<std::string, config::IValue*> m_values;
};

#endif