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-2022 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 <QDebug> 0021 0022 #include "element.h" 0023 #include "macro.h" 0024 #include "entry.h" 0025 #include "preamble.h" 0026 #include "comment.h" 0027 0028 Element::Element() 0029 { 0030 static int idCounter = 0; 0031 uniqueId = ++idCounter; 0032 } 0033 0034 bool Element::operator<(const Element &other) const 0035 { 0036 return uniqueId < other.uniqueId; 0037 } 0038 0039 QDebug operator<<(QDebug dbg, const Element &element) { 0040 if (Macro::isMacro(element)) 0041 return operator<<(dbg, *dynamic_cast<const Macro *>(&element)); 0042 else if (Entry::isEntry(element)) 0043 return operator<<(dbg, *dynamic_cast<const Entry *>(&element)); 0044 else if (Preamble::isPreamble(element)) 0045 return operator<<(dbg, *dynamic_cast<const Preamble *>(&element)); 0046 else if (Comment::isComment(element)) 0047 return operator<<(dbg, *dynamic_cast<const Comment *>(&element)); 0048 else { 0049 dbg.nospace() << "Element object of unsupported type"; 0050 return dbg; 0051 } 0052 }