AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
parsers.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 <functional>
24#include <string>
25#include <set>
26
27#include "conf/configuration.hpp"
28#include "conf/section.hpp"
29
30#include "singleton.hpp"
31
32
33namespace anch::conf {
34
43 using Parser = std::function<void(const std::filesystem::path& /*path*/,
44 anch::conf::Section& /*section*/)>;
45
55 class Parsers: public anch::Singleton<Parsers> {
58
59 // Attributes +
60 private:
62 std::map<std::string, Parser> _registry;
63
65 std::set<std::string> _protected;
66 // Attributes -
67
68 // Constructors +
69 private:
73 Parsers();
74
75 public:
81 Parsers(const Parsers& parsers) = delete;
82
88 Parsers(Parsers&& parsers) = delete;
89 // Constructors -
90
91 // Destructor +
92 private:
96 virtual ~Parsers();
97 // Destructor -
98
99 // Methods +
100 public:
109 Parsers& registerParser(Parser parser, const std::set<std::string>& extensions);
110
120 Parser getParser(const std::string& extension) const;
121
127 const std::map<std::string, Parser>& getParsers() const;
128 // Methods -
129
130 };
131
132}
133
134#include "conf/impl/parsers.hpp"
Meyers' singleton implementation.
Definition singleton.hpp:34
Application configuration.
Definition configuration.hpp:43
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)