File indexing completed on 2025-01-05 05:09:58
0001 /*************************************************************************** 0002 * Copyright (C) 2014 by Renaud Guezennec * 0003 * https://rolisteam.org/contact * 0004 * * 0005 * This file is part of DiceParser * 0006 * * 0007 * DiceParser is free software; you can redistribute it and/or modify * 0008 * it under the terms of the GNU General Public License as published by * 0009 * the Free Software Foundation; either version 2 of the License, or * 0010 * (at your option) any later version. * 0011 * * 0012 * This program is distributed in the hope that it will be useful, * 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0015 * GNU General Public License for more details. * 0016 * * 0017 * You should have received a copy of the GNU General Public License * 0018 * along with this program; if not, write to the * 0019 * Free Software Foundation, Inc., * 0020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0021 ***************************************************************************/ 0022 #ifndef DICEALIAS_H 0023 #define DICEALIAS_H 0024 0025 #include <QString> 0026 0027 #include <diceparser/diceparser_global.h> 0028 /** 0029 * @brief The DiceAlias class is dedicated to store aliases, alias is mainly two QString. The Alias and its replacement. 0030 * The replacement can be a simple QString or a RegExp. 0031 */ 0032 class DICEPARSER_EXPORT DiceAlias 0033 { 0034 public: 0035 enum RESOLUTION_TYPE 0036 { 0037 REPLACE, 0038 REGEXP 0039 }; 0040 /** 0041 * @brief DiceAlias 0042 * @param cmd 0043 * @param key 0044 * @param isReplace 0045 */ 0046 DiceAlias(QString pattern, QString command, QString comment= QString{}, bool isReplace= true, bool isEnable= true); 0047 DiceAlias(const DiceAlias& alias); 0048 /** 0049 * @brief ~DiceAlias 0050 */ 0051 virtual ~DiceAlias(); 0052 /** 0053 * @brief resolved 0054 * @param str 0055 * @return 0056 */ 0057 bool resolved(QString& str); 0058 /** 0059 * @brief setCommand 0060 * @param key 0061 */ 0062 void setPattern(const QString& pattern); 0063 /** 0064 * @brief setValue 0065 * @param value 0066 */ 0067 void setCommand(QString command); 0068 /** 0069 * @brief setType 0070 */ 0071 void setType(RESOLUTION_TYPE); 0072 0073 /** 0074 * @brief getCommand 0075 * @return 0076 */ 0077 QString pattern() const; 0078 /** 0079 * @brief getValue 0080 * @return 0081 */ 0082 QString command() const; 0083 /** 0084 * @brief isReplace 0085 * @return 0086 */ 0087 bool isReplace() const; 0088 /** 0089 * @brief setReplace 0090 */ 0091 void setReplace(bool); 0092 0093 /** 0094 * @brief isEnable 0095 * @return 0096 */ 0097 bool isEnable() const; 0098 /** 0099 * @brief setEnable 0100 * @param b 0101 */ 0102 void setEnable(bool b); 0103 /** 0104 * @brief getComment 0105 * @return 0106 */ 0107 QString comment() const; 0108 /** 0109 * @brief setComment 0110 * @param comment 0111 */ 0112 void setComment(const QString& comment); 0113 0114 private: 0115 QString m_pattern; 0116 QString m_command; 0117 QString m_comment; 0118 RESOLUTION_TYPE m_type; 0119 bool m_isEnable; 0120 }; 0121 0122 #endif // DICEALIAS_H