Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
settings_parsers.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/io/parsers.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//bertini2/io/parsing/settings_parsers.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with bertini2/io/parsing/settings_parsers.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2015 - 2017 by Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22
28
29#pragma once
30
31
32
34
38
39
40
41
42namespace bertini {
43 namespace parsing {
44
45 namespace classic {
46
57
58 template<typename ConfigT>
59 ConfigT FillConfigStruct(std::string const& config_str)
60 {
61 std::string::const_iterator iter = config_str.begin();
62 std::string::const_iterator end = config_str.end();
63 ConfigT settings;
65 auto parse_success = phrase_parse(iter, end, parser,boost::spirit::ascii::space, settings);
66 if (!parse_success || iter!=end)
67 throw std::runtime_error("failed to parse into config struct from file");
68
69 return settings;
70 }
71
72
73
74
83 template<typename ...Ts>
85 {
97 static
98 std::tuple<Ts...> Parse(std::string const& config)
99 {
100 return std::make_tuple<Ts...>(FillConfigStruct<Ts>(config)...);
101 }
102
103 };
104
105
112 template<typename ConfigT>
113 struct ConfigParser <ConfigT>
114 {
115
123 static
124 ConfigT Parse(std::string const& config)
125 {
126 return FillConfigStruct<ConfigT>(config);
127 }
128 };
129
130
137 template<typename ...Ts>
138 struct ConfigParser<detail::TypeList<Ts...>>
139 {
140 static
141 auto Parse(std::string const& config)
142 {
143 return ConfigParser<Ts...>::Parse(config);
144 }
145 };
146 } // re: namespace classic
147
148 }// re: namespace parsing
149}// re: namespace bertini
Provides the parsing rules for algorithm-related settings in bertini2.
Provides the parsing rules for endgames-related settings in bertini2.
Provides the parsing rules for tracking-related settings in bertini2.
ConfigT FillConfigStruct(std::string const &config_str)
Helper function to fill a single configuration struct by parsing a config input file.
Definition settings_parsers.hpp:59
static ConfigT Parse(std::string const &config)
Fill a single configuration struct by parsing a config input file.
Definition settings_parsers.hpp:124
Base variadic parser for parsing many config structs at once.
Definition settings_parsers.hpp:85
static std::tuple< Ts... > Parse(std::string const &config)
Reads in a comment-stripped, config portion of a Bertini classic input file. Parses the config settin...
Definition settings_parsers.hpp:98
Contains the detail/typelist helper type, for templated getting/setting/storage of config structs.