Prison

barcodeutil.cpp
1/*
2 SPDX-FileCopyrightText: 2020 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6#include "barcodeutil_p.h"
7
8#include <QVariant>
9
10using namespace Prison;
11
12QList<bool> BarCodeUtil::barSequence(const char *str)
13{
14 Q_ASSERT(strlen(str) == 9); // this is a internal helper tool, only called with fixed strings in here, all 9 chars long
15 QList<bool> ret;
16 for (int i = 0; i < 9; i++) {
17 ret.append(str[i] == '1');
18 Q_ASSERT(str[i] == '0' || str[i] == '1');
19 }
20 return ret;
21}
22
23QByteArray BarCodeUtil::asLatin1ByteArray(const QVariant &data)
24{
25 if (data.typeId() == QMetaType::QString) {
26 return data.toString().toLatin1();
27 }
28 return data.toByteArray();
29}
Provides classes and methods for generating barcodes.
Definition barcode.h:24
void append(QList< T > &&value)
QByteArray toLatin1() const const
QByteArray toByteArray() const const
QString toString() const const
int typeId() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:12:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.