KTextAddons

languagetoollistoflanguagesparser.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "languagetoollistoflanguagesparser.h"
8
9#include <QJsonArray>
10#include <QJsonObject>
11using namespace TextGrammarCheck;
12LanguageToolListOfLanguagesParser::LanguageToolListOfLanguagesParser() = default;
13
14LanguageToolListOfLanguagesParser::~LanguageToolListOfLanguagesParser() = default;
15
16QVector<LanguageInfo> LanguageToolListOfLanguagesParser::parseResult(const QJsonArray &array) const
17{
18 QVector<LanguageInfo> lstLanguageInfo;
19 for (const QJsonValue &current : array) {
20 // qDebug() << " current " << current;
21 if (current.type() == QJsonValue::Object) {
22 const QJsonObject languageToolObject = current.toObject();
23 LanguageInfo lang;
24 lang.parse(languageToolObject);
25 if (lang.isValid()) {
26 lstLanguageInfo.append(std::move(lang));
27 }
28 }
29 }
30 lstLanguageInfo.erase(std::unique(lstLanguageInfo.begin(), lstLanguageInfo.end()), lstLanguageInfo.end());
31 return lstLanguageInfo;
32}
void append(QList< T > &&value)
iterator begin()
iterator end()
iterator erase(const_iterator begin, const_iterator end)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:02:03 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.