Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fgas / include / fx_stm.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _FX_STREAM\r
8 #define _FX_STREAM\r
9 class IFX_Stream;\r
10 IFX_FileRead*   FX_CreateFileRead(IFX_Stream *pBaseStream, FX_BOOL bReleaseStream = FALSE);\r
11 #ifdef FX_FILESIZE\r
12 IFX_FileRead*   FX_CreateFileRead(IFX_BufferRead *pBufferRead, FX_FILESIZE iFileSize = -1, FX_BOOL bReleaseStream = TRUE);\r
13 #else\r
14 IFX_FileRead*   FX_CreateFileRead(IFX_BufferRead *pBufferRead, FX_INT32 iFileSize = -1, FX_BOOL bReleaseStream = TRUE);\r
15 #endif\r
16 IFX_FileWrite*  FX_CreateFileWrite(IFX_Stream *pBaseStream, FX_BOOL bReleaseStream = FALSE);\r
17 enum FX_STREAMACCESS {\r
18     FX_STREAMACCESS_Binary              = 0x00,\r
19     FX_STREAMACCESS_Text                = 0x01,\r
20     FX_STREAMACCESS_Read                = 0x02,\r
21     FX_STREAMACCESS_Write               = 0x04,\r
22     FX_STREAMACCESS_Truncate    = 0x10,\r
23     FX_STREAMACCESS_Append              = 0x20,\r
24     FX_STREAMACCESS_Create              = 0x80,\r
25 };\r
26 enum FX_STREAMSEEK {\r
27     FX_STREAMSEEK_Begin                 = 0 ,\r
28     FX_STREAMSEEK_Current                       ,\r
29     FX_STREAMSEEK_End                           ,\r
30 };\r
31 class IFX_Stream\r
32 {\r
33 public:\r
34     static IFX_Stream*                  CreateStream(IFX_FileRead *pFileRead, FX_DWORD dwAccess);\r
35     static IFX_Stream*                  CreateStream(IFX_FileWrite *pFileWrite, FX_DWORD dwAccess);\r
36     static IFX_Stream*                  CreateStream(FX_LPCWSTR pszFileName, FX_DWORD dwAccess);\r
37     static IFX_Stream*                  CreateStream(FX_LPBYTE pData, FX_INT32 length, FX_DWORD dwAccess);\r
38     static IFX_Stream*                  CreateStream(IFX_BufferRead *pBufferRead, FX_DWORD dwAccess, FX_INT32 iFileSize = -1, FX_BOOL bReleaseBufferRead = TRUE);\r
39     static IFX_Stream*                  CreateTextStream(IFX_Stream *pBaseStream, FX_BOOL bDeleteOnRelease);\r
40     virtual void                                Release() = 0;\r
41     virtual IFX_Stream*                 Retain() = 0;\r
42     virtual FX_DWORD                    GetAccessModes() const = 0;\r
43     virtual FX_INT32                    GetLength() const = 0;\r
44     virtual FX_INT32                    Seek(FX_STREAMSEEK eSeek, FX_INT32 iOffset) = 0;\r
45     virtual FX_INT32                    GetPosition() = 0;\r
46     virtual FX_BOOL                             IsEOF() const = 0;\r
47     virtual FX_INT32                    ReadData(FX_LPBYTE pBuffer, FX_INT32 iBufferSize) = 0;\r
48     virtual FX_INT32                    ReadString(FX_LPWSTR pStr, FX_INT32 iMaxLength, FX_BOOL &bEOS, FX_INT32 const *pByteSize = NULL) = 0;\r
49     virtual FX_INT32                    WriteData(FX_LPCBYTE pBuffer, FX_INT32 iBufferSize) = 0;\r
50     virtual FX_INT32                    WriteString(FX_LPCWSTR pStr, FX_INT32 iLength) = 0;\r
51     virtual void                                Flush() = 0;\r
52     virtual FX_BOOL                             SetLength(FX_INT32 iLength) = 0;\r
53     virtual FX_INT32                    GetBOM(FX_BYTE bom[4]) const = 0;\r
54     virtual FX_WORD                             GetCodePage() const = 0;\r
55     virtual FX_WORD                             SetCodePage(FX_WORD wCodePage) = 0;\r
56     virtual void                                Lock() = 0;\r
57     virtual void                                Unlock() = 0;\r
58     virtual IFX_Stream*                 CreateSharedStream(FX_DWORD dwAccess, FX_INT32 iOffset, FX_INT32 iLength) = 0;\r
59 };\r
60 #endif\r