File indexing completed on 2024-04-21 04:34:33
0001 /* 0002 * This file is part of KDevelop Krazy2 Plugin. 0003 * 0004 * Copyright 2012 Daniel Calviño Sánchez <danxuliu@gmail.com> 0005 * 0006 * This program is free software; you can redistribute it and/or 0007 * modify it under the terms of the GNU General Public License 0008 * as published by the Free Software Foundation; either version 2 0009 * of the License, or (at your option) any later version. 0010 * 0011 * This program is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0014 * GNU General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU General Public License 0017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0018 */ 0019 0020 #include "checker.h" 0021 #include <QStringList> 0022 0023 //public: 0024 0025 Checker::Checker(): 0026 m_extra(false) { 0027 } 0028 0029 QString Checker::name() const { 0030 return m_name; 0031 } 0032 0033 void Checker::setName(const QString& name) { 0034 m_name = name; 0035 } 0036 0037 QString Checker::description() const { 0038 return m_description; 0039 } 0040 0041 void Checker::setDescription(const QString& description) { 0042 m_description = description; 0043 } 0044 0045 QString Checker::explanation() const { 0046 return m_explanation; 0047 } 0048 0049 void Checker::setExplanation(const QString& explanation) { 0050 m_explanation = explanation; 0051 } 0052 0053 QString Checker::fileType() const { 0054 return m_fileType; 0055 } 0056 0057 void Checker::setFileType(const QString& fileType) { 0058 m_fileType = fileType; 0059 } 0060 0061 bool Checker::isExtra() const { 0062 return m_extra; 0063 } 0064 0065 void Checker::setExtra(bool extra) { 0066 m_extra = extra; 0067 } 0068 0069 0070 const Checker* findChecker(const QList<const Checker*> &list, const QString &s) 0071 { 0072 // s comes in as "C++;endswithnewline" 0073 // break that up into two strings 0074 // sl[0] "C++" 0075 // sl[1] "endswithnewline" 0076 QStringList sl = s.split(';'); 0077 if(sl.size() != 2) 0078 return nullptr; 0079 0080 // Find this checker tool, if exists 0081 foreach (const Checker *checker, list) { 0082 if ((checker->fileType() == sl[0]) && (checker->name() == sl[1])) { 0083 return checker; 0084 } 0085 } 0086 0087 return nullptr; 0088 } 0089