blob: 2701c810fbbdcfaf45048e67a3bf5aa30a37bd66 [file] [log] [blame]
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -07001// 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 FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_
8#define FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_
9
10#include <vector>
11
12#include "core/fxcrt/fx_string.h"
13#include "fxbarcode/pdf417/BC_PDF417Compaction.h"
14
15class CBC_PDF417HighLevelEncoder {
16 public:
17 static WideString encodeHighLevel(WideString msg,
18 Compaction compaction,
19 int32_t& e);
20 static void Inverse();
21 static void Initialize();
22 static void Finalize();
23
24 private:
25 static int32_t TEXT_COMPACTION;
26 static int32_t BYTE_COMPACTION;
27 static int32_t NUMERIC_COMPACTION;
28 static int32_t SUBMODE_PUNCTUATION;
29 static int32_t LATCH_TO_TEXT;
30 static int32_t LATCH_TO_BYTE_PADDED;
31 static int32_t LATCH_TO_NUMERIC;
32 static int32_t SHIFT_TO_BYTE;
33 static int32_t LATCH_TO_BYTE;
34 static uint8_t TEXT_MIXED_RAW[];
35 static uint8_t TEXT_PUNCTUATION_RAW[];
36 static int32_t MIXED[128];
37 static int32_t PUNCTUATION[128];
38 static int32_t encodeText(WideString msg,
39 int32_t startpos,
40 int32_t count,
41 WideString& sb,
42 int32_t initialSubmode);
43 static void encodeBinary(std::vector<uint8_t>* bytes,
44 int32_t startpos,
45 int32_t count,
46 int32_t startmode,
47 WideString& sb);
48 static void encodeNumeric(WideString msg,
49 int32_t startpos,
50 int32_t count,
51 WideString& sb);
52 static bool isDigit(wchar_t ch);
53 static bool isAlphaUpper(wchar_t ch);
54 static bool isAlphaLower(wchar_t ch);
55 static bool isMixed(wchar_t ch);
56 static bool isPunctuation(wchar_t ch);
57 static bool isText(wchar_t ch);
58 static int32_t determineConsecutiveDigitCount(WideString msg,
59 int32_t startpos);
60 static int32_t determineConsecutiveTextCount(WideString msg,
61 int32_t startpos);
62 static int32_t determineConsecutiveBinaryCount(WideString msg,
63 std::vector<uint8_t>* bytes,
64 int32_t startpos,
65 int32_t& e);
66
67 friend class PDF417HighLevelEncoder_EncodeNumeric_Test;
68 friend class PDF417HighLevelEncoder_EncodeBinary_Test;
69 friend class PDF417HighLevelEncoder_EncodeText_Test;
70 friend class PDF417HighLevelEncoder_ConsecutiveDigitCount_Test;
71 friend class PDF417HighLevelEncoder_ConsecutiveTextCount_Test;
72 friend class PDF417HighLevelEncoder_ConsecutiveBinaryCount_Test;
73};
74
75#endif // FXBARCODE_PDF417_BC_PDF417HIGHLEVELENCODER_H_