GCC Code Coverage Report


Directory: src/gate/
File: src/gate/tech/cxx_barcodes.cpp
Date: 2026-03-20 22:56:14
Exec Total Coverage
Lines: 37 46 80.4%
Functions: 13 15 86.7%
Branches: 7 19 36.8%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2026, Stefan Meislinger |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28
29 #include "gate/tech/barcodes.hpp"
30 #include "gate/wrappers.hpp"
31
32 namespace gate
33 {
34 namespace tech
35 {
36
37 typedef gate::graph::RasterImage RasterImage;
38
39 uint32_t const IBarcodeProcessor::ScanFlag_Default = GATE_TECH_BARCODE_SCANNER_FLAG_DEFAULT;
40 uint32_t const IBarcodeProcessor::ScanFlag_Quick = GATE_TECH_BARCODE_SCANNER_FLAG_QUICK;
41 uint32_t const IBarcodeProcessor::ScanFlag_Intensive = GATE_TECH_BARCODE_SCANNER_FLAG_INTENSIVE;
42
43 6 IBarcodeProcessor::~IBarcodeProcessor() noexcept
44 {
45 6 }
46
47
48 2 static Optional<String> generic_barcode_scan(gate_tech_barcode_scanner_t scanner,
49 RasterImage const& image,
50 uint32_t flags, char const* source_func)
51 {
52 2 Optional<String> ret;
53 2 gate_string_t output = GATE_STRING_INIT_EMPTY;
54
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 result_t result = scanner(image.c_impl(), flags, &output);
55
1/3
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
2 switch (result)
56 {
57 2 case GATE_RESULT_OK:
58 {
59 4 String str = String::createFrom(output);
60
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ret.create(str);
61 2 break;
62 }
63 case GATE_RESULT_NOMATCH:
64 {
65 // just return empty optional object
66 break;
67 }
68 default:
69 {
70 raiseException(result, "Failed to scan barcode", source_func);
71 break;
72 }
73 }
74 4 return ret;
75 }
76
77 2 static RasterImage generic_barcode_print(gate_tech_barcode_printer_t printer,
78 String const& data,
79 uint32_t flags, char const* source_func)
80 {
81 2 RasterImage image;
82
2/4
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
2 result_t result = printer(data.c_impl(), flags, image.c_impl());
83
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 GATEXX_CHECK_EXCEPTION(result);
84 2 return image;
85 }
86
87
88
89
90 1 DtmxBarcodeProcessor::DtmxBarcodeProcessor()
91 //: impl(NULL)
92 {
93 1 }
94
95 2 DtmxBarcodeProcessor::~DtmxBarcodeProcessor() noexcept
96 {
97 2 }
98
99 1 Optional<String> DtmxBarcodeProcessor::scan(RasterImage const& image, uint32_t flags)
100 {
101 1 return generic_barcode_scan(&gate_tech_dmtx_scan, image, flags, "DtmxBarcodeProcessor::scan");
102 }
103 1 RasterImage DtmxBarcodeProcessor::print(String const& data)
104 {
105 1 return generic_barcode_print(&gate_tech_dmtx_print, data, 0, "DtmxBarcodeProcessor::print");
106 }
107
108
109
110
111 1 QRCodeBarcodeProcessor::QRCodeBarcodeProcessor()
112 //: impl(NULL)
113 {
114 1 }
115 2 QRCodeBarcodeProcessor::~QRCodeBarcodeProcessor() noexcept
116 {
117 2 }
118
119 Optional<String> QRCodeBarcodeProcessor::scan(RasterImage const& image, uint32_t flags)
120 {
121 return generic_barcode_scan(&gate_tech_qrcode_scan, image, flags, "QRCodeBarcodeProcessor::scan");
122 }
123 RasterImage QRCodeBarcodeProcessor::print(String const& data)
124 {
125 return generic_barcode_print(&gate_tech_qrcode_print, data, 0, "QRCodeBarcodeProcessor::print");
126 }
127
128
129
130
131 1 EanBarcodeProcessor::EanBarcodeProcessor()
132 //: impl(NULL)
133 {
134 1 }
135 2 EanBarcodeProcessor::~EanBarcodeProcessor() noexcept
136 {
137 2 }
138
139 1 Optional<String> EanBarcodeProcessor::scan(RasterImage const& image, uint32_t flags)
140 {
141 1 return generic_barcode_scan(&gate_tech_eanbarcode_scan, image, flags, "EanBarcodeProcessor::scan");
142 }
143 1 RasterImage EanBarcodeProcessor::print(String const& data)
144 {
145 1 return generic_barcode_print(&gate_tech_eanbarcode_print, data, 0, "EanBarcodeProcessor::print");
146 }
147
148 } // end of namespace tech
149 } // end of namespace gate
150