Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
StringUtils.h
1/*
2 * StringUtils.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2021-2023 - adazem009
6 *
7 * Open-Typer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Open-Typer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef STRINGUTILS_H
22#define STRINGUTILS_H
23
24#include <QObject>
25#include <QString>
26#include <QVector>
27#include <QVariant>
28#include "../IStringUtils.h"
29
31class Q_DECL_EXPORT StringUtils : public QObject, public IStringUtils
32{
33 Q_OBJECT
34 public:
35 static std::shared_ptr<StringUtils> instance();
36 Q_INVOKABLE int wordCount(QString str) override;
37 Q_INVOKABLE int charCount(QString str, QChar ch) override;
38 Q_INVOKABLE QString word(QString str, int id) override;
39 Q_INVOKABLE QString wordAt(QString str, int index) override;
40 Q_INVOKABLE QString repeatString(QString string, int n) override;
41 Q_INVOKABLE QList<QVariant> longestCommonSubsequence(QList<QVariant> source, QList<QVariant> target) override;
42 Q_INVOKABLE QString longestCommonSubsequence(QString source, QString target) override;
43 Q_INVOKABLE QString normalizeString(QString str) override;
44
45 private:
46 static std::shared_ptr<StringUtils> m_instance;
47 static int lcsLen(QList<QVariant> source, QList<QVariant> target);
48 static int lcsLen(QList<QVariant> source, QList<QVariant> target, QMap<int, QMap<int, int>> *lcsTable);
49};
50
51#endif // STRINGUTILS_H
Definition IStringUtils.h:28
The StringUtils class contains functions related to strings.
Definition StringUtils.h:32