AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
configuration.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 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 <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <map>
23#include <optional>
24#include <string>
25#include <vector>
26#include <filesystem>
27
28#include "conf/section.hpp"
29#include "conf/confError.hpp"
30
31namespace anch::conf {
32
43 class Configuration {
44
45 // Attributes +
46 private:
48 bool _loaded;
49
51 std::string _name;
52
54 std::vector<std::string> _profiles;
55
57 std::vector<std::string> _includes;
58
60 std::vector<std::string> _folders;
61
63 anch::conf::Section _root;
64 // Attributes -
65
66 // Constructors +
67 private:
71 Configuration();
72
73 public:
79 Configuration(const Configuration& conf) = delete;
80
86 Configuration(Configuration&& conf) = delete;
87 // Constructors -
88
89 // Destructor +
90 private:
94 virtual ~Configuration();
95 // Destructor -
96
97 // Methods +
98 public:
106 static const Configuration& inst();
107
113 static Configuration& loader() noexcept;
114
122 Configuration& folders(const std::vector<std::filesystem::path>& folders) noexcept;
123
131 Configuration& name(const std::string& name) noexcept;
132
140 Configuration& profiles(const std::vector<std::string>& profiles) noexcept;
141
156 Configuration& load();
157
165 const anch::conf::Section* section(const std::string& path) const noexcept;
166
174 std::optional<std::string> value(const std::string& path) const noexcept;
175
176 private:
184 void loadProfile(const std::string& profile);
185 // Methods -
186
187 };
188
189}
190
191#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 framework base namespace.
Definition app.hpp:28