File indexing completed on 2024-04-14 04:31:22
0001 /* This file is part of KDevelop 0002 0003 Copyright 2016 Anton Anikin <anton.anikin@htower.ru> 0004 0005 This program is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU General Public 0007 License as published by the Free Software Foundation; either 0008 version 2 of the License, or (at your option) any later version. 0009 0010 This program is distributed in the hope that it will be useful, 0011 but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 General Public License for more details. 0014 0015 You should have received a copy of the GNU General Public License 0016 along with this program; see the file COPYING. If not, write to 0017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "rules.h" 0022 0023 #include <QHash> 0024 0025 namespace verapp 0026 { 0027 0028 namespace rules 0029 { 0030 static QString names[Type::COUNT]; 0031 static QString titles[Type::COUNT]; 0032 static QString explanations[Type::COUNT]; 0033 0034 static QHash<QString, Type> types; 0035 0036 void initDb(QString* titles, QString* explanations); 0037 0038 void init() 0039 { 0040 names[F001] = QStringLiteral("F001"); 0041 names[F002] = QStringLiteral("F002"); 0042 0043 names[L001] = QStringLiteral("L001"); 0044 names[L002] = QStringLiteral("L002"); 0045 names[L003] = QStringLiteral("L003"); 0046 names[L004] = QStringLiteral("L004"); 0047 names[L005] = QStringLiteral("L005"); 0048 names[L006] = QStringLiteral("L006"); 0049 0050 names[T001] = QStringLiteral("T001"); 0051 names[T002] = QStringLiteral("T002"); 0052 names[T003] = QStringLiteral("T003"); 0053 names[T004] = QStringLiteral("T004"); 0054 names[T005] = QStringLiteral("T005"); 0055 names[T006] = QStringLiteral("T006"); 0056 names[T007] = QStringLiteral("T007"); 0057 names[T008] = QStringLiteral("T008"); 0058 names[T009] = QStringLiteral("T009"); 0059 names[T010] = QStringLiteral("T010"); 0060 names[T011] = QStringLiteral("T011"); 0061 names[T012] = QStringLiteral("T012"); 0062 names[T013] = QStringLiteral("T013"); 0063 names[T014] = QStringLiteral("T014"); 0064 names[T015] = QStringLiteral("T015"); 0065 names[T016] = QStringLiteral("T016"); 0066 names[T017] = QStringLiteral("T017"); 0067 names[T018] = QStringLiteral("T018"); 0068 names[T019] = QStringLiteral("T019"); 0069 0070 for (int intType = FIRST; intType <= LAST; ++intType) { 0071 Type ruleType = static_cast<Type>(intType); 0072 0073 types[names[ruleType]] = ruleType; 0074 } 0075 0076 initDb(titles, explanations); 0077 } 0078 0079 Type type(const QString& name) 0080 { 0081 return types[name]; 0082 } 0083 0084 QString name(Type type) 0085 { 0086 return names[type]; 0087 } 0088 0089 QString title(Type type) 0090 { 0091 return titles[type]; 0092 } 0093 0094 QString title(const QString& name) 0095 { 0096 return titles[type(name)]; 0097 } 0098 0099 QString explanation(Type type) 0100 { 0101 return explanation(name(type)); 0102 } 0103 0104 QString explanation(const QString& name) 0105 { 0106 return explanations[type(name)]; 0107 } 0108 } 0109 0110 }