blob: e3fd1ac098116f68e9f144d109bf277f09350003 [file] [log] [blame]
Dan Sinclair1770c022016-03-14 14:14:16 -04001// 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 Sinclaire7786682017-03-29 15:18:41 -04007#ifndef FXBARCODE_UTILS_H_
8#define FXBARCODE_UTILS_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
Tom Sepez8b6186f2017-03-28 12:06:45 -070010#include <vector>
11
dsinclaira52ab742016-09-29 13:59:29 -070012#include "core/fxcrt/fx_basic.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040013
tsepezd19e9122016-11-02 15:43:18 -070014bool BC_FX_ByteString_Replace(CFX_ByteString& dst,
15 uint32_t first,
16 uint32_t last,
17 int32_t count,
Dan Sinclair812e96c2017-03-13 16:43:37 -040018 char c);
19void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, char c);
tsepez82aa3962017-01-20 12:59:50 -080020void BC_FX_ByteString_Append(CFX_ByteString& dst,
Tom Sepez8b6186f2017-03-28 12:06:45 -070021 const std::vector<uint8_t>& ba);
Dan Sinclair1770c022016-03-14 14:14:16 -040022
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.jrf02f7e52016-05-31 12:20:37 -070031#elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || \
32 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_)
Dan Sinclair1770c022016-03-14 14:14:16 -040033#include <cmath>
34#define FXSYS_isnan(x) std::isnan(x)
Dan Sinclair1770c022016-03-14 14:14:16 -040035#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
42enum 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 Sinclair1770c022016-03-14 14:14:16 -040061#define BCExceptionNO 0
Dan Sinclair1770c022016-03-14 14:14:16 -040062#define BCExceptionIllegalArgument 16
Dan Sinclair1770c022016-03-14 14:14:16 -040063#define BCExceptionDegreeIsNegative 31
Dan Sinclair1770c022016-03-14 14:14:16 -040064#define BCExceptionAIsZero 37
Dan Sinclair1770c022016-03-14 14:14:16 -040065#define BCExceptionValueMustBeEither0or1 50
Dan Sinclair1770c022016-03-14 14:14:16 -040066#define BCExceptionBadIndexException 52
Dan Sinclair1770c022016-03-14 14:14:16 -040067#define BCExceptionNoSuchVersion 58
Dan Sinclair1770c022016-03-14 14:14:16 -040068#define BCExceptionUnsupportedMode 64
69#define BCExceptionInvalidateCharacter 65
Dan Sinclair1770c022016-03-14 14:14:16 -040070#define BCExceptionInvalidateMaskPattern 68
71#define BCExceptionNullPointer 69
72#define BCExceptionBadMask 70
Dan Sinclair1770c022016-03-14 14:14:16 -040073#define BCExceptionInvalidateImageData 73
74#define BCExceptionHeight_8BeZero 74
75#define BCExceptionCharacterNotThisMode 75
Dan Sinclair1770c022016-03-14 14:14:16 -040076#define BCExceptionInvalidateData 77
Dan Sinclair1770c022016-03-14 14:14:16 -040077#define BCExceptionCharactersOutsideISO88591Encoding 87
78#define BCExceptionIllegalDataCodewords 88
79#define BCExceptionCannotHandleThisNumberOfDataRegions 89
80#define BCExceptionIllegalStateUnexpectedCase 90
Dan Sinclair1770c022016-03-14 14:14:16 -040081#define BCExceptionIllegalStateMessageLengthInvalid 92
82#define BCExceptionIllegalArgumentNotGigits 93
83#define BCExceptionIllegalStateIllegalMode 94
Dan Sinclair1770c022016-03-14 14:14:16 -040084#define BCExceptionNonEncodableCharacterDetected 96
Lei Zhangb2a40472017-04-04 16:15:13 -070085#define BCExceptionGeneric 107
Dan Sinclair1770c022016-03-14 14:14:16 -040086
Dan Sinclaire7786682017-03-29 15:18:41 -040087#endif // FXBARCODE_UTILS_H_