summaryrefslogtreecommitdiff
path: root/xfa/fgas/crt/cfgas_stream.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-18 16:35:55 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-18 20:50:08 +0000
commitbf510b7c520bccbd2edf5bb3e2f91b125ebfd6d7 (patch)
tree6ffafd1e5fcc767f5a4160d290e0b5f72d2ce271 /xfa/fgas/crt/cfgas_stream.h
parentfdf7d4092a5fa9c79bbb4a626a4d3d087053ae2c (diff)
downloadpdfium-bf510b7c520bccbd2edf5bb3e2f91b125ebfd6d7.tar.xz
Rename IFGAS_Stream to CFGAS_Stream
This CL replaces IFGAS_Stream with the only implementation CFGAS_Stream. The CreateReadStream and CreateWriteStream methods are removed in favour of calling MakeRetain directly. Change-Id: I882a89258f642e24fc3d631587db05652bd53ded Reviewed-on: https://pdfium-review.googlesource.com/4210 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fgas/crt/cfgas_stream.h')
-rw-r--r--xfa/fgas/crt/cfgas_stream.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/xfa/fgas/crt/cfgas_stream.h b/xfa/fgas/crt/cfgas_stream.h
new file mode 100644
index 0000000000..5d2e5e6242
--- /dev/null
+++ b/xfa/fgas/crt/cfgas_stream.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 XFA_FGAS_CRT_CFGAS_STREAM_H_
+#define XFA_FGAS_CRT_CFGAS_STREAM_H_
+
+#include <algorithm>
+
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/fx_stream.h"
+#include "core/fxcrt/fx_system.h"
+
+class CFGAS_Stream : 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(CFGAS_Stream::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:
+ CFGAS_Stream(const CFX_RetainPtr<IFX_SeekableStream>& stream,
+ bool isWriteSteam);
+ CFGAS_Stream(uint8_t* data, FX_STRSIZE size);
+ ~CFGAS_Stream() override;
+
+ FX_STRSIZE ReadData(uint8_t* pBuffer, FX_STRSIZE iBufferSize);
+
+ uint16_t m_wCodePage;
+ FX_STRSIZE m_wBOMLength;
+ bool m_IsWriteStream;
+ FX_FILESIZE m_iPosition;
+ CFX_RetainPtr<IFX_SeekableStream> m_pStream;
+};
+
+#endif // XFA_FGAS_CRT_CFGAS_STREAM_H_