diff -r 1de2b8d64e9f -r 98906a94732f src/parser.cpp --- a/src/parser.cpp Tue Jan 28 23:34:49 2020 +0200 +++ b/src/parser.cpp Thu Jan 30 19:20:11 2020 +0200 @@ -255,7 +255,7 @@ invertNext = true; continue; } - std::unique_ptr object = parseFromString(line); + std::unique_ptr object = parseFromString(line); auto id = editor.append(std::move(object)); if (invertNext) { @@ -265,10 +265,10 @@ } } -static Color colorFromString(const QString& colorString) +static ldraw::Color colorFromString(const QString& colorString) { bool colorSucceeded; - const Color color = {colorString.toInt(&colorSucceeded)}; + const ldraw::Color color = {colorString.toInt(&colorSucceeded)}; if (colorSucceeded) { return color; @@ -329,22 +329,22 @@ return result; } -static std::unique_ptr parseType0Line( +static std::unique_ptr parseType0Line( const QString& line, const QStringList& tokens) { Q_UNUSED(tokens) if (line.startsWith("0 //")) { - return std::make_unique(line.mid(std::strlen("0 //")).simplified()); + return std::make_unique(line.mid(std::strlen("0 //")).simplified()); } else { - return std::make_unique(line.mid(1).simplified()); + return std::make_unique(line.mid(1).simplified()); } } -static std::unique_ptr parseType1Line( +static std::unique_ptr parseType1Line( const QString& line, const QStringList& tokens) { @@ -357,10 +357,10 @@ { throw BodyParseError{"wrong amount of tokens in a type-1 line"}; } - const Color color = colorFromString(tokens[colorPosition]); + const ldraw::Color color = colorFromString(tokens[colorPosition]); const glm::mat4 transform = matrixFromStrings(tokens, transformPosition, positionPosition); const QString& name = tokens[namePosition]; - return std::make_unique(transform, name, color); + return std::make_unique(transform, name, color); } template @@ -375,7 +375,7 @@ { throw BodyParseError{"wrong amount of tokens"}; } - const Color color = colorFromString(tokens[colorPosition]); + const ldraw::Color color = colorFromString(tokens[colorPosition]); QVector vertices; vertices.reserve(NumVertices); for (int i = 0; i < NumVertices; i += 1) @@ -385,7 +385,7 @@ return std::make_unique(vertices, color); } -std::unique_ptr Parser::parseFromString(QString line) +std::unique_ptr Parser::parseFromString(QString line) { line = line.simplified(); try @@ -393,7 +393,7 @@ const QStringList tokens = line.split(QRegExp{R"(\s+)"}); if (tokens.empty() or tokens == QStringList{{""}}) { - return std::make_unique(); + return std::make_unique(); } bool ok_code; const int code = tokens[0].toInt(&ok_code); @@ -408,19 +408,19 @@ case 1: return parseType1Line(line, tokens); case 2: - return parsePolygon(line, tokens); + return parsePolygon(line, tokens); case 3: - return parsePolygon(line, tokens); + return parsePolygon(line, tokens); case 4: - return parsePolygon(line, tokens); + return parsePolygon(line, tokens); case 5: - return parsePolygon(line, tokens); + return parsePolygon(line, tokens); default: throw BodyParseError{utility::format("bad line type '%1'", code)}; } } catch(const BodyParseError& error) { - return std::make_unique(line, error.message); + return std::make_unique(line, error.message); } }