src/parser.cpp

changeset 13
6e838748867b
parent 12
fe67489523b5
child 14
20d2ed3af73d
--- a/src/parser.cpp	Sun Nov 03 17:57:21 2019 +0200
+++ b/src/parser.cpp	Sun Nov 03 18:09:47 2019 +0200
@@ -254,10 +254,10 @@
 			invertNext = true;
 			continue;
 		}
-		std::unique_ptr<modelobjects::BaseObject> object = parseFromString(line);
+		std::unique_ptr<linetypes::Object> object = parseFromString(line);
 		if (invertNext)
 		{
-			editor.setObjectProperty(object.get(), modelobjects::Property::IsInverted, true);
+			editor.setObjectProperty(object.get(), linetypes::Property::IsInverted, true);
 		}
 		editor.append(std::move(object));
 		invertNext = false;
@@ -317,22 +317,22 @@
 	return result;
 }
 
-static std::unique_ptr<modelobjects::BaseObject> parseType0Line(
+static std::unique_ptr<linetypes::Object> parseType0Line(
 	const QString& line,
 	const QStringList& tokens)
 {
 	Q_UNUSED(tokens)
 	if (line.startsWith("0 //"))
 	{
-		return std::make_unique<modelobjects::Comment>(line.mid(std::strlen("0 //")).simplified());
+		return std::make_unique<linetypes::Comment>(line.mid(std::strlen("0 //")).simplified());
 	}
 	else
 	{
-		return std::make_unique<modelobjects::MetaCommand>(line.mid(1).simplified());
+		return std::make_unique<linetypes::MetaCommand>(line.mid(1).simplified());
 	}
 }
 
-static std::unique_ptr<modelobjects::SubfileReference> parseType1Line(
+static std::unique_ptr<linetypes::SubfileReference> parseType1Line(
 	const QString& line,
 	const QStringList& tokens)
 {
@@ -349,7 +349,7 @@
 	const Vertex position = vertexFromStrings(tokens, positionPosition);
 	const Matrix3x3 transform = matrixFromStrings(tokens, transformPosition);
 	const QString& name = tokens[namePosition];
-	return std::make_unique<modelobjects::SubfileReference>(position, transform, name, color);
+	return std::make_unique<linetypes::SubfileReference>(position, transform, name, color);
 }
 
 template<typename T, int NumVertices>
@@ -374,7 +374,7 @@
 	return std::make_unique<T>(vertices, color);
 }
 
-std::unique_ptr<modelobjects::BaseObject> Parser::parseFromString(QString line)
+std::unique_ptr<linetypes::Object> Parser::parseFromString(QString line)
 {
 	line = line.simplified();
 	try
@@ -382,7 +382,7 @@
 		const QStringList tokens = line.split(QRegExp{R"(\s+)"});
 		if (tokens.empty() or tokens == QStringList{{""}})
 		{
-			return std::make_unique<modelobjects::Empty>();
+			return std::make_unique<linetypes::Empty>();
 		}
 		bool ok_code;
 		const int code = tokens[0].toInt(&ok_code);
@@ -397,19 +397,19 @@
 		case 1:
 			return parseType1Line(line, tokens);
 		case 2:
-			return parsePolygon<modelobjects::Edge, 2>(line, tokens);
+			return parsePolygon<linetypes::Edge, 2>(line, tokens);
 		case 3:
-			return parsePolygon<modelobjects::Triangle, 3>(line, tokens);
+			return parsePolygon<linetypes::Triangle, 3>(line, tokens);
 		case 4:
-			return parsePolygon<modelobjects::Quadrilateral, 4>(line, tokens);
+			return parsePolygon<linetypes::Quadrilateral, 4>(line, tokens);
 		case 5:
-			return parsePolygon<modelobjects::ConditionalEdge, 4>(line, tokens);
+			return parsePolygon<linetypes::ConditionalEdge, 4>(line, tokens);
 		default:
 			throw BodyParseError{utility::format("bad line type '%1'", code)};
 		}
 	}
 	catch(const BodyParseError& error)
 	{
-		return std::make_unique<modelobjects::ErrorLine>(line, error.message);
+		return std::make_unique<linetypes::ErrorLine>(line, error.message);
 	}
 }

mercurial