summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_seekablestreamproxy.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-19 08:58:54 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-19 13:16:57 +0000
commit3b71d26f092ebc86ca9177fbbe89d83caa67ae1b (patch)
treea81ab092972ab8a2ce474d8d53984bfe9b6887a8 /core/fxcrt/cfx_seekablestreamproxy.h
parent5af27b63bf94e7f60212f6759c8342ce02da5ad2 (diff)
downloadpdfium-3b71d26f092ebc86ca9177fbbe89d83caa67ae1b.tar.xz
Move CFGAS_Stream to CFX_SeekableStreamProxy
This CL moves the FGAS stream code into core/fxcrt and renames to CFX_SeekableStreamProxy. Change-Id: I6641fe0cca45a128ef3ec281b0b40f8d60296387 Reviewed-on: https://pdfium-review.googlesource.com/4311 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_seekablestreamproxy.h')
-rw-r--r--core/fxcrt/cfx_seekablestreamproxy.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/core/fxcrt/cfx_seekablestreamproxy.h b/core/fxcrt/cfx_seekablestreamproxy.h
new file mode 100644
index 0000000000..d059fb8956
--- /dev/null
+++ b/core/fxcrt/cfx_seekablestreamproxy.h
@@ -0,0 +1,54 @@
+// Copyright 2017 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_FXCRT_CFX_SEEKABLESTREAMPROXY_H_
+#define CORE_FXCRT_CFX_SEEKABLESTREAMPROXY_H_
+
+#include <algorithm>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/fx_stream.h"
+#include "core/fxcrt/fx_system.h"
+
+class CFX_SeekableStreamProxy : public CFX_Retainable {
+ public:
+ enum class Pos {
+ Begin = 0,
+ Current,
+ };
+
+ template <typename T, typename... Args>
+ friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args);
+
+ FX_FILESIZE GetLength() const { return m_pStream->GetSize(); }
+ FX_FILESIZE GetPosition() { return m_iPosition; }
+ FX_STRSIZE GetBOMLength() const { return std::max(0, m_wBOMLength); }
+ bool IsEOF() const { return m_iPosition >= GetLength(); }
+
+ void Seek(CFX_SeekableStreamProxy::Pos eSeek, FX_FILESIZE iOffset);
+ FX_STRSIZE ReadString(wchar_t* pStr, FX_STRSIZE iMaxLength, bool* bEOS);
+
+ void WriteString(const CFX_WideStringC& str);
+
+ uint16_t GetCodePage() const { return m_wCodePage; }
+ void SetCodePage(uint16_t wCodePage);
+
+ private:
+ CFX_SeekableStreamProxy(const CFX_RetainPtr<IFX_SeekableStream>& stream,
+ bool isWriteSteam);
+ CFX_SeekableStreamProxy(uint8_t* data, FX_STRSIZE size);
+ ~CFX_SeekableStreamProxy() override;
+
+ FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize);
+
+ bool m_IsWriteStream;
+ uint16_t m_wCodePage;
+ FX_STRSIZE m_wBOMLength;
+ FX_FILESIZE m_iPosition;
+ CFX_RetainPtr<IFX_SeekableStream> m_pStream;
+};
+
+#endif // CORE_FXCRT_CFX_SEEKABLESTREAMPROXY_H_