react-native-nitro-zxing 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (423) hide show
  1. package/README.md +34 -0
  2. package/VisionCameraZxing.podspec +48 -0
  3. package/android/CMakeLists.txt +43 -0
  4. package/android/build.gradle +150 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +3 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +7 -0
  9. package/android/src/main/java/com/margelo/nitro/camera/zxing/VisionCameraZxingPackage.kt +21 -0
  10. package/cpp/BarcodeValueTypeClassifier.cpp +70 -0
  11. package/cpp/BarcodeValueTypeClassifier.hpp +14 -0
  12. package/cpp/FrameImageView.cpp +75 -0
  13. package/cpp/FrameImageView.hpp +34 -0
  14. package/cpp/HybridBarcode.cpp +59 -0
  15. package/cpp/HybridBarcode.hpp +26 -0
  16. package/cpp/HybridBarcodeScanner.cpp +121 -0
  17. package/cpp/HybridBarcodeScanner.hpp +26 -0
  18. package/cpp/HybridBarcodeScannerFactory.cpp +11 -0
  19. package/cpp/HybridBarcodeScannerFactory.hpp +14 -0
  20. package/cpp/ImageDownscaler.cpp +34 -0
  21. package/cpp/ImageDownscaler.hpp +21 -0
  22. package/cpp/ZXingDecoder.cpp +189 -0
  23. package/cpp/ZXingDecoder.hpp +72 -0
  24. package/cpp/zxing-core/LICENSE +202 -0
  25. package/cpp/zxing-core/README.md +156 -0
  26. package/cpp/zxing-core/core/CMakeLists.txt +784 -0
  27. package/cpp/zxing-core/core/Version.h.in +28 -0
  28. package/cpp/zxing-core/core/ZXingConfig.cmake.in +9 -0
  29. package/cpp/zxing-core/core/src/Barcode.cpp +255 -0
  30. package/cpp/zxing-core/core/src/Barcode.h +191 -0
  31. package/cpp/zxing-core/core/src/BarcodeData.h +100 -0
  32. package/cpp/zxing-core/core/src/BarcodeFormat.cpp +286 -0
  33. package/cpp/zxing-core/core/src/BarcodeFormat.h +272 -0
  34. package/cpp/zxing-core/core/src/BinaryBitmap.cpp +111 -0
  35. package/cpp/zxing-core/core/src/BinaryBitmap.h +66 -0
  36. package/cpp/zxing-core/core/src/BitArray.cpp +38 -0
  37. package/cpp/zxing-core/core/src/BitArray.h +181 -0
  38. package/cpp/zxing-core/core/src/BitMatrix.cpp +175 -0
  39. package/cpp/zxing-core/core/src/BitMatrix.h +199 -0
  40. package/cpp/zxing-core/core/src/BitMatrixCursor.h +253 -0
  41. package/cpp/zxing-core/core/src/BitMatrixIO.cpp +101 -0
  42. package/cpp/zxing-core/core/src/BitMatrixIO.h +21 -0
  43. package/cpp/zxing-core/core/src/BitSource.cpp +77 -0
  44. package/cpp/zxing-core/core/src/BitSource.h +72 -0
  45. package/cpp/zxing-core/core/src/ByteArray.h +42 -0
  46. package/cpp/zxing-core/core/src/CharacterSet.cpp +78 -0
  47. package/cpp/zxing-core/core/src/CharacterSet.h +58 -0
  48. package/cpp/zxing-core/core/src/ConcentricFinder.cpp +312 -0
  49. package/cpp/zxing-core/core/src/ConcentricFinder.h +156 -0
  50. package/cpp/zxing-core/core/src/Content.cpp +471 -0
  51. package/cpp/zxing-core/core/src/Content.h +82 -0
  52. package/cpp/zxing-core/core/src/ContentType.h +19 -0
  53. package/cpp/zxing-core/core/src/CreateBarcode.cpp +490 -0
  54. package/cpp/zxing-core/core/src/CreateBarcode.h +132 -0
  55. package/cpp/zxing-core/core/src/DecoderResult.h +92 -0
  56. package/cpp/zxing-core/core/src/DetectorResult.h +44 -0
  57. package/cpp/zxing-core/core/src/ECI.cpp +81 -0
  58. package/cpp/zxing-core/core/src/ECI.h +78 -0
  59. package/cpp/zxing-core/core/src/Error.cpp +29 -0
  60. package/cpp/zxing-core/core/src/Error.h +79 -0
  61. package/cpp/zxing-core/core/src/Flags.h +165 -0
  62. package/cpp/zxing-core/core/src/GTIN.cpp +253 -0
  63. package/cpp/zxing-core/core/src/GTIN.h +58 -0
  64. package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.cpp +197 -0
  65. package/cpp/zxing-core/core/src/GlobalHistogramBinarizer.h +34 -0
  66. package/cpp/zxing-core/core/src/GridSampler.cpp +124 -0
  67. package/cpp/zxing-core/core/src/GridSampler.h +59 -0
  68. package/cpp/zxing-core/core/src/HRI.cpp +343 -0
  69. package/cpp/zxing-core/core/src/HRI.h +16 -0
  70. package/cpp/zxing-core/core/src/HybridBinarizer.cpp +315 -0
  71. package/cpp/zxing-core/core/src/HybridBinarizer.h +40 -0
  72. package/cpp/zxing-core/core/src/ImageView.h +168 -0
  73. package/cpp/zxing-core/core/src/JSON.cpp +154 -0
  74. package/cpp/zxing-core/core/src/JSON.h +66 -0
  75. package/cpp/zxing-core/core/src/LocalGrid.cpp +242 -0
  76. package/cpp/zxing-core/core/src/LocalGrid.h +91 -0
  77. package/cpp/zxing-core/core/src/LogMatrix.h +105 -0
  78. package/cpp/zxing-core/core/src/Matrix.h +125 -0
  79. package/cpp/zxing-core/core/src/MultiFormatReader.cpp +107 -0
  80. package/cpp/zxing-core/core/src/MultiFormatReader.h +34 -0
  81. package/cpp/zxing-core/core/src/MultiFormatWriter.cpp +111 -0
  82. package/cpp/zxing-core/core/src/MultiFormatWriter.h +62 -0
  83. package/cpp/zxing-core/core/src/Pattern.h +472 -0
  84. package/cpp/zxing-core/core/src/PerspectiveTransform.cpp +81 -0
  85. package/cpp/zxing-core/core/src/PerspectiveTransform.h +47 -0
  86. package/cpp/zxing-core/core/src/Point.h +185 -0
  87. package/cpp/zxing-core/core/src/Quadrilateral.h +215 -0
  88. package/cpp/zxing-core/core/src/Range.h +112 -0
  89. package/cpp/zxing-core/core/src/ReadBarcode.cpp +335 -0
  90. package/cpp/zxing-core/core/src/ReadBarcode.h +33 -0
  91. package/cpp/zxing-core/core/src/Reader.h +32 -0
  92. package/cpp/zxing-core/core/src/ReaderOptions.h +210 -0
  93. package/cpp/zxing-core/core/src/ReedSolomon.cpp +100 -0
  94. package/cpp/zxing-core/core/src/ReedSolomon.h +66 -0
  95. package/cpp/zxing-core/core/src/RegressionLine.h +161 -0
  96. package/cpp/zxing-core/core/src/ResultPoint.cpp +20 -0
  97. package/cpp/zxing-core/core/src/ResultPoint.h +35 -0
  98. package/cpp/zxing-core/core/src/StdGenerator.h +121 -0
  99. package/cpp/zxing-core/core/src/StdPrint.h +38 -0
  100. package/cpp/zxing-core/core/src/StdScope.h +55 -0
  101. package/cpp/zxing-core/core/src/StructuredAppend.h +19 -0
  102. package/cpp/zxing-core/core/src/SymbologyIdentifier.h +29 -0
  103. package/cpp/zxing-core/core/src/TextDecoder.cpp +59 -0
  104. package/cpp/zxing-core/core/src/TextDecoder.h +23 -0
  105. package/cpp/zxing-core/core/src/TextEncoder.cpp +75 -0
  106. package/cpp/zxing-core/core/src/TextEncoder.h +31 -0
  107. package/cpp/zxing-core/core/src/ThresholdBinarizer.h +58 -0
  108. package/cpp/zxing-core/core/src/TritMatrix.h +29 -0
  109. package/cpp/zxing-core/core/src/Utf.cpp +276 -0
  110. package/cpp/zxing-core/core/src/Utf.h +26 -0
  111. package/cpp/zxing-core/core/src/WhiteRectDetector.cpp +276 -0
  112. package/cpp/zxing-core/core/src/WhiteRectDetector.h +36 -0
  113. package/cpp/zxing-core/core/src/WriteBarcode.cpp +213 -0
  114. package/cpp/zxing-core/core/src/WriteBarcode.h +72 -0
  115. package/cpp/zxing-core/core/src/ZXAlgorithms.h +353 -0
  116. package/cpp/zxing-core/core/src/ZXConfig.h +17 -0
  117. package/cpp/zxing-core/core/src/ZXTestSupport.h +9 -0
  118. package/cpp/zxing-core/core/src/ZXVersion.h +14 -0
  119. package/cpp/zxing-core/core/src/ZXingC.cpp +460 -0
  120. package/cpp/zxing-core/core/src/ZXingC.h +296 -0
  121. package/cpp/zxing-core/core/src/ZXingCpp.cpp +18 -0
  122. package/cpp/zxing-core/core/src/ZXingCpp.h +76 -0
  123. package/cpp/zxing-core/core/src/ZXingQt.h +606 -0
  124. package/cpp/zxing-core/core/src/aztec/AZDecoder.cpp +376 -0
  125. package/cpp/zxing-core/core/src/aztec/AZDecoder.h +20 -0
  126. package/cpp/zxing-core/core/src/aztec/AZDetector.cpp +508 -0
  127. package/cpp/zxing-core/core/src/aztec/AZDetector.h +25 -0
  128. package/cpp/zxing-core/core/src/aztec/AZDetectorResult.h +51 -0
  129. package/cpp/zxing-core/core/src/aztec/AZEncoder.cpp +318 -0
  130. package/cpp/zxing-core/core/src/aztec/AZEncoder.h +44 -0
  131. package/cpp/zxing-core/core/src/aztec/AZEncodingState.h +40 -0
  132. package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.cpp +377 -0
  133. package/cpp/zxing-core/core/src/aztec/AZHighLevelEncoder.h +36 -0
  134. package/cpp/zxing-core/core/src/aztec/AZReader.cpp +45 -0
  135. package/cpp/zxing-core/core/src/aztec/AZReader.h +21 -0
  136. package/cpp/zxing-core/core/src/aztec/AZToken.cpp +44 -0
  137. package/cpp/zxing-core/core/src/aztec/AZToken.h +39 -0
  138. package/cpp/zxing-core/core/src/aztec/AZWriter.cpp +38 -0
  139. package/cpp/zxing-core/core/src/aztec/AZWriter.h +55 -0
  140. package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.cpp +194 -0
  141. package/cpp/zxing-core/core/src/datamatrix/DMBitLayout.h +21 -0
  142. package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.cpp +63 -0
  143. package/cpp/zxing-core/core/src/datamatrix/DMDataBlock.h +41 -0
  144. package/cpp/zxing-core/core/src/datamatrix/DMDecoder.cpp +457 -0
  145. package/cpp/zxing-core/core/src/datamatrix/DMDecoder.h +19 -0
  146. package/cpp/zxing-core/core/src/datamatrix/DMDetector.cpp +1230 -0
  147. package/cpp/zxing-core/core/src/datamatrix/DMDetector.h +23 -0
  148. package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.cpp +137 -0
  149. package/cpp/zxing-core/core/src/datamatrix/DMECEncoder.h +26 -0
  150. package/cpp/zxing-core/core/src/datamatrix/DMEncoderContext.h +128 -0
  151. package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.cpp +919 -0
  152. package/cpp/zxing-core/core/src/datamatrix/DMHighLevelEncoder.h +29 -0
  153. package/cpp/zxing-core/core/src/datamatrix/DMReader.cpp +40 -0
  154. package/cpp/zxing-core/core/src/datamatrix/DMReader.h +21 -0
  155. package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.cpp +141 -0
  156. package/cpp/zxing-core/core/src/datamatrix/DMSymbolInfo.h +78 -0
  157. package/cpp/zxing-core/core/src/datamatrix/DMSymbolShape.h +17 -0
  158. package/cpp/zxing-core/core/src/datamatrix/DMVersion.cpp +82 -0
  159. package/cpp/zxing-core/core/src/datamatrix/DMVersion.h +76 -0
  160. package/cpp/zxing-core/core/src/datamatrix/DMWriter.cpp +114 -0
  161. package/cpp/zxing-core/core/src/datamatrix/DMWriter.h +62 -0
  162. package/cpp/zxing-core/core/src/librscpp/README.md +65 -0
  163. package/cpp/zxing-core/core/src/librscpp/decode.h +258 -0
  164. package/cpp/zxing-core/core/src/librscpp/encode.h +124 -0
  165. package/cpp/zxing-core/core/src/librscpp/field.h +158 -0
  166. package/cpp/zxing-core/core/src/librscpp/poly.h +194 -0
  167. package/cpp/zxing-core/core/src/libzint/2of5inter.c +1 -0
  168. package/cpp/zxing-core/core/src/libzint/2of5inter_based.c +1 -0
  169. package/cpp/zxing-core/core/src/libzint/aztec.c +1 -0
  170. package/cpp/zxing-core/core/src/libzint/aztec.h +1 -0
  171. package/cpp/zxing-core/core/src/libzint/big5.h +1 -0
  172. package/cpp/zxing-core/core/src/libzint/codabar.c +1 -0
  173. package/cpp/zxing-core/core/src/libzint/code.c +1 -0
  174. package/cpp/zxing-core/core/src/libzint/code128.c +1 -0
  175. package/cpp/zxing-core/core/src/libzint/code128.h +1 -0
  176. package/cpp/zxing-core/core/src/libzint/common.c +1 -0
  177. package/cpp/zxing-core/core/src/libzint/common.h +1 -0
  178. package/cpp/zxing-core/core/src/libzint/dmatrix.c +1 -0
  179. package/cpp/zxing-core/core/src/libzint/dmatrix.h +1 -0
  180. package/cpp/zxing-core/core/src/libzint/dxfilmedge.c +1 -0
  181. package/cpp/zxing-core/core/src/libzint/eci.c +1 -0
  182. package/cpp/zxing-core/core/src/libzint/eci.h +1 -0
  183. package/cpp/zxing-core/core/src/libzint/eci_sb.h +1 -0
  184. package/cpp/zxing-core/core/src/libzint/filemem.c +1 -0
  185. package/cpp/zxing-core/core/src/libzint/filemem.h +1 -0
  186. package/cpp/zxing-core/core/src/libzint/fonts/normal_woff2.h +1 -0
  187. package/cpp/zxing-core/core/src/libzint/fonts/upcean_woff2.h +1 -0
  188. package/cpp/zxing-core/core/src/libzint/gb18030.h +1 -0
  189. package/cpp/zxing-core/core/src/libzint/gb2312.h +1 -0
  190. package/cpp/zxing-core/core/src/libzint/gbk.h +1 -0
  191. package/cpp/zxing-core/core/src/libzint/general_field.c +1 -0
  192. package/cpp/zxing-core/core/src/libzint/general_field.h +1 -0
  193. package/cpp/zxing-core/core/src/libzint/gs1.c +1 -0
  194. package/cpp/zxing-core/core/src/libzint/gs1.h +1 -0
  195. package/cpp/zxing-core/core/src/libzint/gs1_lint.h +1 -0
  196. package/cpp/zxing-core/core/src/libzint/iso3166.h +1 -0
  197. package/cpp/zxing-core/core/src/libzint/iso4217.h +1 -0
  198. package/cpp/zxing-core/core/src/libzint/ksx1001.h +1 -0
  199. package/cpp/zxing-core/core/src/libzint/large.c +1 -0
  200. package/cpp/zxing-core/core/src/libzint/large.h +1 -0
  201. package/cpp/zxing-core/core/src/libzint/library.c +1 -0
  202. package/cpp/zxing-core/core/src/libzint/maxicode.c +1 -0
  203. package/cpp/zxing-core/core/src/libzint/maxicode.h +1 -0
  204. package/cpp/zxing-core/core/src/libzint/medical.c +1 -0
  205. package/cpp/zxing-core/core/src/libzint/output.c +1 -0
  206. package/cpp/zxing-core/core/src/libzint/output.h +1 -0
  207. package/cpp/zxing-core/core/src/libzint/pdf417.c +1 -0
  208. package/cpp/zxing-core/core/src/libzint/pdf417.h +1 -0
  209. package/cpp/zxing-core/core/src/libzint/pdf417_tabs.h +1 -0
  210. package/cpp/zxing-core/core/src/libzint/qr.c +1 -0
  211. package/cpp/zxing-core/core/src/libzint/qr.h +1 -0
  212. package/cpp/zxing-core/core/src/libzint/raster.c +1 -0
  213. package/cpp/zxing-core/core/src/libzint/raster_font.h +1 -0
  214. package/cpp/zxing-core/core/src/libzint/reedsol.c +1 -0
  215. package/cpp/zxing-core/core/src/libzint/reedsol.h +1 -0
  216. package/cpp/zxing-core/core/src/libzint/reedsol_logs.h +1 -0
  217. package/cpp/zxing-core/core/src/libzint/rss.c +1 -0
  218. package/cpp/zxing-core/core/src/libzint/rss.h +1 -0
  219. package/cpp/zxing-core/core/src/libzint/sjis.h +1 -0
  220. package/cpp/zxing-core/core/src/libzint/stubs.c +137 -0
  221. package/cpp/zxing-core/core/src/libzint/svg.c +1 -0
  222. package/cpp/zxing-core/core/src/libzint/telepen.c +1 -0
  223. package/cpp/zxing-core/core/src/libzint/upcean.c +1 -0
  224. package/cpp/zxing-core/core/src/libzint/vector.c +1 -0
  225. package/cpp/zxing-core/core/src/libzint/zfiletypes.h +1 -0
  226. package/cpp/zxing-core/core/src/libzint/zint.h +1 -0
  227. package/cpp/zxing-core/core/src/libzint/zintconfig.h +1 -0
  228. package/cpp/zxing-core/core/src/libzueci/README.md +11 -0
  229. package/cpp/zxing-core/core/src/libzueci/zueci.c +1718 -0
  230. package/cpp/zxing-core/core/src/libzueci/zueci.h +179 -0
  231. package/cpp/zxing-core/core/src/libzueci/zueci_big5.h +3884 -0
  232. package/cpp/zxing-core/core/src/libzueci/zueci_common.h +31 -0
  233. package/cpp/zxing-core/core/src/libzueci/zueci_gb18030.h +264 -0
  234. package/cpp/zxing-core/core/src/libzueci/zueci_gb2312.h +2381 -0
  235. package/cpp/zxing-core/core/src/libzueci/zueci_gbk.h +4047 -0
  236. package/cpp/zxing-core/core/src/libzueci/zueci_ksx1001.h +2932 -0
  237. package/cpp/zxing-core/core/src/libzueci/zueci_sb.h +1112 -0
  238. package/cpp/zxing-core/core/src/libzueci/zueci_sjis.h +2286 -0
  239. package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.cpp +68 -0
  240. package/cpp/zxing-core/core/src/maxicode/MCBitMatrixParser.h +30 -0
  241. package/cpp/zxing-core/core/src/maxicode/MCDecoder.cpp +329 -0
  242. package/cpp/zxing-core/core/src/maxicode/MCDecoder.h +19 -0
  243. package/cpp/zxing-core/core/src/maxicode/MCReader.cpp +65 -0
  244. package/cpp/zxing-core/core/src/maxicode/MCReader.h +21 -0
  245. package/cpp/zxing-core/core/src/oned/ODCodabarReader.cpp +102 -0
  246. package/cpp/zxing-core/core/src/oned/ODCodabarReader.h +21 -0
  247. package/cpp/zxing-core/core/src/oned/ODCodabarWriter.cpp +136 -0
  248. package/cpp/zxing-core/core/src/oned/ODCodabarWriter.h +34 -0
  249. package/cpp/zxing-core/core/src/oned/ODCode128Patterns.h +130 -0
  250. package/cpp/zxing-core/core/src/oned/ODCode128Reader.cpp +236 -0
  251. package/cpp/zxing-core/core/src/oned/ODCode128Reader.h +21 -0
  252. package/cpp/zxing-core/core/src/oned/ODCode128Writer.cpp +261 -0
  253. package/cpp/zxing-core/core/src/oned/ODCode128Writer.h +34 -0
  254. package/cpp/zxing-core/core/src/oned/ODCode39Reader.cpp +213 -0
  255. package/cpp/zxing-core/core/src/oned/ODCode39Reader.h +26 -0
  256. package/cpp/zxing-core/core/src/oned/ODCode39Writer.cpp +176 -0
  257. package/cpp/zxing-core/core/src/oned/ODCode39Writer.h +34 -0
  258. package/cpp/zxing-core/core/src/oned/ODCode93Patterns.h +80 -0
  259. package/cpp/zxing-core/core/src/oned/ODCode93Reader.cpp +112 -0
  260. package/cpp/zxing-core/core/src/oned/ODCode93Reader.h +21 -0
  261. package/cpp/zxing-core/core/src/oned/ODCode93Writer.cpp +192 -0
  262. package/cpp/zxing-core/core/src/oned/ODCode93Writer.h +32 -0
  263. package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.cpp +246 -0
  264. package/cpp/zxing-core/core/src/oned/ODDXFilmEdgeReader.h +26 -0
  265. package/cpp/zxing-core/core/src/oned/ODDataBarCommon.cpp +172 -0
  266. package/cpp/zxing-core/core/src/oned/ODDataBarCommon.h +204 -0
  267. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.cpp +253 -0
  268. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedBitDecoder.h +19 -0
  269. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.cpp +383 -0
  270. package/cpp/zxing-core/core/src/oned/ODDataBarExpandedReader.h +25 -0
  271. package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.cpp +163 -0
  272. package/cpp/zxing-core/core/src/oned/ODDataBarLimitedReader.h +23 -0
  273. package/cpp/zxing-core/core/src/oned/ODDataBarReader.cpp +240 -0
  274. package/cpp/zxing-core/core/src/oned/ODDataBarReader.h +25 -0
  275. package/cpp/zxing-core/core/src/oned/ODEAN13Writer.cpp +62 -0
  276. package/cpp/zxing-core/core/src/oned/ODEAN13Writer.h +34 -0
  277. package/cpp/zxing-core/core/src/oned/ODEAN8Writer.cpp +51 -0
  278. package/cpp/zxing-core/core/src/oned/ODEAN8Writer.h +34 -0
  279. package/cpp/zxing-core/core/src/oned/ODITFReader.cpp +97 -0
  280. package/cpp/zxing-core/core/src/oned/ODITFReader.h +33 -0
  281. package/cpp/zxing-core/core/src/oned/ODITFWriter.cpp +78 -0
  282. package/cpp/zxing-core/core/src/oned/ODITFWriter.h +34 -0
  283. package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.cpp +323 -0
  284. package/cpp/zxing-core/core/src/oned/ODMultiUPCEANReader.h +32 -0
  285. package/cpp/zxing-core/core/src/oned/ODReader.cpp +259 -0
  286. package/cpp/zxing-core/core/src/oned/ODReader.h +35 -0
  287. package/cpp/zxing-core/core/src/oned/ODRowReader.h +222 -0
  288. package/cpp/zxing-core/core/src/oned/ODTelepenReader.cpp +199 -0
  289. package/cpp/zxing-core/core/src/oned/ODTelepenReader.h +25 -0
  290. package/cpp/zxing-core/core/src/oned/ODUPCAWriter.cpp +33 -0
  291. package/cpp/zxing-core/core/src/oned/ODUPCAWriter.h +34 -0
  292. package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.cpp +80 -0
  293. package/cpp/zxing-core/core/src/oned/ODUPCEANCommon.h +129 -0
  294. package/cpp/zxing-core/core/src/oned/ODUPCEWriter.cpp +56 -0
  295. package/cpp/zxing-core/core/src/oned/ODUPCEWriter.h +34 -0
  296. package/cpp/zxing-core/core/src/oned/ODWriterHelper.cpp +39 -0
  297. package/cpp/zxing-core/core/src/oned/ODWriterHelper.h +48 -0
  298. package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.cpp +796 -0
  299. package/cpp/zxing-core/core/src/pdf417/MicroPDFReader.h +23 -0
  300. package/cpp/zxing-core/core/src/pdf417/PDF417.cpp +85 -0
  301. package/cpp/zxing-core/core/src/pdf417/PDF417.h +81 -0
  302. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeMetadata.h +53 -0
  303. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.cpp +48 -0
  304. package/cpp/zxing-core/core/src/pdf417/PDFBarcodeValue.h +38 -0
  305. package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.cpp +116 -0
  306. package/cpp/zxing-core/core/src/pdf417/PDFBoundingBox.h +75 -0
  307. package/cpp/zxing-core/core/src/pdf417/PDFCodeword.h +71 -0
  308. package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.cpp +588 -0
  309. package/cpp/zxing-core/core/src/pdf417/PDFCodewordDecoder.h +41 -0
  310. package/cpp/zxing-core/core/src/pdf417/PDFCompaction.h +20 -0
  311. package/cpp/zxing-core/core/src/pdf417/PDFCustomData.h +32 -0
  312. package/cpp/zxing-core/core/src/pdf417/PDFDecoder.cpp +725 -0
  313. package/cpp/zxing-core/core/src/pdf417/PDFDecoder.h +20 -0
  314. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.cpp +247 -0
  315. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResult.h +74 -0
  316. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.cpp +321 -0
  317. package/cpp/zxing-core/core/src/pdf417/PDFDetectionResultColumn.h +83 -0
  318. package/cpp/zxing-core/core/src/pdf417/PDFDetector.cpp +371 -0
  319. package/cpp/zxing-core/core/src/pdf417/PDFDetector.h +45 -0
  320. package/cpp/zxing-core/core/src/pdf417/PDFEncoder.cpp +570 -0
  321. package/cpp/zxing-core/core/src/pdf417/PDFEncoder.h +182 -0
  322. package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.cpp +570 -0
  323. package/cpp/zxing-core/core/src/pdf417/PDFHighLevelEncoder.h +32 -0
  324. package/cpp/zxing-core/core/src/pdf417/PDFReader.cpp +333 -0
  325. package/cpp/zxing-core/core/src/pdf417/PDFReader.h +28 -0
  326. package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.cpp +559 -0
  327. package/cpp/zxing-core/core/src/pdf417/PDFScanningDecoder.h +41 -0
  328. package/cpp/zxing-core/core/src/pdf417/PDFWriter.cpp +170 -0
  329. package/cpp/zxing-core/core/src/pdf417/PDFWriter.h +74 -0
  330. package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.cpp +623 -0
  331. package/cpp/zxing-core/core/src/pdf417/ZXBigInteger.h +81 -0
  332. package/cpp/zxing-core/core/src/pdf417/ZXNullable.h +105 -0
  333. package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.cpp +294 -0
  334. package/cpp/zxing-core/core/src/qrcode/QRBitMatrixParser.h +41 -0
  335. package/cpp/zxing-core/core/src/qrcode/QRCodecMode.cpp +95 -0
  336. package/cpp/zxing-core/core/src/qrcode/QRCodecMode.h +59 -0
  337. package/cpp/zxing-core/core/src/qrcode/QRDataBlock.cpp +93 -0
  338. package/cpp/zxing-core/core/src/qrcode/QRDataBlock.h +52 -0
  339. package/cpp/zxing-core/core/src/qrcode/QRDataMask.h +50 -0
  340. package/cpp/zxing-core/core/src/qrcode/QRDecoder.cpp +359 -0
  341. package/cpp/zxing-core/core/src/qrcode/QRDecoder.h +19 -0
  342. package/cpp/zxing-core/core/src/qrcode/QRDetector.cpp +920 -0
  343. package/cpp/zxing-core/core/src/qrcode/QRDetector.h +45 -0
  344. package/cpp/zxing-core/core/src/qrcode/QRECB.h +52 -0
  345. package/cpp/zxing-core/core/src/qrcode/QREncodeResult.h +33 -0
  346. package/cpp/zxing-core/core/src/qrcode/QREncoder.cpp +568 -0
  347. package/cpp/zxing-core/core/src/qrcode/QREncoder.h +21 -0
  348. package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.cpp +51 -0
  349. package/cpp/zxing-core/core/src/qrcode/QRErrorCorrectionLevel.h +39 -0
  350. package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.cpp +160 -0
  351. package/cpp/zxing-core/core/src/qrcode/QRFormatInformation.h +61 -0
  352. package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.cpp +156 -0
  353. package/cpp/zxing-core/core/src/qrcode/QRMaskUtil.h +15 -0
  354. package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.cpp +318 -0
  355. package/cpp/zxing-core/core/src/qrcode/QRMatrixUtil.h +25 -0
  356. package/cpp/zxing-core/core/src/qrcode/QRReader.cpp +149 -0
  357. package/cpp/zxing-core/core/src/qrcode/QRReader.h +21 -0
  358. package/cpp/zxing-core/core/src/qrcode/QRVersion.cpp +754 -0
  359. package/cpp/zxing-core/core/src/qrcode/QRVersion.h +127 -0
  360. package/cpp/zxing-core/core/src/qrcode/QRWriter.cpp +51 -0
  361. package/cpp/zxing-core/core/src/qrcode/QRWriter.h +74 -0
  362. package/cpp/zxing-core/core/version.rc.in +34 -0
  363. package/cpp/zxing-core/core/zxing.pc.in +8 -0
  364. package/cpp/zxing-core/wrappers/ios/README.md +25 -0
  365. package/cpp/zxing-core/wrappers/ios/Sources/Wrapper/Version.h +29 -0
  366. package/cpp/zxing-core/zxing-cpp.podspec +45 -0
  367. package/lib/factory.d.ts +10 -0
  368. package/lib/factory.js +12 -0
  369. package/lib/index.d.ts +9 -0
  370. package/lib/index.js +9 -0
  371. package/lib/specs/Barcode.nitro.d.ts +63 -0
  372. package/lib/specs/Barcode.nitro.js +1 -0
  373. package/lib/specs/BarcodeFormat.d.ts +11 -0
  374. package/lib/specs/BarcodeFormat.js +1 -0
  375. package/lib/specs/BarcodeScanner.nitro.d.ts +89 -0
  376. package/lib/specs/BarcodeScanner.nitro.js +1 -0
  377. package/lib/specs/BarcodeScannerFactory.nitro.d.ts +26 -0
  378. package/lib/specs/BarcodeScannerFactory.nitro.js +1 -0
  379. package/lib/specs/BarcodeValueType.d.ts +9 -0
  380. package/lib/specs/BarcodeValueType.js +1 -0
  381. package/lib/specs/Point.d.ts +14 -0
  382. package/lib/specs/Point.js +1 -0
  383. package/lib/specs/Rect.d.ts +22 -0
  384. package/lib/specs/Rect.js +1 -0
  385. package/lib/useBarcodeScanner.d.ts +23 -0
  386. package/lib/useBarcodeScanner.js +25 -0
  387. package/nitro.json +20 -0
  388. package/nitrogen/generated/.gitattributes +1 -0
  389. package/nitrogen/generated/android/VisionCameraZxing+autolinking.cmake +83 -0
  390. package/nitrogen/generated/android/VisionCameraZxing+autolinking.gradle +27 -0
  391. package/nitrogen/generated/android/VisionCameraZxingOnLoad.cpp +49 -0
  392. package/nitrogen/generated/android/VisionCameraZxingOnLoad.hpp +34 -0
  393. package/nitrogen/generated/android/kotlin/com/margelo/nitro/camera/zxing/VisionCameraZxingOnLoad.kt +35 -0
  394. package/nitrogen/generated/ios/VisionCameraZxing+autolinking.rb +62 -0
  395. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.cpp +17 -0
  396. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Bridge.hpp +27 -0
  397. package/nitrogen/generated/ios/VisionCameraZxing-Swift-Cxx-Umbrella.hpp +38 -0
  398. package/nitrogen/generated/ios/VisionCameraZxingAutolinking.mm +35 -0
  399. package/nitrogen/generated/ios/VisionCameraZxingAutolinking.swift +16 -0
  400. package/nitrogen/generated/shared/c++/BarcodeFormat.hpp +124 -0
  401. package/nitrogen/generated/shared/c++/BarcodeScannerOptions.hpp +85 -0
  402. package/nitrogen/generated/shared/c++/BarcodeValueType.hpp +120 -0
  403. package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.cpp +23 -0
  404. package/nitrogen/generated/shared/c++/HybridBarcodeScannerSpec.hpp +74 -0
  405. package/nitrogen/generated/shared/c++/HybridBarcodeSpec.cpp +27 -0
  406. package/nitrogen/generated/shared/c++/HybridBarcodeSpec.hpp +82 -0
  407. package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.cpp +21 -0
  408. package/nitrogen/generated/shared/c++/HybridZXingBarcodeScannerFactorySpec.hpp +67 -0
  409. package/nitrogen/generated/shared/c++/Point.hpp +87 -0
  410. package/nitrogen/generated/shared/c++/Rect.hpp +95 -0
  411. package/nitrogen/generated/shared/c++/TargetBarcodeFormat.hpp +124 -0
  412. package/package.json +108 -0
  413. package/react-native.config.js +16 -0
  414. package/src/factory.ts +26 -0
  415. package/src/index.ts +9 -0
  416. package/src/specs/Barcode.nitro.ts +70 -0
  417. package/src/specs/BarcodeFormat.ts +31 -0
  418. package/src/specs/BarcodeScanner.nitro.ts +91 -0
  419. package/src/specs/BarcodeScannerFactory.nitro.ts +27 -0
  420. package/src/specs/BarcodeValueType.ts +25 -0
  421. package/src/specs/Point.ts +14 -0
  422. package/src/specs/Rect.ts +22 -0
  423. package/src/useBarcodeScanner.ts +36 -0
