Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 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 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 7 | #ifndef FXBARCODE_UTILS_H_ |
| 8 | #define FXBARCODE_UTILS_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 10 | #include <vector> |
| 11 | |
dsinclair | a52ab74 | 2016-09-29 13:59:29 -0700 | [diff] [blame] | 12 | #include "core/fxcrt/fx_basic.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 13 | |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 14 | bool BC_FX_ByteString_Replace(CFX_ByteString& dst, |
| 15 | uint32_t first, |
| 16 | uint32_t last, |
| 17 | int32_t count, |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 18 | char c); |
| 19 | void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, char c); |
tsepez | 82aa396 | 2017-01-20 12:59:50 -0800 | [diff] [blame] | 20 | void BC_FX_ByteString_Append(CFX_ByteString& dst, |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 21 | const std::vector<uint8_t>& ba); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 22 | |
| 23 | #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) |
| 24 | #include <limits> |
| 25 | #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ |
| 26 | _FX_OS_ == _FX_IOS_) |
| 27 | #include <limits.h> |
| 28 | #endif |
| 29 | #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) |
| 30 | #define FXSYS_isnan(x) _isnan(x) |
phajdan.jr | f02f7e5 | 2016-05-31 12:20:37 -0700 | [diff] [blame] | 31 | #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || \ |
| 32 | _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 33 | #include <cmath> |
| 34 | #define FXSYS_isnan(x) std::isnan(x) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 35 | #endif |
| 36 | #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) |
| 37 | #define FXSYS_nan() (std::numeric_limits<float>::quiet_NaN()) |
| 38 | #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ |
| 39 | _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_) |
| 40 | #define FXSYS_nan() NAN |
| 41 | #endif |
| 42 | enum BCFORMAT { |
| 43 | BCFORMAT_UNSPECIFY = -1, |
| 44 | BCFORMAT_CODABAR, |
| 45 | BCFORMAT_CODE_39, |
| 46 | BCFORMAT_CODE_128, |
| 47 | BCFORMAT_CODE_128B, |
| 48 | BCFORMAT_CODE_128C, |
| 49 | BCFORMAT_EAN_8, |
| 50 | BCFORMAT_UPC_A, |
| 51 | BCFORMAT_EAN_13, |
| 52 | BCFORMAT_PDF_417, |
| 53 | BCFORMAT_DATAMATRIX, |
| 54 | BCFORMAT_QR_CODE |
| 55 | }; |
| 56 | #define BCFORMAT_ECLEVEL_L 0 |
| 57 | #define BCFORMAT_ECLEVEL_M 1 |
| 58 | #define BCFORMAT_ECLEVEL_Q 2 |
| 59 | #define BCFORMAT_ECLEVEL_H 3 |
| 60 | #include <ctype.h> |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 61 | #define BCExceptionNO 0 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 62 | #define BCExceptionIllegalArgument 16 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 63 | #define BCExceptionDegreeIsNegative 31 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 64 | #define BCExceptionAIsZero 37 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 65 | #define BCExceptionValueMustBeEither0or1 50 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 66 | #define BCExceptionBadIndexException 52 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 67 | #define BCExceptionNoSuchVersion 58 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 68 | #define BCExceptionUnsupportedMode 64 |
| 69 | #define BCExceptionInvalidateCharacter 65 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 70 | #define BCExceptionInvalidateMaskPattern 68 |
| 71 | #define BCExceptionNullPointer 69 |
| 72 | #define BCExceptionBadMask 70 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 73 | #define BCExceptionInvalidateImageData 73 |
| 74 | #define BCExceptionHeight_8BeZero 74 |
| 75 | #define BCExceptionCharacterNotThisMode 75 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 76 | #define BCExceptionInvalidateData 77 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 77 | #define BCExceptionCharactersOutsideISO88591Encoding 87 |
| 78 | #define BCExceptionIllegalDataCodewords 88 |
| 79 | #define BCExceptionCannotHandleThisNumberOfDataRegions 89 |
| 80 | #define BCExceptionIllegalStateUnexpectedCase 90 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 81 | #define BCExceptionIllegalStateMessageLengthInvalid 92 |
| 82 | #define BCExceptionIllegalArgumentNotGigits 93 |
| 83 | #define BCExceptionIllegalStateIllegalMode 94 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 84 | #define BCExceptionNonEncodableCharacterDetected 96 |
Lei Zhang | b2a4047 | 2017-04-04 16:15:13 -0700 | [diff] [blame] | 85 | #define BCExceptionGeneric 107 |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 86 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 87 | #endif // FXBARCODE_UTILS_H_ |