blob: 21ea695c3de4c1336eb940c9d011fb1bb9850d44 [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_DATAMATRIX_BC_ENCODERCONTEXT_H_
8#define FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_
Dan Sinclair1770c022016-03-14 14:14:16 -04009
Tom Sepezd0409af2017-05-25 15:53:57 -070010#include "core/fxcrt/cfx_unowned_ptr.h"
Lei Zhang60cd0332017-04-27 23:58:03 -070011#include "core/fxcrt/cfx_widestring.h"
Dan Sinclaire7786682017-03-29 15:18:41 -040012#include "fxbarcode/datamatrix/BC_SymbolShapeHint.h"
Dan Sinclair1770c022016-03-14 14:14:16 -040013
14class CBC_SymbolInfo;
Dan Sinclair1770c022016-03-14 14:14:16 -040015
Lei Zhanga861a7b2017-05-23 14:37:27 -070016class CBC_EncoderContext {
Dan Sinclair1770c022016-03-14 14:14:16 -040017 public:
Lei Zhang60cd0332017-04-27 23:58:03 -070018 CBC_EncoderContext(const CFX_WideString& msg,
19 const CFX_WideString& ecLevel,
Dan Sinclair1770c022016-03-14 14:14:16 -040020 int32_t& e);
Lei Zhanga861a7b2017-05-23 14:37:27 -070021 ~CBC_EncoderContext();
weili29b8ad02016-06-14 18:20:04 -070022
Dan Sinclair1770c022016-03-14 14:14:16 -040023 void setSymbolShape(SymbolShapeHint shape);
Dan Sinclair1770c022016-03-14 14:14:16 -040024 void setSkipAtEnd(int32_t count);
Dan Sinclair812e96c2017-03-13 16:43:37 -040025 wchar_t getCurrentChar();
26 wchar_t getCurrent();
Lei Zhang60cd0332017-04-27 23:58:03 -070027 void writeCodewords(const CFX_WideString& codewords);
Dan Sinclair812e96c2017-03-13 16:43:37 -040028 void writeCodeword(wchar_t codeword);
Dan Sinclair1770c022016-03-14 14:14:16 -040029 int32_t getCodewordCount();
30 void signalEncoderChange(int32_t encoding);
31 void resetEncoderSignal();
tsepezd19e9122016-11-02 15:43:18 -070032 bool hasMoreCharacters();
Dan Sinclair1770c022016-03-14 14:14:16 -040033 int32_t getRemainingCharacters();
34 void updateSymbolInfo(int32_t& e);
35 void updateSymbolInfo(int32_t len, int32_t& e);
36 void resetSymbolInfo();
37
Dan Sinclair1770c022016-03-14 14:14:16 -040038 CFX_WideString m_msg;
39 CFX_WideString m_codewords;
40 int32_t m_pos;
41 int32_t m_newEncoding;
Tom Sepezd0409af2017-05-25 15:53:57 -070042 CFX_UnownedPtr<CBC_SymbolInfo> m_symbolInfo;
Dan Sinclair1770c022016-03-14 14:14:16 -040043
44 private:
45 int32_t getTotalMessageCharCount();
46
Dan Sinclair1770c022016-03-14 14:14:16 -040047 SymbolShapeHint m_shape;
Dan Sinclair1770c022016-03-14 14:14:16 -040048 int32_t m_skipAtEnd;
49};
50
Dan Sinclaire7786682017-03-29 15:18:41 -040051#endif // FXBARCODE_DATAMATRIX_BC_ENCODERCONTEXT_H_