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_DATAMATRIXDECODEDBITSTREAMPARSER_H_
8 #define _BC_DATAMATRIXDECODEDBITSTREAMPARSER_H_
9 class CBC_CommonDecoderResult;
10 class CBC_CommonBitSource;
11 class CBC_DataMatrixDecodedBitStreamParser {
12  public:
13   CBC_DataMatrixDecodedBitStreamParser();
14   virtual ~CBC_DataMatrixDecodedBitStreamParser();
15   static CBC_CommonDecoderResult* Decode(CFX_ByteArray& bytes, int32_t& e);
16 
17  private:
18   static int32_t DecodeAsciiSegment(CBC_CommonBitSource* bits,
19                                     CFX_ByteString& result,
20                                     CFX_ByteString& resultTrailer,
21                                     int32_t& e);
22   static void DecodeC40Segment(CBC_CommonBitSource* bits,
23                                CFX_ByteString& result,
24                                int32_t& e);
25   static void DecodeTextSegment(CBC_CommonBitSource* bits,
26                                 CFX_ByteString& result,
27                                 int32_t& e);
28   static void DecodeAnsiX12Segment(CBC_CommonBitSource* bits,
29                                    CFX_ByteString& result,
30                                    int32_t& e);
31   static void ParseTwoBytes(int32_t firstByte,
32                             int32_t secondByte,
33                             CFX_Int32Array& result);
34   static void DecodeEdifactSegment(CBC_CommonBitSource* bits,
35                                    CFX_ByteString& result,
36                                    int32_t& e);
37   static void DecodeBase256Segment(CBC_CommonBitSource* bits,
38                                    CFX_ByteString& result,
39                                    CFX_Int32Array& byteSegments,
40                                    int32_t& e);
41   static uint8_t Unrandomize255State(int32_t randomizedBase256Codeword,
42                                      int32_t base256CodewordPosition);
43 
44   const static FX_CHAR C40_BASIC_SET_CHARS[];
45   const static FX_CHAR C40_SHIFT2_SET_CHARS[];
46 
47   const static FX_CHAR TEXT_BASIC_SET_CHARS[];
48   const static FX_CHAR TEXT_SHIFT3_SET_CHARS[];
49   const static int32_t PAD_ENCODE;
50   const static int32_t ASCII_ENCODE;
51   const static int32_t C40_ENCODE;
52   const static int32_t TEXT_ENCODE;
53   const static int32_t ANSIX12_ENCODE;
54   const static int32_t EDIFACT_ENCODE;
55   const static int32_t BASE256_ENCODE;
56 };
57 #endif
58