CVB++ 15.0
decl_config_upc_ean_codes.hpp
1#pragma once
2
3#include <unordered_map>
4
5#include "../../_cexports/c_code_reader.h"
6
7namespace Cvb
8{
9 CVB_BEGIN_INLINE_NS
10
11 namespace CodeReader
12 {
13 class Decoder;
14
15 namespace Config
16 {
29
31
46 template <class T>
47 class UpcEanBase : public CompositeCodeBase<T>
48 {
49 protected:
51
52 public:
54
60 virtual T &EnableCCA() override;
61
63
68 virtual T &DisableCCA() override;
69
71
77 virtual T &EnableCCB() override;
78
80
85 virtual T &DisableCCB() override;
86
88
94 virtual T &EnableCCC() override;
95
97
102 virtual T &DisableCCC() override;
103
105
113 virtual T &SetSupplemental(SupplementalCode supplement, bool required = false, bool addSpace = true) = 0;
114
116
119 virtual SupplementalCode Supplemental() const = 0;
120
122
126 virtual T &SetStripCheckDigit(bool value) = 0;
127
129
132 virtual bool StripCheckDigit() const = 0;
133
134 protected:
135 std::pair<bool, bool> MapSupplemental(SupplementalCode supplement) const;
136 SupplementalCode MapSupplemental(bool supplement2, bool supplement5) const;
137 void SetSupplemental(int propertySupplemental2, int propertySupplemental5, int propertyRequired,
138 int propertyAddSpace, SupplementalCode supplement, bool required, bool addSpace);
139 SupplementalCode Supplemental(int propertySupplemental2, int propertySupplemental5) const;
140 };
141
142#pragma region UPCA
144
159 class UpcA final : public UpcEanBase<UpcA>
160 {
161 friend class Cvb::CodeReader::Decoder;
162
163 public:
164 UpcA &SetSupplemental(SupplementalCode supplement, bool required = false, bool addSpace = true) override;
165 SupplementalCode Supplemental() const override;
166
167 UpcA &SetStripCheckDigit(bool value) override;
168 bool StripCheckDigit() const override;
169
171
175 UpcA &SetStripNumberSystemDigit(bool value);
176
178
181 bool StripNumberSystemDigit() const;
182
185
190 UpcA &SetConvertToEAN13(bool value);
191
194
198 bool ConvertedToEAN13() const;
199
200 private:
201 UpcA(Decoder &decoder) noexcept
202 : UpcEanBase<UpcA>(decoder)
203 {
204 }
205 };
206
207 template <>
208 struct Mapper<Symbology::UpcA>
209 {
210 using Type = Config::UpcA;
211 };
212
213 template <>
214 struct ReverseMapper<Config::UpcA>
215 {
216 static constexpr Symbology type = Symbology::UpcA;
217 };
218#pragma endregion
219
220#pragma region UPCE
222
237
238 class UpcE final : public UpcEanBase<UpcE>
239 {
240 friend class Cvb::CodeReader::Decoder;
241
242 public:
243 UpcE &SetSupplemental(SupplementalCode supplement, bool required = false, bool addSpace = true) override;
244 SupplementalCode Supplemental() const override;
245
246 UpcE &SetStripCheckDigit(bool value) override;
247 bool StripCheckDigit() const override;
248
250
254 UpcE &SetStripNumberSystemDigit(bool value);
255
257
260 bool StripNumberSystemDigit() const;
261
263
271 UpcE &SetRejectMisreadCode(bool value);
272
274
278 bool RejectMisreadCode() const;
279
281
284 bool EnabledUpcE1() const;
285
287
291 UpcE &SetEnableUpcE1(bool value);
292
294
297 bool EnabledUpcEExpansion() const;
298
300
304 UpcE &SetEnableUpcEExpansion(bool value);
305
306 private:
307 UpcE(Decoder &decoder) noexcept
308 : UpcEanBase<UpcE>(decoder)
309 {
310 }
311 };
312
313 template <>
314 struct Mapper<Symbology::UpcE>
315 {
316 using Type = Config::UpcE;
317 };
318
319 template <>
320 struct ReverseMapper<Config::UpcE>
321 {
322 static constexpr Symbology type = Symbology::UpcE;
323 };
324#pragma endregion
325
326#pragma region EAN8
328
343 class Ean8 final : public UpcEanBase<Ean8>
344 {
345 friend class Cvb::CodeReader::Decoder;
346
347 public:
348 Ean8 &SetSupplemental(SupplementalCode supplement, bool required = false, bool addSpace = true) override;
349 SupplementalCode Supplemental() const override;
350
351 Ean8 &SetStripCheckDigit(bool value) override;
352 bool StripCheckDigit() const override;
353
355
359 Ean8 &SetConvertToEAN13(bool value);
360
362
366 bool ConvertedToEAN13() const;
367
368 private:
369 Ean8(Decoder &decoder) noexcept
370 : UpcEanBase<Ean8>(decoder)
371 {
372 }
373 };
374
375 template <>
376 struct Mapper<Symbology::Ean8>
377 {
378 using Type = Config::Ean8;
379 };
380
381 template <>
382 struct ReverseMapper<Config::Ean8>
383 {
384 static constexpr Symbology type = Symbology::Ean8;
385 };
386#pragma endregion
387
388#pragma region EAN13
390
405 class Ean13 final : public UpcEanBase<Ean13>
406 {
407 friend class Cvb::CodeReader::Decoder;
408
409 public:
410 Ean13 &SetSupplemental(SupplementalCode supplement, bool required = false, bool addSpace = true) override;
411 SupplementalCode Supplemental() const override;
412
413 Ean13 &SetStripCheckDigit(bool value) override;
414 bool StripCheckDigit() const override;
415
417
421 Ean13 &SetConvertBooklandToISBN(bool value);
422
424
427 bool ConvertedFromBooklandToISBN() const;
428
430
434 Ean13 &SetConvertBooklandToISSN(bool value);
435
437
440 bool ConvertedFromBooklandToISSN() const;
441
442 private:
443 Ean13(Decoder &decoder) noexcept
444 : UpcEanBase<Ean13>(decoder)
445 {
446 }
447 };
448
449 template <>
450 struct Mapper<Symbology::Ean13>
451 {
452 using Type = Config::Ean13;
453 };
454
455 template <>
456 struct ReverseMapper<Config::Ean13>
457 {
458 static constexpr Symbology type = Symbology::Ean13;
459 };
460#pragma endregion
461
462 } // namespace Config
463 } // namespace CodeReader
464
465 CVB_END_INLINE_NS
466} // namespace Cvb
Base configuration class for composite codes.
Definition decl_config_base.hpp:289
Configuration class for EAN-13 barcodes.
Definition decl_config_upc_ean_codes.hpp:406
bool ConvertedFromBooklandToISSN() const
Determines whether conversion from Bookland to ISSN is enabled or disabled.
Definition detail_config_upc_ean_codes.hpp:359
Ean13 & SetStripCheckDigit(bool value) override
Enables or disables the removal of the check digit from read codes.
Definition detail_config_upc_ean_codes.hpp:328
Ean13 & SetConvertBooklandToISBN(bool value)
Enables or disables conversion from Bookland to ISBN.
Definition detail_config_upc_ean_codes.hpp:339
SupplementalCode Supplemental() const override
Retrieves the current configuration of the supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:321
bool ConvertedFromBooklandToISBN() const
Determines whether conversion from Bookland to ISBN is enabled or disabled.
Definition detail_config_upc_ean_codes.hpp:346
bool StripCheckDigit() const override
Determines whether check digit removal is enabled.
Definition detail_config_upc_ean_codes.hpp:334
Ean13 & SetConvertBooklandToISSN(bool value)
Enables or disables conversion from Bookland to ISSN.
Definition detail_config_upc_ean_codes.hpp:352
Ean13 & SetSupplemental(SupplementalCode supplement, bool required=false, bool addSpace=true) override
Configures supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:310
Configuration class for EAN-8 barcodes.
Definition decl_config_upc_ean_codes.hpp:344
Ean8 & SetSupplemental(SupplementalCode supplement, bool required=false, bool addSpace=true) override
Configures supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:267
Ean8 & SetStripCheckDigit(bool value) override
Enables or disables the removal of the check digit from read codes.
Definition detail_config_upc_ean_codes.hpp:285
bool ConvertedToEAN13() const
Determines whether the conversion of EAN-8 codes to EAN-13 format is enabled or disabled.
Definition detail_config_upc_ean_codes.hpp:302
SupplementalCode Supplemental() const override
Retrieves the current configuration of the supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:278
Ean8 & SetConvertToEAN13(bool value)
Enables or disables the conversion of EAN-8 codes to EAN-13 format in the decoded data.
Definition detail_config_upc_ean_codes.hpp:296
bool StripCheckDigit() const override
Determines whether check digit removal is enabled.
Definition detail_config_upc_ean_codes.hpp:291
Configuration class for UPC-A barcodes.
Definition decl_config_upc_ean_codes.hpp:160
bool StripNumberSystemDigit() const
Determines whether UPC-A Number System digit removal is enabled.
Definition detail_config_upc_ean_codes.hpp:165
UpcA & SetConvertToEAN13(bool value)
Enables or disables the conversion of 12-digit UPC-A codes to 13-digit EAN-13 format in the decoded d...
Definition detail_config_upc_ean_codes.hpp:171
UpcA & SetStripNumberSystemDigit(bool value)
Enables or disables the removal of the UPC-A Number System digit from read codes.
Definition detail_config_upc_ean_codes.hpp:159
bool ConvertedToEAN13() const
Determines whether the conversion of 12-digit UPC-A codes to 13-digit EAN-13 format is enabled or dis...
Definition detail_config_upc_ean_codes.hpp:179
SupplementalCode Supplemental() const override
Retrieves the current configuration of the supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:141
UpcA & SetSupplemental(SupplementalCode supplement, bool required=false, bool addSpace=true) override
Configures supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:130
bool StripCheckDigit() const override
Determines whether check digit removal is enabled.
Definition detail_config_upc_ean_codes.hpp:154
UpcA & SetStripCheckDigit(bool value) override
Enables or disables the removal of the check digit from read codes.
Definition detail_config_upc_ean_codes.hpp:148
Configuration class for UPC-E barcodes.
Definition decl_config_upc_ean_codes.hpp:239
UpcE & SetEnableUpcE1(bool value)
Enables or disables UPC-E1 decoding.
Definition detail_config_upc_ean_codes.hpp:234
UpcE & SetRejectMisreadCode(bool value)
Configures handling of damaged UPCE-A and EAN-13 codes.
Definition detail_config_upc_ean_codes.hpp:252
UpcE & SetSupplemental(SupplementalCode supplement, bool required=false, bool addSpace=true) override
Configures supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:187
bool StripNumberSystemDigit() const
Determines whether UPC-E Number System digit removal is enabled.
Definition detail_config_upc_ean_codes.hpp:222
bool EnabledUpcE1() const
Checks if UPC-E1 decoding is enabled.
Definition detail_config_upc_ean_codes.hpp:228
UpcE & SetStripCheckDigit(bool value) override
Enables or disables the removal of the check digit from read codes.
Definition detail_config_upc_ean_codes.hpp:205
UpcE & SetEnableUpcEExpansion(bool value)
Enables or disables the expansion of detected UPC-E codes to the UPC-A format.
Definition detail_config_upc_ean_codes.hpp:246
SupplementalCode Supplemental() const override
Retrieves the current configuration of the supplemental code decoding.
Definition detail_config_upc_ean_codes.hpp:198
bool StripCheckDigit() const override
Determines whether check digit removal is enabled.
Definition detail_config_upc_ean_codes.hpp:211
bool EnabledUpcEExpansion() const
Determines if the expansion of detected UPC-E codes to the UPC-A format is enabled.
Definition detail_config_upc_ean_codes.hpp:240
UpcE & SetStripNumberSystemDigit(bool value)
Enables or disables the removal of the UPC-E Number System digit from read codes.
Definition detail_config_upc_ean_codes.hpp:216
bool RejectMisreadCode() const
Determines whether damaged UPC-A or EAN-13 barcodes are rejected.
Definition detail_config_upc_ean_codes.hpp:258
Base configuration class for UPC-A, UPC-E, EAN-8, and EAN-13 barcodes.
Definition decl_config_upc_ean_codes.hpp:48
virtual T & SetSupplemental(SupplementalCode supplement, bool required=false, bool addSpace=true)=0
Configures supplemental code decoding.
virtual T & DisableCCA() override
Disables Composite Component A (CC-A) decoding.
Definition detail_config_upc_ean_codes.hpp:23
virtual T & DisableCCB() override
Disables Composite Component B (CC-B) decoding.
Definition detail_config_upc_ean_codes.hpp:39
virtual T & EnableCCA() override
Enables Composite Component A (CC-A) decoding.
Definition detail_config_upc_ean_codes.hpp:15
virtual T & EnableCCB() override
Enables Composite Component B (CC-B) decoding.
Definition detail_config_upc_ean_codes.hpp:31
virtual T & SetStripCheckDigit(bool value)=0
Enables or disables the removal of the check digit from read codes.
virtual T & EnableCCC() override
Enables Composite Component C (CC-C) decoding.
Definition detail_config_upc_ean_codes.hpp:47
virtual T & DisableCCC() override
Disables Composite Component C (CC-C) decoding.
Definition detail_config_upc_ean_codes.hpp:55
virtual SupplementalCode Supplemental() const =0
Retrieves the current configuration of the supplemental code decoding.
virtual bool StripCheckDigit() const =0
Determines whether check digit removal is enabled.
Class for decoding.
Definition decl_decoder.hpp:101
This namespace contains the configuration classes for all supported codes.
Definition decl_config_2d_codes.hpp:14
SupplementalCode
Enum class for configuring supplemental code decoding for UpcA, UpcE, Ean8 and Ean13 codes.
Definition decl_config_upc_ean_codes.hpp:19
@ Supplement2digits
Enables decoding of 2-digit supplemental codes.
Definition decl_config_upc_ean_codes.hpp:23
@ SupplementAll
Enables decoding of both 2-digit and 5-digit supplemental codes.
Definition decl_config_upc_ean_codes.hpp:27
@ Supplement5digits
Enables decoding of 5-digit supplemental codes.
Definition decl_config_upc_ean_codes.hpp:25
@ None
Definition decl_config_base.hpp:197
Namespace for all decoding functionalities.
Definition decl_config_2d_codes.hpp:10
Symbology
Enum class listing all supported symbologies.
Definition decl_config_base.hpp:35
@ Ean13
EAN-13.
Definition decl_config_base.hpp:57
@ UpcA
UPC-A.
Definition decl_config_base.hpp:67
@ Ean8
EAN-8.
Definition decl_config_base.hpp:62
@ UpcE
UPC-E.
Definition decl_config_base.hpp:72
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17