@@ -0,0 +1,490 @@
1
+ /*
2
+ * Copyright 2024 Axel Waggershauser
3
+ * Copyright 2025 gitlost
4
+ */
5
+ // SPDX-License-Identifier: Apache-2.0
6
+
7
+ #include "CreateBarcode.h"
8
+
9
+ #include "BarcodeData.h"
10
+ #include "BitMatrix.h"
11
+ #include "ByteArray.h"
12
+ #include "DecoderResult.h"
13
+ #include "DetectorResult.h"
14
+ #include "JSON.h"
15
+ #include "Version.h"
16
+ #include "ZXAlgorithms.h"
17
+
18
+ #ifdef ZXING_READERS
19
+ #include "ReadBarcode.h"
20
+ #endif
21
+
22
+ #ifdef ZXING_USE_ZINT
23
+ #include "ECI.h"
24
+ #include "TextEncoder.h"
25
+ #include <zint.h>
26
+ #else
27
+ #include "MultiFormatWriter.h"
28
+ #endif // ZXING_USE_ZINT
29
+
30
+ #include <charconv>
31
+ #include <optional>
32
+
33
+ using namespace std::literals;
34
+
35
+ namespace ZXing {
36
+
37
+ struct CreatorOptions::Data
38
+ {
39
+ BarcodeFormat format;
40
+ std::string options;
41
+
42
+ // symbol size (qrcode, datamatrix, etc), map from I, 'WxH'
43
+ // structured_append (idx, cnt, ID)
44
+
45
+ mutable unique_zint_symbol zint;
46
+
47
+ #ifndef __cpp_aggregate_paren_init // make XCode 14.x happy
48
+ Data(BarcodeFormat format, std::string options) : format(format), options(std::move(options)) {}
49
+ #endif
50
+ };
51
+
52
+ // TODO: check return type
53
+ #define ZX_PROPERTY(TYPE, NAME) \
54
+ const TYPE& CreatorOptions::NAME() const noexcept { return d->NAME; } \
55
+ CreatorOptions& CreatorOptions::NAME(TYPE v)& { return d->NAME = std::move(v), *this; } \
56
+ CreatorOptions&& CreatorOptions::NAME(TYPE v)&& { return d->NAME = std::move(v), std::move(*this); }
57
+
58
+ ZX_PROPERTY(BarcodeFormat, format)
59
+ ZX_PROPERTY(std::string, options)
60
+
61
+ #undef ZX_PROPERTY
62
+
63
+ #define ZX_RO_PROPERTY(TYPE, NAME) \
64
+ std::optional<TYPE> CreatorOptions::NAME() const noexcept { return JsonGet<TYPE>(d->options, #NAME); }
65
+
66
+ ZX_RO_PROPERTY(std::string, ecLevel);
67
+ ZX_RO_PROPERTY(std::string, eci);
68
+ ZX_RO_PROPERTY(bool, gs1);
69
+ ZX_RO_PROPERTY(bool, readerInit);
70
+ ZX_RO_PROPERTY(bool, forceSquare);
71
+ ZX_RO_PROPERTY(int, columns);
72
+ ZX_RO_PROPERTY(int, rows);
73
+ ZX_RO_PROPERTY(int, version);
74
+ ZX_RO_PROPERTY(int, dataMask);
75
+
76
+ #undef ZX_RO_PROPERTY
77
+
78
+ CreatorOptions::CreatorOptions(BarcodeFormat format, std::string options) : d(std::make_unique<Data>(format, std::move(options))) {}
79
+ CreatorOptions::~CreatorOptions() = default;
80
+ CreatorOptions::CreatorOptions(CreatorOptions&&) noexcept = default;
81
+ CreatorOptions& CreatorOptions::operator=(CreatorOptions&&) noexcept = default;
82
+
83
+ inline bool IsAscii(ByteView bv)
84
+ {
85
+ return std::all_of(bv.begin(), bv.end(), [](uint8_t c) { return c <= 127; });
86
+ }
87
+
88
+ #ifdef ZXING_WRITERS
89
+ #ifdef ZXING_USE_ZINT
90
+
91
+ struct String2Int
92
+ {
93
+ const char* str;
94
+ int val;
95
+ };
96
+
97
+ static int ParseECLevel(int symbology, std::string_view s)
98
+ {
99
+ constexpr std::string_view EC_LABELS_QR[4] = {"L", "M", "Q", "H"};
100
+ int res = 0;
101
+
102
+ // Convert L/M/Q/H to Zint 1-4
103
+ if (Contains({BARCODE_QRCODE, BARCODE_MICROQR, BARCODE_RMQR}, symbology))
104
+ if ((res = IndexOf(EC_LABELS_QR, s)) != -1)
105
+ return res + 1;
106
+
107
+ if (std::from_chars(s.data(), s.data() + s.size() - (s.back() == '%'), res).ec != std::errc{})
108
+ throw std::invalid_argument(StrCat("Invalid ecLevel: '", s, "'"));
109
+
110
+ auto findClosestECLevel = [](const std::vector<int>& list, int val) {
111
+ int mIdx = -2, mAbs = 100;
112
+ for (int i = 0; i < Size(list); ++i)
113
+ if (int abs = std::abs(val - list[i]); abs < mAbs) {
114
+ mIdx = i;
115
+ mAbs = abs;
116
+ }
117
+ return mIdx + 1;
118
+ };
119
+
120
+ // Convert percentage to Zint
121
+ if (s.back() == '%') {
122
+ switch (symbology) {
123
+ case BARCODE_QRCODE: return findClosestECLevel({20, 37, 55, 65}, res);
124
+ case BARCODE_MICROQR: return findClosestECLevel({20, 37, 55}, res);
125
+ case BARCODE_RMQR: return res <= 46 ? 2 : 4;
126
+ case BARCODE_AZTEC: return findClosestECLevel({10, 23, 36, 50}, res);
127
+ case BARCODE_PDF417:
128
+ // TODO: do something sensible with PDF417?
129
+ default:
130
+ return -1;
131
+ }
132
+ }
133
+
134
+ return res;
135
+ };
136
+
137
+ static constexpr struct { BarcodeFormat format; SymbologyIdentifier si; } barcodeFormat2SymbologyIdentifier[] = {
138
+ {BarcodeFormat::Aztec, {'z', '0', 3}}, // '1' GS1, '2' AIM
139
+ {BarcodeFormat::Codabar, {'F', '0'}}, // if checksum processing were implemented and checksum present and stripped then modifier would be 4
140
+ // {BarcodeFormat::CodablockF, {'O', '4'}}, // '5' GS1
141
+ {BarcodeFormat::Code128, {'C', '0'}}, // '1' GS1, '2' AIM
142
+ // {BarcodeFormat::Code16K, {'K', '0'}}, // '1' GS1, '2' AIM, '4' D1 PAD
143
+ // {BarcodeFormat::Code39, {'A', '0'}}, // '3' checksum, '4' extended, '7' checksum,extended
144
+ {BarcodeFormat::Code39Ext, {'A', '4'}}, // '3' checksum, '4' extended, '7' checksum,extended
145
+ {BarcodeFormat::DataBar, {'e', '0', 0, AIFlag::GS1}},
146
+ {BarcodeFormat::DataBarOmni, {'e', '0', 0, AIFlag::GS1}},
147
+ {BarcodeFormat::DataBarStk, {'e', '0', 0, AIFlag::GS1}},
148
+ {BarcodeFormat::DataBarStkOmni, {'e', '0', 0, AIFlag::GS1}},
149
+ {BarcodeFormat::DataBarExp, {'e', '0', 0, AIFlag::GS1}},
150
+ {BarcodeFormat::DataBarExpStk, {'e', '0', 0, AIFlag::GS1}},
151
+ {BarcodeFormat::DataBarLtd, {'e', '0', 0, AIFlag::GS1}},
152
+ {BarcodeFormat::DataMatrix, {'d', '1', 3}}, // '2' GS1, '3' AIM
153
+ // {BarcodeFormat::DotCode, {'J', '0', 3}}, // '1' GS1, '2' AIM
154
+ {BarcodeFormat::DXFilmEdge, {'X', 'F'}},
155
+ {BarcodeFormat::EAN8, {'E', '4'}},
156
+ // {BarcodeFormat::HanXin, {'h', '0', 1}}, // '2' GS1
157
+ // {BarcodeFormat::ITF, {'I', '0'}}, // '1' check digit
158
+ {BarcodeFormat::MaxiCode, {'U', '0', 2}}, // '1' mode 2 or 3
159
+ {BarcodeFormat::MicroPDF417, {'L', '2', -1}},
160
+ {BarcodeFormat::MicroQRCode, {'Q', '1', 1}},
161
+ {BarcodeFormat::PDF417, {'L', '2', -1}},
162
+ {BarcodeFormat::QRCode, {'Q', '1', 1}}, // '3' GS1, '5' AIM
163
+ {BarcodeFormat::RMQRCode, {'Q', '1', 1}}, // '3' GS1, '5' AIM
164
+ };
165
+
166
+ static SymbologyIdentifier SymbologyIdentifierZint2ZXing(const CreatorOptions& opts, const ByteArray& ba)
167
+ {
168
+ using enum BarcodeFormat;
169
+
170
+ const BarcodeFormat format = opts.format();
171
+
172
+ auto i = FindIf(barcodeFormat2SymbologyIdentifier, [format](auto& v) { return v.format == format; });
173
+ SymbologyIdentifier ret = i != std::end(barcodeFormat2SymbologyIdentifier) ? i->si : SymbologyIdentifier{SymbologyKey(format), '0'};
174
+
175
+ if (format & (EAN13 | UPCA | UPCE)) {
176
+ if (ba.size() > 13) // Have EAN-2/5 add-on?
177
+ ret.modifier = '3'; // Combined packet, EAN-13, UPC-A, UPC-E, with add-on
178
+ } else if (opts.gs1() && format & AllGS1) {
179
+ if (format & (Aztec | Code128))
180
+ ret.modifier = '1';
181
+ else if (format == DataMatrix)
182
+ ret.modifier = '2';
183
+ else if (format & (QRCode | RMQRCode))
184
+ ret.modifier = '3';
185
+ ret.aiFlag = AIFlag::GS1;
186
+ }
187
+
188
+ return ret;
189
+ }
190
+
191
+ static std::string ECLevelZint2ZXing(const zint_symbol* zint)
192
+ {
193
+ constexpr char EC_LABELS_QR[4] = {'L', 'M', 'Q', 'H'};
194
+
195
+ const int symbology = zint->symbology;
196
+ const int option_1 = zint->option_1;
197
+
198
+ switch (symbology) {
199
+ case BARCODE_AZTEC:
200
+ if ((option_1 >> 8) >= 0 && (option_1 >> 8) <= 99)
201
+ return std::to_string(option_1 >> 8) + "%";
202
+ break;
203
+ case BARCODE_MAXICODE:
204
+ // Mode
205
+ if (option_1 >= 2 && option_1 <= 6)
206
+ return std::to_string(option_1);
207
+ break;
208
+ case BARCODE_PDF417:
209
+ case BARCODE_PDF417COMP:
210
+ // Convert to percentage
211
+ if (option_1 >= 0 && option_1 <= 8) {
212
+ int overhead = symbology == BARCODE_PDF417COMP ? 35 : 69;
213
+ int cols = (zint->width - overhead) / 17;
214
+ int tot_cws = zint->rows * cols;
215
+ assert(tot_cws);
216
+ return std::to_string((2 << option_1) * 100 / tot_cws) + "%";
217
+ }
218
+ break;
219
+ // case BARCODE_MICROPDF417:
220
+ // if ((option_1 >> 8) >= 0 && (option_1 >> 8) <= 99)
221
+ // return std::to_string(option_1 >> 8) + "%";
222
+ // break;
223
+ case BARCODE_QRCODE:
224
+ case BARCODE_MICROQR:
225
+ case BARCODE_RMQR:
226
+ // Convert to L/M/Q/H
227
+ if (option_1 >= 1 && option_1 <= 4)
228
+ return {EC_LABELS_QR[option_1 - 1]};
229
+ break;
230
+ // case BARCODE_HANXIN:
231
+ // if (option_1 >= 1 && option_1 <= 4)
232
+ // return "L" + std::to_string(option_1);
233
+ // break;
234
+ default:
235
+ break;
236
+ }
237
+
238
+ return {};
239
+ }
240
+
241
+ #ifndef ZXING_READERS
242
+ // Convert bytes to UTF-8 code points 0-255
243
+ static std::string BinaryToUtf8(ByteView ba)
244
+ {
245
+ std::string utf8;
246
+ utf8.reserve(ba.size() * 2);
247
+ for (auto c : ba)
248
+ if (c < 0x80) {
249
+ utf8.push_back(c);
250
+ } else if (c < 0xC0) {
251
+ utf8.push_back(0xC2);
252
+ utf8.push_back(c);
253
+ } else {
254
+ utf8.push_back(0xC3);
255
+ utf8.push_back(c - 0x40);
256
+ }
257
+ return utf8;
258
+ }
259
+ #endif
260
+
261
+ zint_symbol* CreatorOptions::zint() const
262
+ {
263
+ using enum BarcodeFormat;
264
+
265
+ auto& zint = d->zint;
266
+
267
+ if (!zint) {
268
+ #ifdef PRINT_DEBUG
269
+ // printf("zint version: %d, sizeof(zint_symbol): %ld, options: %s\n", ZBarcode_Version(), sizeof(zint_symbol), options().c_str());
270
+ #endif
271
+ zint.reset(ZBarcode_Create());
272
+
273
+ switch (format()) {
274
+ #define X(NAME, SYM, VAR, FLAGS, ZINT, ENABLED, HRI) \
275
+ case BarcodeFormat(ZX_BCF_ID(SYM, VAR)): zint->symbology = ZINT; break;
276
+ ZX_BCF_LIST(X)
277
+ #undef X
278
+ };
279
+
280
+ if (zint->symbology == 0)
281
+ throw std::invalid_argument(StrCat("Unsupported barcode format for creation: ", ToString(format())));
282
+
283
+ if (format() == Code128 && gs1())
284
+ zint->symbology = BARCODE_GS1_128;
285
+
286
+ zint->scale = 0.5f;
287
+
288
+ if (auto val = ecLevel(); val)
289
+ zint->option_1 = ParseECLevel(zint->symbology, *val);
290
+
291
+ if (auto val = version(); val && !(format() & AllLinear))
292
+ zint->option_2 = *val;
293
+
294
+ if (auto val = columns(); val && format() & (DataBarExpStk | PDF417 | MicroPDF417 | CompactPDF417))
295
+ zint->option_2 = *val;
296
+
297
+ if (auto val = rows(); val && format() & (DataBarExpStk | PDF417))
298
+ zint->option_3 = *val;
299
+
300
+ if (auto val = dataMask(); val && format() & (QRCode | MicroQRCode))
301
+ zint->option_3 = (zint->option_3 & 0xFF) | (*val + 1) << 8;
302
+
303
+ if (format() == DataMatrix)
304
+ zint->option_3 = (forceSquare() ? DM_SQUARE : DM_DMRE) | DM_ISO_144;
305
+ }
306
+
307
+ return zint.get();
308
+ }
309
+
310
+ #define CHECK_WARN(ZINT_CALL, WARN) \
311
+ if (WARN = (ZINT_CALL); WARN >= ZINT_ERROR) \
312
+ throw std::invalid_argument(StrCat(zint->errtxt, " (retval: ", std::to_string(WARN), ")"));
313
+
314
+ Barcode CreateBarcode(const void* data, int size, int mode, const CreatorOptions& opts)
315
+ {
316
+ if (!data || size < 1)
317
+ throw std::invalid_argument("Can not create a barcode from NULL or empty data");
318
+
319
+ auto zint = opts.zint();
320
+
321
+ zint->input_mode = mode == UNICODE_MODE && opts.gs1() && (opts.format() & BarcodeFormat::AllGS1) ? GS1_MODE : mode;
322
+ if (mode == UNICODE_MODE && static_cast<const char*>(data)[0] != '[')
323
+ zint->input_mode |= GS1PARENS_MODE;
324
+ zint->output_options |= OUT_BUFFER_INTERMEDIATE | BARCODE_NO_QUIET_ZONES | BARCODE_CONTENT_SEGS;
325
+ if (opts.readerInit())
326
+ zint->output_options |= READER_INIT;
327
+
328
+ if (ZBarcode_Cap(zint->symbology, ZINT_CAP_ECI)) {
329
+ if (auto eci = opts.eci(); eci) {
330
+ if (auto cs = CharacterSetFromString(*eci); cs != CharacterSet::Unknown) {
331
+ zint->eci = static_cast<int>(ToECI(cs));
332
+ } else if (std::all_of(eci->begin(), eci->end(), IsDigit<char>)) {
333
+ zint->eci = std::stoi(*eci);
334
+ }
335
+ } else if (mode == DATA_MODE) {
336
+ zint->eci = static_cast<int>(ECI::Binary);
337
+ }
338
+ // the following would make sure that non-ASCII text is encoded as UTF-8, hence the GuessTextEncoding for
339
+ // non-ECI data can't produce a wrong result.
340
+ // else if (mode == UNICODE_MODE && !IsAscii({data, narrow_cast<size_t>(size)}))
341
+ // zint->eci = static_cast<int>(ECI::UTF8);
342
+ }
343
+
344
+ if (opts.format() == BarcodeFormat::Telepen && (std::all_of((const char*)data, (const char*)data + size, IsDigit<char>)))
345
+ zint->symbology = BARCODE_TELEPEN_NUM;
346
+
347
+ int warning;
348
+ CHECK_WARN(ZBarcode_Encode_and_Buffer(zint, (uint8_t*)data, size, 0), warning);
349
+
350
+ #ifdef PRINT_DEBUG
351
+ printf("create symbol with size: %dx%d\n", zint->width, zint->rows);
352
+ #endif
353
+
354
+ #if 0 // use ReadBarcode to create Barcode object
355
+ auto buffer = std::vector<uint8_t>(zint->bitmap_width * zint->bitmap_height);
356
+ std::transform(zint->bitmap, zint->bitmap + zint->bitmap_width * zint->bitmap_height, buffer.data(),
357
+ [](unsigned char v) { return (v == '0') * 0xff; });
358
+
359
+ auto res = ReadBarcode({buffer.data(), zint->bitmap_width, zint->bitmap_height, ImageFormat::Lum},
360
+ ReaderOptions().formats(opts.format()).isPure(true).binarizer(Binarizer::BoolCast));
361
+ #else
362
+ assert(zint->content_seg_count == 1);
363
+ const auto& content_seg = zint->content_segs[0];
364
+ const size_t content_seg_len =
365
+ static_cast<size_t>(content_seg.length - (opts.format() == BarcodeFormat::Code93 && content_seg.length >= 2 ? 2 : 0));
366
+
367
+ Content content;
368
+
369
+ if (zint->eci || warning == ZINT_WARN_USES_ECI)
370
+ content.switchEncoding(ECI(content_seg.eci));
371
+ else
372
+ content.switchEncoding(ToCharacterSet(ECI(content_seg.eci)));
373
+
374
+ if ((zint->input_mode & 0x07) == UNICODE_MODE) {
375
+ // `content_segs` returned as UTF-8
376
+ std::string utf8(reinterpret_cast<const char *>(content_seg.source), content_seg_len);
377
+ content.append(TextEncoder::FromUnicode(utf8, ToCharacterSet(ECI(content_seg.eci))));
378
+ #ifndef ZXING_READERS
379
+ content.utf8Cache.push_back(std::move(utf8));
380
+ #endif
381
+ } else {
382
+ content.append({content_seg.source, content_seg_len});
383
+ #ifndef ZXING_READERS
384
+ content.utf8Cache.push_back(BinaryToUtf8(content.bytes));
385
+ #endif
386
+ }
387
+
388
+ content.symbology = SymbologyIdentifierZint2ZXing(opts, content.bytes);
389
+
390
+ DecoderResult decRes(std::move(content));
391
+ decRes.setEcLevel(ECLevelZint2ZXing(zint));
392
+ decRes.setReaderInit(zint->output_options & READER_INIT);
393
+ auto bits = BitMatrix(zint->bitmap_width, zint->bitmap_height);
394
+ std::transform(zint->bitmap, zint->bitmap + zint->bitmap_width * zint->bitmap_height, bits.row(0).begin(),
395
+ [](unsigned char v) { return (v == '1') * BitMatrix::SET_V; });
396
+ int left, top, width, height;
397
+ bits.findBoundingBox(left, top, width, height);
398
+
399
+ auto res = MatrixBarcode(std::move(decRes), {std::move(bits), Rectangle<PointI>(left, top, width, height)}, opts.format());
400
+ #endif
401
+
402
+ res.zint = std::move(opts.d->zint);
403
+ res.zintMutex = std::make_unique<std::mutex>();
404
+
405
+ return res;
406
+ }
407
+
408
+ Barcode CreateBarcodeFromText(std::string_view contents, const CreatorOptions& options)
409
+ {
410
+ return CreateBarcode(contents.data(), contents.size(), UNICODE_MODE, options);
411
+ }
412
+
413
+ Barcode CreateBarcodeFromText(std::u8string_view contents, const CreatorOptions& options)
414
+ {
415
+ return CreateBarcode(contents.data(), contents.size(), UNICODE_MODE, options);
416
+ }
417
+
418
+ Barcode CreateBarcodeFromBytes(const void* data, int size, const CreatorOptions& options)
419
+ {
420
+ return CreateBarcode(data, size, DATA_MODE, options);
421
+ }
422
+
423
+ #else // ZXING_USE_ZINT
424
+
425
+ zint_symbol* CreatorOptions::zint() const { return nullptr; }
426
+
427
+ static Barcode CreateBarcode(BitMatrix&& bits, std::string_view contents, const CreatorOptions& opts)
428
+ {
429
+ Content content;
430
+ content.append(contents);
431
+
432
+ DecoderResult decRes(std::move(content));
433
+ DetectorResult detRes(std::move(bits), Rectangle<PointI>(0, 0, bits.width(), bits.height()));
434
+ return MatrixBarcode(std::move(decRes), std::move(detRes), opts.format());
435
+ }
436
+
437
+ Barcode CreateBarcodeFromText(std::string_view contents, const CreatorOptions& opts)
438
+ {
439
+ auto writer = MultiFormatWriter(opts.format()).setMargin(0);
440
+ if (auto ecLevel = opts.ecLevel(); ecLevel && ecLevel->size() == 1 && strchr("012345678", (*ecLevel)[0]))
441
+ writer.setEccLevel(std::stoi(*ecLevel));
442
+ if (!IsAscii({(const uint8_t*)contents.data(), contents.size()}))
443
+ writer.setEncoding(CharacterSet::UTF8); // write UTF8 (ECI value 26) for maximum compatibility
444
+
445
+ return CreateBarcode(writer.encode(std::string(contents), 0, opts.format() & BarcodeFormat::AllLinear ? 50 : 0), contents, opts);
446
+ }
447
+
448
+ Barcode CreateBarcodeFromText(std::u8string_view contents, const CreatorOptions& opts)
449
+ {
450
+ return CreateBarcodeFromText({reinterpret_cast<const char*>(contents.data()), contents.size()}, opts);
451
+ }
452
+
453
+ Barcode CreateBarcodeFromBytes(const void* data, int size, const CreatorOptions& opts)
454
+ {
455
+ std::wstring bytes;
456
+ for (uint8_t c : ByteView(data, size))
457
+ bytes.push_back(c);
458
+
459
+ auto writer = MultiFormatWriter(opts.format()).setMargin(0);
460
+ if (auto ecLevel = opts.ecLevel(); ecLevel && ecLevel->size() == 1 && strchr("012345678", (*ecLevel)[0]))
461
+ writer.setEccLevel(std::stoi(*ecLevel));
462
+ writer.setEncoding(CharacterSet::BINARY);
463
+
464
+ return CreateBarcode(writer.encode(bytes, 0, opts.format() & BarcodeFormat::AllLinear ? 50 : 0), {(const char*)data, (size_t)size}, opts);
465
+ }
466
+
467
+ #endif // ZXING_USE_ZINT
468
+
469
+ #else // ZXING_WRITERS
470
+
471
+ zint_symbol* CreatorOptions::zint() const { return nullptr; }
472
+
473
+ Barcode CreateBarcodeFromText(std::string_view, const CreatorOptions&)
474
+ {
475
+ throw std::runtime_error("This build of zxing-cpp does not support creating barcodes.");
476
+ }
477
+
478
+ Barcode CreateBarcodeFromText(std::u8string_view, const CreatorOptions&)
479
+ {
480
+ throw std::runtime_error("This build of zxing-cpp does not support creating barcodes.");
481
+ }
482
+
483
+ Barcode CreateBarcodeFromBytes(const void*, int, const CreatorOptions&)
484
+ {
485
+ throw std::runtime_error("This build of zxing-cpp does not support creating barcodes.");
486
+ }
487
+
488
+ #endif // ZXING_WRITERS
489
+
490
+ } // namespace ZXing
@@ -0,0 +1,132 @@
1
+ /*
2
+ * Copyright 2024 Axel Waggershauser
3
+ */
4
+ // SPDX-License-Identifier: Apache-2.0
5
+
6
+ #pragma once
7
+
8
+ #include "Barcode.h"
9
+
10
+ #include <memory>
11
+ #include <optional>
12
+ #include <string_view>
13
+
14
+ extern "C" struct zint_symbol;
15
+
16
+ namespace ZXing {
17
+
18
+ /**
19
+ * @brief Configuration options for barcode creation.
20
+ *
21
+ * This class encapsulates all the parameters needed to create a barcode with
22
+ * specific format and settings.
23
+ *
24
+ * The options property is a string that can contain multiple key-value pairs
25
+ * separated by commas. Each key-value pair configures a specific aspect of the
26
+ * barcode generation process and are dependent on the used BarcodeFormat.
27
+ * Boolean properties are interpreted as true if only the property name is present.
28
+ * Keys are case-insensitive. Passing a serialized JSON object is also supported.
29
+ *
30
+ * For a list of all supported options, see the list of read-only properties below.
31
+ *
32
+ * ```c++
33
+ * // example of creating a QR code with 30% error correction level and GS1 mode enabled
34
+ * auto opts = CreatorOptions(BarcodeFormat::QRCode, "ecLevel=30%, gs1");
35
+ * ```
36
+ */
37
+ class CreatorOptions
38
+ {
39
+ struct Data;
40
+
41
+ std::unique_ptr<Data> d;
42
+
43
+ friend Barcode CreateBarcode(const void* data, int size, int mode, const CreatorOptions& options);
44
+
45
+ public:
46
+ CreatorOptions(BarcodeFormat format, std::string options = {});
47
+ ~CreatorOptions();
48
+ CreatorOptions(CreatorOptions&&) noexcept;
49
+ CreatorOptions& operator=(CreatorOptions&&) noexcept;
50
+
51
+ zint_symbol* zint() const;
52
+
53
+ #define ZX_PROPERTY(TYPE, NAME) \
54
+ const TYPE& NAME() const noexcept; \
55
+ CreatorOptions& NAME(TYPE v)&; \
56
+ CreatorOptions&& NAME(TYPE v)&&;
57
+
58
+ ZX_PROPERTY(BarcodeFormat, format)
59
+ ZX_PROPERTY(std::string, options)
60
+
61
+ #undef ZX_PROPERTY
62
+
63
+ #define ZX_RO_PROPERTY(TYPE, NAME) \
64
+ std::optional<TYPE> NAME() const noexcept;
65
+
66
+ /// EcLevel, e.g. "30%", see also libzint docs for supported values per symbology
67
+ ZX_RO_PROPERTY(std::string, ecLevel);
68
+
69
+ /// Specify ECI designator to use (e.g. "UTF-8" or "26" for UTF-8), see also libzint docs (most 2D symbologies)
70
+ ZX_RO_PROPERTY(std::string, eci);
71
+
72
+ /// GS1 mode (most 2D symbologies + Code128)
73
+ ZX_RO_PROPERTY(bool, gs1);
74
+
75
+ /// Set the "reader init" flag (most 2D symbologies)
76
+ ZX_RO_PROPERTY(bool, readerInit);
77
+
78
+ /// DataMatrix: only consider square symbol versions
79
+ ZX_RO_PROPERTY(bool, forceSquare);
80
+
81
+ /// Specify number of columns (e.g. for DataBarExpStk, PDF417)
82
+ ZX_RO_PROPERTY(int, columns);
83
+
84
+ /// Specify number of rows (e.g. for DataBarExpStk, PDF417)
85
+ ZX_RO_PROPERTY(int, rows);
86
+
87
+ /// Specify the version/size of the symbol (most 2D symbologies)
88
+ ZX_RO_PROPERTY(int, version);
89
+
90
+ /// Specify dataMask to use (QRCode/MicroQRCode)
91
+ ZX_RO_PROPERTY(int, dataMask);
92
+
93
+ #undef ZX_RO_PROPERTY
94
+ };
95
+
96
+ /**
97
+ * @brief Generate Barcode from unicode text
98
+ *
99
+ * @param contents UTF-8 string to encode into a barcode
100
+ * @param options CreatorOptions (including BarcodeFormat)
101
+ */
102
+ Barcode CreateBarcodeFromText(std::string_view contents, const CreatorOptions& options);
103
+
104
+ /**
105
+ * @brief Generate Barcode from raw binary data
106
+ *
107
+ * @param data array of bytes to encode into a barcode
108
+ * @param size size of byte array
109
+ * @param options CreatorOptions (including BarcodeFormat)
110
+ */
111
+ Barcode CreateBarcodeFromBytes(const void* data, int size, const CreatorOptions& options);
112
+
113
+ #if defined(__cpp_lib_char8_t)
114
+ Barcode CreateBarcodeFromText(std::u8string_view contents, const CreatorOptions& options);
115
+ #endif
116
+
117
+ #if defined(__cpp_lib_ranges)
118
+ template <typename R>
119
+ requires std::ranges::contiguous_range<R> && std::ranges::sized_range<R> && (sizeof(std::ranges::range_value_t<R>) == 1)
120
+ Barcode CreateBarcodeFromBytes(const R& contents, const CreatorOptions& options)
121
+ {
122
+ return CreateBarcodeFromBytes(std::ranges::data(contents), std::ranges::size(contents), options);
123
+ }
124
+ #else
125
+ template <typename R>
126
+ Barcode CreateBarcodeFromBytes(const R& contents, const CreatorOptions& options)
127
+ {
128
+ return CreateBarcodeFromBytes(std::data(contents), std::size(contents), options);
129
+ }
130
+ #endif
131
+
132
+ } // ZXing