File indexing completed on 2024-05-19 05:05:20
0001 /*************************************************************************** 0002 * SPDX-License-Identifier: GPL-2.0-or-later 0003 * * 0004 * SPDX-FileCopyrightText: 2004-2018 Thomas Fischer <fischer@unix-ag.uni-kl.de> 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (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 <https://www.gnu.org/licenses/>. * 0018 ***************************************************************************/ 0019 0020 #include "macro.h" 0021 0022 #include <typeinfo> 0023 0024 #include <QStringList> 0025 0026 #include "logging_data.h" 0027 0028 /** 0029 * Private class to store internal variables that should not be visible 0030 * in the interface as defined in the header file. 0031 */ 0032 class Macro::MacroPrivate 0033 { 0034 public: 0035 QString key; 0036 Value value; 0037 }; 0038 0039 Macro::Macro(const QString &key, const Value &value) 0040 : Element(), d(new Macro::MacroPrivate) 0041 { 0042 d->key = key; 0043 d->value = value; 0044 } 0045 0046 Macro::Macro(const Macro &other) 0047 : Element(), d(new Macro::MacroPrivate) 0048 { 0049 d->key = other.d->key; 0050 d->value = other.d->value; 0051 } 0052 0053 Macro::~Macro() 0054 { 0055 delete d; 0056 } 0057 0058 bool Macro::operator==(const Macro &other) const 0059 { 0060 return d->key == other.d->key && d->value == other.d->value; 0061 } 0062 0063 bool Macro::operator!=(const Macro &other) const 0064 { 0065 return !operator ==(other); 0066 } 0067 0068 Macro &Macro::operator= (const Macro &other) 0069 { 0070 if (this != &other) { 0071 d->key = other.key(); 0072 d->value = other.value(); 0073 } 0074 return *this; 0075 } 0076 0077 void Macro::setKey(const QString &key) 0078 { 0079 d->key = key; 0080 } 0081 0082 QString Macro::key() const 0083 { 0084 return d->key; 0085 } 0086 0087 Value &Macro::value() 0088 { 0089 return d->value; 0090 } 0091 0092 const Value &Macro::value() const 0093 { 0094 return d->value; 0095 } 0096 0097 void Macro::setValue(const Value &value) 0098 { 0099 d->value = value; 0100 } 0101 0102 bool Macro::isMacro(const Element &other) { 0103 return typeid(other) == typeid(Macro); 0104 } 0105 0106 QDebug operator<<(QDebug dbg, const Macro ¯o) { 0107 dbg.nospace() << "Macro " << macro.key() << " = " << macro.value(); 0108 return dbg; 0109 }