Prison

format.cpp
1/*
2 SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: MIT
4*/
5
6#include "format_p.h"
7
8using namespace Prison;
9
10struct format_map_t {
11 ZXing::BarcodeFormat zxFormat;
13};
14
15static constexpr const format_map_t format_map[] = {
16 {ZXing::BarcodeFormat::None, Format::NoFormat},
17 {ZXing::BarcodeFormat::Aztec, Format::Aztec},
18 {ZXing::BarcodeFormat::Codabar, Format::Codabar},
19 {ZXing::BarcodeFormat::Code39, Format::Code39},
20 {ZXing::BarcodeFormat::Code93, Format::Code93},
21 {ZXing::BarcodeFormat::Code128, Format::Code128},
22 {ZXing::BarcodeFormat::DataBar, Format::DataBar},
23 {ZXing::BarcodeFormat::DataBarExpanded, Format::DataBarExpanded},
24 {ZXing::BarcodeFormat::DataMatrix, Format::DataMatrix},
25 {ZXing::BarcodeFormat::EAN8, Format::EAN8},
26 {ZXing::BarcodeFormat::EAN13, Format::EAN13},
27 {ZXing::BarcodeFormat::ITF, Format::ITF},
28 {ZXing::BarcodeFormat::MaxiCode, Format::MaxiCode},
29 {ZXing::BarcodeFormat::PDF417, Format::PDF417},
30 {ZXing::BarcodeFormat::QRCode, Format::QRCode},
31 {ZXing::BarcodeFormat::UPCA, Format::UPCA},
32 {ZXing::BarcodeFormat::UPCE, Format::UPCE},
33};
34
35ZXing::BarcodeFormats Format::toZXing(Format::BarcodeFormats formats)
36{
37 ZXing::BarcodeFormats f;
38 for (auto m : format_map) {
39 if (m.format & formats) {
40 f |= m.zxFormat;
41 }
42 }
43 return f;
44}
45
46Format::BarcodeFormat Format::toFormat(ZXing::BarcodeFormat format)
47{
48 const auto it = std::find_if(std::begin(format_map), std::end(format_map), [format](auto m) {
49 return m.zxFormat == format;
50 });
51
52 return it != std::end(format_map) ? (*it).format : Format::NoFormat;
53}
54
55#include "moc_format.cpp"
BarcodeFormat
Barcode formats.
Definition format.h:27
Provides classes and methods for generating barcodes.
Definition barcode.h:24
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:55:54 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.