File indexing completed on 2024-06-16 03:42:35

0001 /*
0002     File                 : Integer2BigIntFilter.h
0003     Project              : AbstractColumn
0004     Description          : conversion filter int -> bigint
0005     --------------------------------------------------------------------
0006     SPDX-FileCopyrightText: 2020 Stefan Gerlach <stefan.gerlach@uni.kn>
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #ifndef INTEGER2BIGINT_FILTER_H
0011 #define INTEGER2BIGINT_FILTER_H
0012 
0013 #include "../AbstractSimpleFilter.h"
0014 #include <QLocale>
0015 
0016 //! conversion filter integer -> bigint
0017 class Integer2BigIntFilter : public AbstractSimpleFilter {
0018     Q_OBJECT
0019 
0020 public:
0021     Integer2BigIntFilter() {
0022     }
0023 
0024     qint64 bigIntAt(int row) const override {
0025         if (!m_inputs.value(0))
0026             return 0;
0027 
0028         int value = m_inputs.value(0)->integerAt(row);
0029         qint64 result = (qint64)value;
0030         // DEBUG("Integer2BigInt::integerAt() " << value << " -> " << result);
0031 
0032         return result;
0033     }
0034 
0035     //! Return the data type of the column
0036     AbstractColumn::ColumnMode columnMode() const override {
0037         return AbstractColumn::ColumnMode::BigInt;
0038     }
0039 
0040 protected:
0041     //! Using typed ports: only integer inputs are accepted
0042     bool inputAcceptable(int, const AbstractColumn* source) override {
0043         DEBUG("inputAcceptable(): source type = " << ENUM_TO_STRING(AbstractColumn, ColumnMode, source->columnMode()));
0044         return source->columnMode() == AbstractColumn::ColumnMode::Integer;
0045     }
0046 };
0047 
0048 #endif // ifndef INTEGER2BIGINT_FILTER_H