src/parser.h

Wed, 19 Apr 2023 22:42:43 +0300

author
Teemu Piippo <teemu.s.piippo@gmail.com>
date
Wed, 19 Apr 2023 22:42:43 +0300
changeset 380
16f6717a218b
parent 358
ef90ed0a5720
permissions
-rw-r--r--

Use QFileInfo to represent paths

3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 /*
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
24
1a0faaaceb84 added license
Teemu Piippo <teemu@hecknology.net>
parents: 14
diff changeset
3 * Copyright (C) 2013 - 2020 Teemu Piippo
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 *
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 * (at your option) any later version.
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 *
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 * GNU General Public License for more details.
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14 *
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17 */
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
18
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
19 #pragma once
264
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 206
diff changeset
20 #include "src/basics.h"
76a025db4948 Convert all includes to be relative to project root directory. Files that cannot be found in this manner use angle brackets.
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 206
diff changeset
21 #include "src/model.h"
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
22
333
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
23 struct TextRange
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 {
333
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
25 int start;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
26 int length;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
27 };
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
28
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
29
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
30 enum class Attribute {
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
31 LineType,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
32 Color,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
33 X1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
34 Y1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
35 Z1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
36 X2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
37 Y2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
38 Z2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
39 X3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
40 Y3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
41 Z3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
42 X4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
43 Y4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
44 Z4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
45 Name,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
46 Text
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
47 };
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
48
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
49 template<typename T, Attribute... Attribs>
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
50 struct LineType
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
51 {
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
52 static constexpr Attribute attributes[] = {Attribs...};
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
53 QString content;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
54 TextRange positions[countof(attributes)];
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
55 T value;
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
56 };
200
ca23936b455b Giant refactor
Teemu Piippo <teemu@hecknology.net>
parents: 176
diff changeset
57
358
ef90ed0a5720 Hopefully fixed all problems with determining polygon winding
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 333
diff changeset
58 using LineType0 = LineType<Comment, Attribute::LineType, Attribute::Text>;
333
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
59 using LineType1 = LineType<Colored<SubfileReference>,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
60 Attribute::LineType,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
61 Attribute::Color,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
62 Attribute::X1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
63 Attribute::Y1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
64 Attribute::Z1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
65 Attribute::X2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
66 Attribute::Y2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
67 Attribute::Z2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
68 Attribute::X3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
69 Attribute::Y3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
70 Attribute::Z3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
71 Attribute::X4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
72 Attribute::Y4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
73 Attribute::Z4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
74 Attribute::Name>;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
75 using LineType2 = LineType<Colored<LineSegment>,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
76 Attribute::LineType,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
77 Attribute::Color,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
78 Attribute::X1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
79 Attribute::Y1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
80 Attribute::Z1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
81 Attribute::X2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
82 Attribute::Y2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
83 Attribute::Z2>;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
84 using LineType3 = LineType<Colored<Triangle>,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
85 Attribute::LineType,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
86 Attribute::Color,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
87 Attribute::X1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
88 Attribute::Y1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
89 Attribute::Z1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
90 Attribute::X2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
91 Attribute::Y2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
92 Attribute::Z2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
93 Attribute::X3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
94 Attribute::Y3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
95 Attribute::Z3>;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
96 using LineType4 = LineType<Colored<Quadrilateral>,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
97 Attribute::LineType,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
98 Attribute::Color,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
99 Attribute::X1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
100 Attribute::Y1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
101 Attribute::Z1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
102 Attribute::X2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
103 Attribute::Y2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
104 Attribute::Z2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
105 Attribute::X3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
106 Attribute::Y3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
107 Attribute::Z3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
108 Attribute::X4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
109 Attribute::Y4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
110 Attribute::Z4>;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
111 using LineType5 = LineType<Colored<ConditionalEdge>,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
112 Attribute::LineType,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
113 Attribute::Color,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
114 Attribute::X1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
115 Attribute::Y1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
116 Attribute::Z1,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
117 Attribute::X2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
118 Attribute::Y2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
119 Attribute::Z2,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
120 Attribute::X3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
121 Attribute::Y3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
122 Attribute::Z3,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
123 Attribute::X4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
124 Attribute::Y4,
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
125 Attribute::Z4>;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
126
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
127 template<typename T, Attribute Attrib>
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
128 constexpr int findAttributeIndex()
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
129 {
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
130 constexpr auto it = std::find(
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
131 std::begin(T::attributes),
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
132 std::end(T::attributes),
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
133 Attrib
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
134 );
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
135 static_assert(it != std::end(T::attributes), "Attribute not found");
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
136 return it - std::begin(T::attributes);
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
137 }
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
138
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
139 template<typename T, Attribute Attrib>
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
140 constexpr int attribIndex = findAttributeIndex<T, Attrib>();
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
141 static_assert(attribIndex<LineType3, Attribute::X1> == 2);
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
142 using ParsedLine = std::variant<LineType0, LineType1, LineType2, LineType3, LineType4, LineType5>;
07e65a4c6611 Experiment to delete the Model class and rely solely on text documents
Teemu Piippo <teemu.s.piippo@gmail.com>
parents: 328
diff changeset
143 opt<ParsedLine> parse(const QString& line);

mercurial