• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef XFA_FXBARCODE_UTILS_H_
8 #define XFA_FXBARCODE_UTILS_H_
9 
10 #include "core/fxcrt/fx_basic.h"
11 
12 bool BC_FX_ByteString_Replace(CFX_ByteString& dst,
13                               uint32_t first,
14                               uint32_t last,
15                               int32_t count,
16                               FX_CHAR c);
17 void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, FX_CHAR c);
18 void BC_FX_ByteString_Append(CFX_ByteString& dst,
19                              const CFX_ArrayTemplate<uint8_t>& ba);
20 
21 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
22 #include <limits>
23 #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \
24       _FX_OS_ == _FX_IOS_)
25 #include <limits.h>
26 #endif
27 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
28 #define FXSYS_isnan(x) _isnan(x)
29 #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || \
30       _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_)
31 #include <cmath>
32 #define FXSYS_isnan(x) std::isnan(x)
33 #endif
34 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
35 #define FXSYS_nan() (std::numeric_limits<float>::quiet_NaN())
36 #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \
37       _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_)
38 #define FXSYS_nan() NAN
39 #endif
40 enum BCFORMAT {
41   BCFORMAT_UNSPECIFY = -1,
42   BCFORMAT_CODABAR,
43   BCFORMAT_CODE_39,
44   BCFORMAT_CODE_128,
45   BCFORMAT_CODE_128B,
46   BCFORMAT_CODE_128C,
47   BCFORMAT_EAN_8,
48   BCFORMAT_UPC_A,
49   BCFORMAT_EAN_13,
50   BCFORMAT_PDF_417,
51   BCFORMAT_DATAMATRIX,
52   BCFORMAT_QR_CODE
53 };
54 #define BCFORMAT_ECLEVEL_L 0
55 #define BCFORMAT_ECLEVEL_M 1
56 #define BCFORMAT_ECLEVEL_Q 2
57 #define BCFORMAT_ECLEVEL_H 3
58 #include <ctype.h>
59 #define FXSYS_IntMax INT_MAX
60 #define FXSYS_Isdigit isdigit
61 #define BCExceptionNO 0
62 #define BCExceptionNotFound 1
63 #define BCExceptionEndLessThanStart 2
64 #define BCExceptionUnknownDecoder 3
65 #define BCExceptionRotateNotSupported 4
66 #define BCExceptionHeightAndWidthMustBeAtLeast1 5
67 #define BCExceptionRegionMustFitInsideMatrix 6
68 #define BCExceptionCanNotCallGetDimensionOnNonSquareMatrix 7
69 #define BCExceptionFormatException 8
70 #define BCExceptionIllegalArgumentMustMatchVersionSize 9
71 #define BCExceptionChecksumException 10
72 #define BCExceptionIllegalArgumentInvalidFirstDigit 11
73 #define BCExceptionIllegalArgumentInvalidSecondDigit 12
74 #define BCExceptionRuntimeDecodingInvalidISO_IEC 13
75 #define BCExceptionRuntimeDecodingInvalidAlphanumeric 14
76 #define BCExceptionLeftAndTopMustBeNonnegative 15
77 #define BCExceptionIllegalArgument 16
78 #define BCExceptionBadECI 17
79 #define BCExceptionUnSupportedBarcode 18
80 #define BCExceptionUnSupportedString 19
81 #define BCExceptionDigitLengthMustBe8 20
82 #define BCExceptionDataCheckException 21
83 #define BCExceptionExtractNumberValueFromBitArray 22
84 #define BCExceptionRead 23
85 #define BCExceptionRequestedRowIsOutSizeTheImage 24
86 #define BCExceptionNoContents 26
87 #define BCExceptionUnSupportEclevel 27
88 #define BCExceptionUnSupportMode 28
89 #define BCExceptionReferenceMustBeBetween0And7 29
90 #define BCExceptionBadErrorLocation 30
91 #define BCExceptionDegreeIsNegative 31
92 #define BCExceptionDivideByZero 32
93 #define BCExceptionCoefficientsSizeIsNull 33
94 #define BCExceptionNoCorrectionBytes 34
95 #define BCExceptionNoDataBytesProvided 35
96 #define BCExceptionR_I_1IsZero 36
97 #define BCExceptionAIsZero 37
98 #define BCExceptionIsZero 38
99 #define BCExceptionDegreeNotMatchRoots 39
100 #define BCExceptionContentsLengthShouldBetween1and80 40
101 #define BCExceptionOnlyEncodeCODE_128 41
102 #define BCExceptionOnlyEncodeCODE_39 42
103 #define BCExceptionOnlyEncodeEAN_13 43
104 #define BCExceptionOnlyEncodeEAN_8 44
105 #define BCExceptionOnlyEncodeITF 45
106 #define BCExceptionDigitLengthShould13 46
107 #define BCExceptionDigitLengthMustBe6or8or10or12or14or16or20or24or44 47
108 #define BCExceptionOnlyEncodeUPC_A 48
109 #define BCExceptionDigitLengthShouldBe12 49
110 #define BCExceptionValueMustBeEither0or1 50
111 #define BCExceptionReedsolomnDecodeException 51
112 #define BCExceptionBadIndexException 52
113 #define BCExceptionBadValueException 53
114 #define BCExceptionBadNumBitsException 54
115 #define BCExceptioncanNotOperatexorOperator 55
116 #define BCExceptionVersionMust1_40 56
117 #define BCExceptionUnknown 57
118 #define BCExceptionNoSuchVersion 58
119 #define BCExceptionCannotFindBlockInfo 59
120 #define BCExceptionDataTooBig 60
121 #define BCExceptionInvalidQRCode 61
122 #define BCExceptionDataTooMany 62
123 #define BCExceptionBitsNotEqualCacity 63
124 #define BCExceptionUnsupportedMode 64
125 #define BCExceptionInvalidateCharacter 65
126 #define BCExceptionBytesNotMatchOffset 66
127 #define BCExceptionSizeInBytesDiffer 67
128 #define BCExceptionInvalidateMaskPattern 68
129 #define BCExceptionNullPointer 69
130 #define BCExceptionBadMask 70
131 #define BCExceptionBitSizeNot15 71
132 #define BCExceptionBitSizeNot18 72
133 #define BCExceptionInvalidateImageData 73
134 #define BCExceptionHeight_8BeZero 74
135 #define BCExceptionCharacterNotThisMode 75
136 #define BCExceptionBitsBytesNotMatch 76
137 #define BCExceptionInvalidateData 77
138 #define BCExceptionLoadFile 78
139 #define BCExceptionPDF417EncodeFail 79
140 #define BCExceptionFailToCreateBitmap 80
141 #define BCExceptionLoadFontFail 81
142 #define BCExceptionOnlyEncodeCODEBAR 82
143 #define BCExceptionCodabarShouldStartWithOneOfABCD 83
144 #define BCExceptionCodabarShouldEndWithOneOfTNE 84
145 #define BCExceptionCodabarEncodeCharsInvalid 85
146 #define BCExceptionOnlyEncodeDATAMATRIX 86
147 #define BCExceptionCharactersOutsideISO88591Encoding 87
148 #define BCExceptionIllegalDataCodewords 88
149 #define BCExceptionCannotHandleThisNumberOfDataRegions 89
150 #define BCExceptionIllegalStateUnexpectedCase 90
151 #define BCExceptionIllegalStateCountMustNotExceed4 91
152 #define BCExceptionIllegalStateMessageLengthInvalid 92
153 #define BCExceptionIllegalArgumentNotGigits 93
154 #define BCExceptionIllegalStateIllegalMode 94
155 #define BCExceptionOnlyEncodePDF417 95
156 #define BCExceptionNonEncodableCharacterDetected 96
157 #define BCExceptionErrorCorrectionLevelMustBeBetween0And8 97
158 #define BCExceptionNoRecommendationPossible 98
159 #define BCExceptionIllegalArgumentnMustBeAbove0 99
160 #define BCExceptionUnableToFitMessageInColumns 100
161 #define BCExceptionEncodedMessageContainsTooManyCodeWords 101
162 #define BCExceptionBitmapSizeError 102
163 #define BCExceptionFormatInstance 102
164 #define BCExceptionChecksumInstance 103
165 #define BCExceptiontNotFoundInstance 104
166 #define BCExceptionNotFoundInstance 105
167 #define BCExceptionCannotMetadata 106
168 
169 #endif  // XFA_FXBARCODE_UTILS_H_
170