CVB++ 14.0
qr.hpp
1#pragma once
2
3#include "_detail/reader_2d_with_quietzone_config_base.hpp"
4
5namespace Cvb
6{
7 CVB_BEGIN_INLINE_NS
8
9 namespace Barcode
10 {
11 using namespace Internal;
12
13
15
18 {
19public:
20
22
27 void SetMaxVersionMiniQr(int maxVersionMiniQR)
28 {
29 if(maxVersionMiniQR < minVersionMiniQR_ ||
30 maxVersionMiniQR > MaxVersionMiniQRHighest_)
31 throw std::runtime_error("MaxVersionMiniQR out of range");
32 maxVersionMiniQR_ = static_cast<short>(maxVersionMiniQR);
33 SetDirty();
34 }
35
37
42 int MaxVersionMiniQr() const
43 {
44 return maxVersionMiniQR_;
45 };
46
48
53 void SetMaxVersionStandardQr(int maxVersionStandardQR)
54 {
55 if(maxVersionStandardQR < minVersionStandardQR_ ||
56 maxVersionStandardQR > MaxVersionStandardQRHighest_)
57 throw std::runtime_error("MaxVersionStandardQR out of range");
58 maxVersionStandardQR_ = static_cast<short>(maxVersionStandardQR);
59 SetDirty();
60 }
61
63
69 {
70 return maxVersionStandardQR_;
71 };
72
73
75
80 void SetMinVersionMiniQr(int minVersionMiniQR)
81 {
82 if(minVersionMiniQR > maxVersionMiniQR_ ||
83 minVersionMiniQR < MinVersionMiniQRLowest_)
84 throw std::runtime_error("MinVersionMiniQR out of range");
85 minVersionMiniQR_ = static_cast<short>(minVersionMiniQR);
86 SetDirty();
87 }
88
90
95 int MinVersionMiniQr() const
96 {
97 return minVersionMiniQR_;
98 };
99
100
102
107 void SetMinVersionStandardQr(int minVersionStandardQR)
108 {
109 if(minVersionStandardQR > maxVersionStandardQR_ ||
110 minVersionStandardQR < MinVersionStandardQRLowest_)
111 throw std::runtime_error("MinVersionStandardQR out of range");
112 minVersionStandardQR_ = static_cast<short>(minVersionStandardQR);
113 SetDirty();
114 }
115
117
123 {
124 return minVersionStandardQR_;
125 };
126
127
129
134 void SetSubTypes(QrSubType subTypes)
135 {
136 if (subTypes_ != subTypes)
137 SetDirty();
138 subTypes_ = subTypes;
139 };
140
142
148 {
149 return subTypes_;
150 };
151
152 protected:
153 short maxVersionMiniQR_;
154 short maxVersionStandardQR_;
155 short minVersionMiniQR_;
156 short minVersionStandardQR_;
157 QrSubType subTypes_;
158
160 const short MinVersionMiniQRLowest_ = 1;
161
164
167
170
171 public:
172 virtual Symbology Type() const override { return Symbology::Qr; };
173
175
181 static std::unique_ptr<Qr> FromHandle(const HandleGuard<ReaderConfig>& guard, bool& isActiveOut)
182 {
183 auto pConfig = std::unique_ptr<Qr>(new Qr());
184 isActiveOut = pConfig->ReadFromHandle(guard);
185 return pConfig;
186 }
187
188 protected:
189 virtual bool ReadFromHandle_(const HandleGuard<ReaderConfig>& guard) override
190 {
191 CExports::cvbbool_t active;
192 SmartBool activeMiniQr;
193 SmartBool activeStandardQr;
194 CVB_CALL_CAPI(CvcBcGetQRCode(
195 reinterpret_cast<std::intptr_t>(guard.Handle()),
196 &active,
197 mirrored_.Ptr(),
198 inverse_.Ptr(),
199 checkQuietzone_.Ptr(),
200 activeMiniQr.Ptr(),
201 &minVersionMiniQR_,
202 &maxVersionMiniQR_,
203 activeStandardQr.Ptr(),
204 &minVersionStandardQR_,
205 &maxVersionStandardQR_
206 ));
207 // convert to QrSubType
208 if (!activeMiniQr && !activeStandardQr)
209 throw std::runtime_error("MiniQR and StandardQR both deactivated");
210 else if (activeMiniQr && activeStandardQr)
211 subTypes_ = QrSubType::Both;
212 else if (activeMiniQr)
213 subTypes_ = QrSubType::Mini;
214 else if (activeStandardQr)
215 subTypes_ = QrSubType::Standard;
216
217 return SmartBool(active);
218 }
219
220 virtual void WriteToHandle_(bool active, HandleGuard<ReaderConfig>& guard) override
221 {
222 SmartBool activeMiniQr;
223 SmartBool activeStandardQr;
224 Internal::DoResCall([&]()
225 {
226 return CVB_CALL_CAPI(CvcBcSetQRCode(reinterpret_cast<std::intptr_t>(guard.Handle()),
227 SmartBool(active),
228 mirrored_,
229 inverse_,
230 checkQuietzone_,
231 SmartBool(subTypes_ != QrSubType::Standard),
232 minVersionMiniQR_,
233 maxVersionMiniQR_,
234 SmartBool(subTypes_ != QrSubType::Mini),
235 minVersionStandardQR_,
236 maxVersionStandardQR_));
237 });
238 }
239 protected:
240 Qr()
241 : Reader2DWithQuietzoneConfigBase()
242 {
243 }
244
245 };
246
247 using QrPtr = std::shared_ptr<Qr>;
248 }
249
250 CVB_END_INLINE_NS
251}
Configuration to access parameters of Reader2DWithQuietzoneConfigBase.
Definition: reader_2d_with_quietzone_config_base.hpp:19
Configuration to access parameters of Qr.
Definition: qr.hpp:18
void SetMinVersionMiniQr(int minVersionMiniQR)
Limiting values for Mini-QR-code ranging from 1 to 4. The default value is 1 (min) to 4 (max) to deco...
Definition: qr.hpp:80
const short MinVersionMiniQRLowest_
Lowest possible version for mini QR reading.
Definition: qr.hpp:160
const short MaxVersionMiniQRHighest_
Highest possible version for mini QR reading.
Definition: qr.hpp:163
static std::unique_ptr< Qr > FromHandle(const HandleGuard< ReaderConfig > &guard, bool &isActiveOut)
Create object from handle.
Definition: qr.hpp:181
QrSubType SubTypes() const
Returns which varieties of QR codes to read.
Definition: qr.hpp:147
int MinVersionStandardQr() const
Limiting values for standard-QR-code ranging from 1 to 40. The default value is 1 (min) to 40 (max) t...
Definition: qr.hpp:122
void SetMaxVersionMiniQr(int maxVersionMiniQR)
Limiting values for Mini-QR-code ranging from 1 to 4. The default value is 1 (min) to 4 (max) to deco...
Definition: qr.hpp:27
int MinVersionMiniQr() const
Limiting values for Mini-QR-code ranging from 1 to 4. The default value is 1 (min) to 4 (max) to deco...
Definition: qr.hpp:95
int MaxVersionStandardQr() const
Limiting values for standard-QR-code ranging from 1 to 40. The default value is 1 (min) to 40 (max) t...
Definition: qr.hpp:68
const short MaxVersionStandardQRHighest_
Highest possible version for mini QR reading.
Definition: qr.hpp:169
void SetSubTypes(QrSubType subTypes)
Determine which varieties of QR codes to read.
Definition: qr.hpp:134
int MaxVersionMiniQr() const
Limiting values for Mini-QR-code ranging from 1 to 4. The default value is 1 (min) to 4 (max) to deco...
Definition: qr.hpp:42
void SetMinVersionStandardQr(int minVersionStandardQR)
Limiting values for standard-QR-code ranging from 1 to 40. The default value is 1 (min) to 40 (max) t...
Definition: qr.hpp:107
const short MinVersionStandardQRLowest_
Lowest possible version for mini QR reading.
Definition: qr.hpp:166
void SetMaxVersionStandardQr(int maxVersionStandardQR)
Limiting values for standard-QR-code ranging from 1 to 40. The default value is 1 (min) to 40 (max) t...
Definition: qr.hpp:53
QrSubType
QR code types to read.
Definition: barcode.hpp:396
@ Both
Both types of QR codes.
@ Mini
Mini QR codes only.
@ Standard
Standard QR codes only.
Symbology
The symbologies supported by Barcode.
Definition: barcode.hpp:97
@ Qr
QR Matrix Code.
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24