File indexing completed on 2024-05-12 04:01:31

0001 /*
0002     SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 #include "barcodeutil_p.h"
0007 
0008 #include <QVariant>
0009 
0010 using namespace Prison;
0011 
0012 QList<bool> BarCodeUtil::barSequence(const char *str)
0013 {
0014     Q_ASSERT(strlen(str) == 9); // this is a internal helper tool, only called with fixed strings in here, all 9 chars long
0015     QList<bool> ret;
0016     for (int i = 0; i < 9; i++) {
0017         ret.append(str[i] == '1');
0018         Q_ASSERT(str[i] == '0' || str[i] == '1');
0019     }
0020     return ret;
0021 }
0022 
0023 QByteArray BarCodeUtil::asLatin1ByteArray(const QVariant &data)
0024 {
0025     if (data.typeId() == QMetaType::QString) {
0026         return data.toString().toLatin1();
0027     }
0028     return data.toByteArray();
0029 }