AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
configuration.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-conf-export.hpp"
23
24#include <map>
25#include <optional>
26#include <string>
27#include <vector>
28#include <filesystem>
29
30#include "conf/section.hpp"
31#include "conf/confError.hpp"
32
33namespace anch::conf {
34
45 class ANCH_CONF_EXPORT Configuration {
46
47 // Attributes +
48 private:
50 bool _loaded;
51
53 std::string _name;
54
56 std::vector<std::string> _profiles;
57
59 std::vector<std::string> _includes;
60
62 std::vector<std::string> _folders;
63
66 // Attributes -
67
68 // Constructors +
69 private:
73 Configuration();
74
75 public:
81 Configuration(const Configuration& conf) = delete;
82
88 Configuration(Configuration&& conf) = delete;
89 // Constructors -
90
91 // Destructor +
92 private:
96 virtual ~Configuration();
97 // Destructor -
98
99 // Methods +
100 public:
108 static const Configuration& inst();
109
115 static Configuration& loader() noexcept;
116
124 Configuration& folders(const std::vector<std::filesystem::path>& folders) noexcept;
125
133 Configuration& name(const std::string& name) noexcept;
134
142 Configuration& profiles(const std::vector<std::string>& profiles) noexcept;
143
164 Configuration& load();
165
173 const anch::conf::Section* section(const std::string& path) const noexcept;
174
182 std::optional<std::string> value(const std::string& path) const noexcept;
183
184 private:
192 void loadProfile(const std::string& profile);
193 // Methods -
194
195 };
196
197}
198
199#include "conf/impl/configuration.hpp"
Configuration & folders(const std::vector< std::filesystem::path > &folders) noexcept
std::optional< std::string > value(const std::string &path) const noexcept
const anch::conf::Section * section(const std::string &path) const noexcept
Configuration & profiles(const std::vector< std::string > &profiles) noexcept
Configuration & name(const std::string &name) noexcept
static const Configuration & inst()
Configuration(Configuration &&conf)=delete
Configuration & load()
static Configuration & loader() noexcept
Configuration(const Configuration &conf)=delete
AnCH configuration library namespace.
anch::ini::Section Section
Definition section.hpp:27
AnCH framework base namespace.
Definition app.hpp:30