Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
system_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/system_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/system_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
33
35
36
37
38namespace bertini {
39 namespace parsing {
40
41 namespace classic {
42
43
44
45 template <typename Iterator>
46 static bool parse(Iterator first, Iterator last, System& sys)
47 {
48 using boost::spirit::qi::double_;
49 using boost::spirit::qi::_1;
50 using boost::spirit::qi::phrase_parse;
51 using boost::spirit::ascii::space;
52 using boost::phoenix::ref;
53
55
56 System s{};
57 bool r = phrase_parse(first, last,
58 S,
59 space,
60 s);
61
62 if (!r || first != last) // fail if we did not get a full match
63 return false;
64
65 sys = s;
66 return r;
67 }
68
69 } // re: namespace classic
70
71 }// re: namespace parsing
72
73 inline
74 System::System(std::string const& input)
75 {
76 System sys;
77
79
80 std::string::const_iterator iter = input.begin();
81 std::string::const_iterator end = input.end();
82
83 bool s = phrase_parse(iter, end, S,boost::spirit::ascii::space, sys);
84
85 if (!s || iter!=end)
86 {
87 throw std::runtime_error("unable to correctly parse string in construction of system");
88 }
89
90 using std::swap;
91 swap(sys,*this);
92 }
93
94}// re: namespace bertini
95
96
friend void swap(System &a, System &b)
System()
The default constructor for a system.
Definition system/system.hpp:111
Qi Parser object for parsing text into the System class.
Definition system_rules.hpp:79
Provides the parsing rules for systems in bertini2.