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-2019 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 "preamble.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 Preamble::PreamblePrivate
0033 {
0034 public:
0035     Value value;
0036 };
0037 
0038 Preamble::Preamble(const Value &value)
0039         : Element(), d(new Preamble::PreamblePrivate)
0040 {
0041     d->value = value;
0042 }
0043 
0044 Preamble::Preamble(const Preamble &other)
0045         : Element(), d(new Preamble::PreamblePrivate)
0046 {
0047     operator=(other);
0048 }
0049 
0050 Preamble::~Preamble()
0051 {
0052     delete d;
0053 }
0054 
0055 bool Preamble::operator==(const Preamble &other) const
0056 {
0057     return d->value == other.d->value;
0058 }
0059 
0060 bool Preamble::operator!=(const Preamble &other) const
0061 {
0062     return !operator ==(other);
0063 }
0064 
0065 Preamble &Preamble::operator= (const Preamble &other)
0066 {
0067     if (this != &other)
0068         d->value = other.d->value;
0069     return *this;
0070 }
0071 
0072 Value &Preamble::value()
0073 {
0074     return d->value;
0075 }
0076 
0077 const Value &Preamble::value() const
0078 {
0079     return d->value;
0080 }
0081 
0082 void Preamble::setValue(const Value &value)
0083 {
0084     d->value = value;
0085 
0086 }
0087 
0088 bool Preamble::isPreamble(const Element &other) {
0089     return typeid(other) == typeid(Preamble);
0090 }
0091 
0092 QDebug operator<<(QDebug dbg, const Preamble &preamble) {
0093     dbg.nospace() << "Preamble: " << preamble.value();
0094     return dbg;
0095 }