AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
parsers.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 <functional>
26#include <string>
27#include <set>
28
29#include "conf/configuration.hpp"
30#include "conf/section.hpp"
31
32#include "singleton.hpp"
33
34
35namespace anch::conf {
36
45 using Parser = std::function<void(const std::filesystem::path& /*path*/,
46 anch::conf::Section& /*section*/)>;
47
57 class ANCH_CONF_EXPORT Parsers: public anch::Singleton<Parsers> {
58 friend class anch::conf::Configuration;
59 friend class anch::Singleton<Parsers>;
60
61 // Attributes +
62 private:
64 std::map<std::string, Parser> _registry;
65
67 std::set<std::string> _protected;
68 // Attributes -
69
70 // Constructors +
71 private:
75 Parsers();
76
77 public:
83 Parsers(const Parsers& parsers) = delete;
84
90 Parsers(Parsers&& parsers) = delete;
91 // Constructors -
92
93 // Destructor +
94 private:
98 virtual ~Parsers();
99 // Destructor -
100
101 // Methods +
102 public:
111 Parsers& registerParser(Parser parser, const std::set<std::string>& extensions);
112
122 Parser getParser(const std::string& extension) const;
123
129 const std::map<std::string, Parser>& getParsers() const;
130 // Methods -
131
132 };
133
134}
135
136#include "conf/impl/parsers.hpp"
Meyers' singleton implementation.
Definition singleton.hpp:50
Application configuration.
Definition configuration.hpp:45
Parsers(Parsers &&parsers)=delete
const std::map< std::string, Parser > & getParsers() const
Parsers(const Parsers &parsers)=delete
Parser getParser(const std::string &extension) const
Parsers & registerParser(Parser parser, const std::set< std::string > &extensions)
AnCH configuration library namespace.
anch::ini::Section Section
Definition section.hpp:27
std::function< void(const std::filesystem::path &, anch::conf::Section &)> Parser
Definition parsers.hpp:45