summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page/cpdf_streamparser.h
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-22 10:45:59 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-22 10:45:59 -0800
commit1aff265f7a210738fc817675c4391f8fe240b81d (patch)
tree38a9cd7ea6e6faca866211ebe28c636a0c104e48 /core/fpdfapi/page/cpdf_streamparser.h
parente50184c087ee6f90568ad1166a55f5d25be4d09e (diff)
downloadpdfium-1aff265f7a210738fc817675c4391f8fe240b81d.tar.xz
Continue splitting pageint.h into per-class files
Add cpdf_streamparser.h and cpdf_contentparser.h since there are already corresponding .cpp files with the same name. Review-Url: https://codereview.chromium.org/2521123003
Diffstat (limited to 'core/fpdfapi/page/cpdf_streamparser.h')
-rw-r--r--core/fpdfapi/page/cpdf_streamparser.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/core/fpdfapi/page/cpdf_streamparser.h b/core/fpdfapi/page/cpdf_streamparser.h
new file mode 100644
index 0000000000..ce01dd04ee
--- /dev/null
+++ b/core/fpdfapi/page/cpdf_streamparser.h
@@ -0,0 +1,60 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_
+#define CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_
+
+#include <memory>
+#include <utility>
+
+#include "core/fpdfapi/parser/cpdf_dictionary.h"
+#include "core/fpdfapi/parser/cpdf_document.h"
+#include "core/fpdfapi/parser/cpdf_object.h"
+#include "core/fpdfapi/parser/cpdf_stream.h"
+#include "core/fxcrt/cfx_string_pool_template.h"
+#include "core/fxcrt/cfx_weak_ptr.h"
+
+class CPDF_StreamParser {
+ public:
+ enum SyntaxType { EndOfData, Number, Keyword, Name, Others };
+
+ CPDF_StreamParser(const uint8_t* pData, uint32_t dwSize);
+ CPDF_StreamParser(const uint8_t* pData,
+ uint32_t dwSize,
+ const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
+ ~CPDF_StreamParser();
+
+ SyntaxType ParseNextElement();
+ const uint8_t* GetWordBuf() const { return m_WordBuffer; }
+ uint32_t GetWordSize() const { return m_WordSize; }
+ uint32_t GetPos() const { return m_Pos; }
+ void SetPos(uint32_t pos) { m_Pos = pos; }
+ std::unique_ptr<CPDF_Object> GetObject() { return std::move(m_pLastObj); }
+ std::unique_ptr<CPDF_Object> ReadNextObject(bool bAllowNestedArray,
+ uint32_t dwInArrayLevel);
+ std::unique_ptr<CPDF_Stream> ReadInlineStream(
+ CPDF_Document* pDoc,
+ std::unique_ptr<CPDF_Dictionary> pDict,
+ CPDF_Object* pCSObj);
+
+ private:
+ friend class cpdf_streamparser_ReadHexString_Test;
+
+ void GetNextWord(bool& bIsNumber);
+ CFX_ByteString ReadString();
+ CFX_ByteString ReadHexString();
+ bool PositionIsInBounds() const;
+
+ const uint8_t* m_pBuf;
+ uint32_t m_Size; // Length in bytes of m_pBuf.
+ uint32_t m_Pos; // Current byte position within m_pBuf.
+ uint8_t m_WordBuffer[256];
+ uint32_t m_WordSize;
+ std::unique_ptr<CPDF_Object> m_pLastObj;
+ CFX_WeakPtr<CFX_ByteStringPool> m_pPool;
+};
+
+#endif // CORE_FPDFAPI_PAGE_CPDF_STREAMPARSER_H_