Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: xfa/src/fxbarcode/src/include/utils.h

Issue 842043002: Organize barcode codes into modules. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/src/fxbarcode/src/include/BC_X12Encoder.h ('k') | xfa/src/fxbarcode/utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 _BC_UTILS_H_
8 #define _BC_UTILS_H_
9 typedef CFX_MapPtrTemplate<FX_LPVOID, FX_INT32> CFX_PtrToInt32;
10 FX_BOOL BC_FX_ByteString_Replace(CFX_ByteString &dst, FX_DWORD first, FX_DWORD l ast, FX_INT32 count, FX_CHAR c);
11 void BC_FX_ByteString_Append(CFX_ByteString &dst, FX_INT32 count, FX_CHAR c);
12 void BC_FX_ByteString_Append(CFX_ByteString &dst, const CFX_ByteArray &ba);
13 typedef FX_BOOL (*BC_PtrArrayCompareCallback)(FX_LPVOID l, FX_LPVOID r);
14 void BC_FX_PtrArray_Sort(CFX_PtrArray &src, BC_PtrArrayCompareCallback fun);
15 template<class _Ty>
16 class CBC_AutoPtr
17 {
18 public:
19 typedef _Ty element_type;
20 explicit CBC_AutoPtr(_Ty *_P = 0)
21 : _Owns(_P != 0), _Ptr(_P) {}
22 CBC_AutoPtr(const CBC_AutoPtr<_Ty>& _Y)
23 : _Owns(_Y._Owns), _Ptr(_Y.release()) {}
24 CBC_AutoPtr<_Ty>& operator=(const CBC_AutoPtr<_Ty>& _Y)
25 {
26 if (this != &_Y) {
27 if (_Ptr != _Y.get()) {
28 if (_Owns) {
29 delete _Ptr;
30 }
31 _Owns = _Y._Owns;
32 } else if (_Y._Owns) {
33 _Owns = TRUE;
34 }
35 _Ptr = _Y.release();
36 }
37 return (*this);
38 }
39 ~CBC_AutoPtr()
40 {
41 if (_Owns) {
42 delete _Ptr;
43 }
44 }
45 _Ty& operator*() const
46 {
47 return (*get());
48 }
49 _Ty *operator->() const
50 {
51 return (get());
52 }
53 _Ty *get() const
54 {
55 return (_Ptr);
56 }
57 _Ty *release() const
58 {
59 ((CBC_AutoPtr<_Ty> *)this)->_Owns = FALSE;
60 return (_Ptr);
61 }
62 private:
63 FX_BOOL _Owns;
64 _Ty *_Ptr;
65 };
66 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
67 #include <limits>
68 #elif (_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX _IOS_)
69 #include <limits.h>
70 #endif
71 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
72 #define FXSYS_isnan(x) _isnan(x)
73 #elif (_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_)
74 #include <math.h>
75 #define FXSYS_isnan(x) std::isnan(x)
76 #elif (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_)
77 #include <math.h>
78 #define FXSYS_isnan(x) isnan(x)
79 #endif
80 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_)
81 #define FXSYS_nan() (std::numeric_limits<float>::quiet_NaN())
82 #elif (_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX _IOS_ || _FX_OS_ == _FX_ANDROID_)
83 #define FXSYS_nan() NAN
84 #endif
85 enum BCFORMAT {
86 BCFORMAT_UNSPECIFY = -1,
87 BCFORMAT_CODABAR,
88 BCFORMAT_CODE_39,
89 BCFORMAT_CODE_128,
90 BCFORMAT_CODE_128B,
91 BCFORMAT_CODE_128C,
92 BCFORMAT_EAN_8,
93 BCFORMAT_UPC_A,
94 BCFORMAT_EAN_13,
95 BCFORMAT_PDF_417,
96 BCFORMAT_DATAMATRIX,
97 BCFORMAT_QR_CODE
98 };
99 #define BCFORMAT_ECLEVEL_L 0
100 #define BCFORMAT_ECLEVEL_M 1
101 #define BCFORMAT_ECLEVEL_Q 2
102 #define BCFORMAT_ECLEVEL_H 3
103 #include <ctype.h>
104 #define FXSYS_IntMax INT_MAX
105 #define FXSYS_Isdigit isdigit
106 #define BCExceptionNO 0
107 #define BCExceptionNotFound 1
108 #define BCExceptionEndLessThanStart 2
109 #define BCExceptionUnknownDecoder 3
110 #define BCExceptionRotateNotSupported 4
111 #define BCExceptionHeightAndWidthMustBeAtLeast1 5
112 #define BCExceptionRegionMustFitInsideMatrix 6
113 #define BCExceptionCanNotCallGetDimensionOnNonSquareMatrix 7
114 #define BCExceptionFormatException 8
115 #define BCExceptionIllegalArgumentMustMatchVersionSize 9
116 #define BCExceptionChecksumException 10
117 #define BCExceptionIllegalArgumentInvalidFirstDigit 11
118 #define BCExceptionIllegalArgumentInvalidSecondDigit 12
119 #define BCExceptionRuntimeDecodingInvalidISO_IEC 13
120 #define BCExceptionRuntimeDecodingInvalidAlphanumeric 14
121 #define BCExceptionLeftAndTopMustBeNonnegative 15
122 #define BCExceptionIllegalArgument 16
123 #define BCExceptionBadECI 17
124 #define BCExceptionUnSupportedBarcode 18
125 #define BCExceptionUnSupportedString 19
126 #define BCExceptionDigitLengthMustBe8 20
127 #define BCExceptionDataCheckException 21
128 #define BCExceptionExtractNumberValueFromBitArray 22
129 #define BCExceptionRead 23
130 #define BCExceptionRequestedRowIsOutSizeTheImage 24
131 #define BCExceptionNoContents 26
132 #define BCExceptionUnSupportEclevel 27
133 #define BCExceptionUnSupportMode 28
134 #define BCExceptionReferenceMustBeBetween0And7 29
135 #define BCExceptionBadErrorLocation 30
136 #define BCExceptionDegreeIsNegative 31
137 #define BCExceptionDivideByZero 32
138 #define BCExceptionCoefficientsSizeIsNull 33
139 #define BCExceptionNoCorrectionBytes 34
140 #define BCExceptionNoDataBytesProvided 35
141 #define BCExceptionR_I_1IsZero 36
142 #define BCExceptionAIsZero 37
143 #define BCExceptionIsZero 38
144 #define BCExceptionDegreeNotMatchRoots 39
145 #define BCExceptionContentsLengthShouldBetween1and80 40
146 #define BCExceptionOnlyEncodeCODE_128 41
147 #define BCExceptionOnlyEncodeCODE_39 42
148 #define BCExceptionOnlyEncodeEAN_13 43
149 #define BCExceptionOnlyEncodeEAN_8 44
150 #define BCExceptionOnlyEncodeITF 45
151 #define BCExceptionDigitLengthShould13 46
152 #define BCExceptionDigitLengthMustBe6or8or10or12or14or16or20or24or44 47
153 #define BCExceptionOnlyEncodeUPC_A 48
154 #define BCExceptionDigitLengthShouldBe12 49
155 #define BCExceptionValueMustBeEither0or1 50
156 #define BCExceptionReedsolomnDecodeException 51
157 #define BCExceptionBadIndexException 52
158 #define BCExceptionBadValueException 53
159 #define BCExceptionBadNumBitsException 54
160 #define BCExceptioncanNotOperatexorOperator 55
161 #define BCExceptionVersionMust1_40 56
162 #define BCExceptionUnknown 57
163 #define BCExceptionNoSuchVersion 58
164 #define BCExceptionCannotFindBlockInfo 59
165 #define BCExceptionDataTooBig 60
166 #define BCExceptionInvalidQRCode 61
167 #define BCExceptionDataTooMany 62
168 #define BCExceptionBitsNotEqualCacity 63
169 #define BCExceptionUnsupportedMode 64
170 #define BCExceptionInvalidateCharacter 65
171 #define BCExceptionBytesNotMatchOffset 66
172 #define BCExceptionSizeInBytesDiffer 67
173 #define BCExceptionInvalidateMaskPattern 68
174 #define BCExceptionNullPointer 69
175 #define BCExceptionBadMask 70
176 #define BCExceptionBitSizeNot15 71
177 #define BCExceptionBitSizeNot18 72
178 #define BCExceptionInvalidateImageData 73
179 #define BCExceptionHeight_8BeZero 74
180 #define BCExceptionCharacterNotThisMode 75
181 #define BCExceptionBitsBytesNotMatch 76
182 #define BCExceptionInvalidateData 77
183 #define BCExceptionLoadFile 78
184 #define BCExceptionPDF417EncodeFail 79
185 #define BCExceptionFailToCreateBitmap 80
186 #define BCExceptionLoadFontFail 81
187 #define BCExceptionOnlyEncodeCODEBAR 82
188 #define BCExceptionCodabarShouldStartWithOneOfABCD 83
189 #define BCExceptionCodabarShouldEndWithOneOfTNE 84
190 #define BCExceptionCodabarEncodeCharsInvalid 85
191 #define BCExceptionOnlyEncodeDATAMATRIX 86
192 #define BCExceptionCharactersOutsideISO88591Encoding 87
193 #define BCExceptionIllegalDataCodewords 88
194 #define BCExceptionCannotHandleThisNumberOfDataRegions 89
195 #define BCExceptionIllegalStateUnexpectedCase 90
196 #define BCExceptionIllegalStateCountMustNotExceed4 91
197 #define BCExceptionIllegalStateMessageLengthInvalid 92
198 #define BCExceptionIllegalArgumentNotGigits 93
199 #define BCExceptionIllegalStateIllegalMode 94
200 #define BCExceptionOnlyEncodePDF417 95
201 #define BCExceptionNonEncodableCharacterDetected 96
202 #define BCExceptionErrorCorrectionLevelMustBeBetween0And8 97
203 #define BCExceptionNoRecommendationPossible 98
204 #define BCExceptionIllegalArgumentnMustBeAbove0 99
205 #define BCExceptionUnableToFitMessageInColumns 100
206 #define BCExceptionEncodedMessageContainsTooManyCodeWords 101
207 #define BCExceptionBitmapSizeError 102
208 #define BCExceptionFormatInstance 102
209 #define BCExceptionChecksumInstance 103
210 #define BCExceptiontNotFoundInstance 104
211 #define BCExceptionNotFoundInstance 105
212 #define BCExceptionCannotMetadata 106
213 #define TWO_DIGIT_DATA_LENGTH_SIZE 24
214 #define THREE_DIGIT_DATA_LENGTH_SIZE 23
215 #define THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH_SIZE 57
216 #define FOUR_DIGIT_DATA_LENGTH_SIZE 17
217 #define BC_EXCEPTION_CHECK_ReturnVoid(e) if (e != BCExceptionNO) return;
218 #define BC_EXCEPTION_CHECK_ReturnValue(e, v) if (e != BCExceptionNO) return v;
219 #endif
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/src/include/BC_X12Encoder.h ('k') | xfa/src/fxbarcode/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698