Foxit PDF SDK
CFX_CachedFileRead Class Reference

Cached file read interface. More...

Inheritance diagram for CFX_CachedFileRead:
IFX_FileStream IFX_FileRead IFX_FileWrite IFX_StreamRead IFX_StreamWrite

Public Member Functions

 CFX_CachedFileRead ()
 Constructor.
 
virtual ~CFX_CachedFileRead ()
 Destructor.

 
FX_BOOL AttachFile (IFX_FileRead *pFile, FX_BOOL bTakeOver)
 Attach a file read. More...
 
virtual FX_INT64 GetPosition ()
 Get the current reading position in stream. More...
 
virtual FX_INT64 GetSize ()
 Get total size of the file. More...
 
FX_BOOL Init (FX_INT32 nChunkSize, FX_INT32 nChunkCount, FX_LPVOID pBuffer, IFX_Allocator *pAllocator=0)
 Initialize the chunk size and chunk count. More...
 
virtual FX_BOOL IsEOF ()
 Determine whether reach the end of stream. More...
 
FX_BOOL PreCache (FX_INT64 offset, FX_INT32 nCacheCount)
 Attach a file read. More...
 
virtual FX_BOOL ReadBlock (void *buffer, FX_INT64 offset, size_t size)
 Read a data block from the file. More...
 
virtual size_t ReadBlock (void *buffer, size_t size)
 Read data block from stream. More...
 
- Public Member Functions inherited from IFX_FileStream
virtual FX_BOOL WriteBlock (const void *buffer, size_t size)
 Write a block data to the end of current stream. More...
 
- Public Member Functions inherited from IFX_FileRead
virtual void ClearRange ()
 Clear accessing range set by function IFX_FileRead::SetRange. More...
 
virtual FX_INT64 SetPosition (FX_INT64 pos)
 Set the current file accessing position. More...
 
virtual FX_BOOL SetRange (FX_INT64 offset, FX_INT64 size)
 Set accessing range. More...
 

Protected Member Functions

virtual FX_BOOL Flush ()
 Flush internal buffer. Unsupported for reading mode, return false directly.
 
virtual void Release ()
 Destroy the current instance. More...
 
virtual IFX_FileStreamRetain ()
 Create a shared instance. More...
 
virtual FX_BOOL WriteBlock (const void *buffer, FX_INT64 offset, size_t size)
 Write a block data into stream. Unsupported for reading mode, return false directly.
 

Detailed Description

Cached file read interface.

Member Function Documentation

◆ AttachFile()

FX_BOOL CFX_CachedFileRead::AttachFile ( IFX_FileRead pFile,
FX_BOOL  bTakeOver 
)

Attach a file read.

Parameters
[in]pFileThe file to be attached.
[in]bTakeOverTake over the file or not.
Returns
true means success, while false means failure.

◆ GetPosition()

virtual FX_INT64 CFX_CachedFileRead::GetPosition ( )
virtual

Get the current reading position in stream.

Returns
The current reading position in stream.

Implements IFX_FileStream.

◆ GetSize()

virtual FX_INT64 CFX_CachedFileRead::GetSize ( )
virtual

Get total size of the file.

Returns
File size, in bytes. Implementation can return 0 for any error.

Implements IFX_FileStream.

◆ Init()

FX_BOOL CFX_CachedFileRead::Init ( FX_INT32  nChunkSize,
FX_INT32  nChunkCount,
FX_LPVOID  pBuffer,
IFX_Allocator pAllocator = 0 
)

Initialize the chunk size and chunk count.

Parameters
[in]nChunkSizeThe size of each chunk.
[in]nChunkCountThe total count of chunks.
[in]pBufferExternal buffer. NULL means cache is disabled.
[in]pAllocatorAllocator used in this class. NULL means to use default allocator. Default value: NULL.
Returns
true means success, while false means failure.

◆ IsEOF()

virtual FX_BOOL CFX_CachedFileRead::IsEOF ( )
virtual

Determine whether reach the end of stream.

Returns
true means reach the end of stream, and false means not yet.

Implements IFX_FileStream.

◆ PreCache()

FX_BOOL CFX_CachedFileRead::PreCache ( FX_INT64  offset,
FX_INT32  nCacheCount 
)

Attach a file read.

Parameters
[in]offsetThe file to be attached.
[in]nCacheCountTake over the file or not.
Returns
true means success, while false means failure.

◆ ReadBlock() [1/2]

virtual FX_BOOL CFX_CachedFileRead::ReadBlock ( void *  buffer,
FX_INT64  offset,
size_t  size 
)
virtual

Read a data block from the file.

Parameters
[in,out]bufferPointer to a buffer receiving read data
[in]offsetByte offset from beginning of the file
[in]sizeNumber of bytes for the block.
Returns
true means success, while false means failure.

Implements IFX_FileStream.

◆ ReadBlock() [2/2]

virtual size_t CFX_CachedFileRead::ReadBlock ( void *  buffer,
size_t  size 
)
virtual

Read data block from stream.

Parameters
[in,out]bufferBuffer to store data.
[in]sizeTotal size of buffer, in bytes.
Returns
The length of data stored in buffer. 0 means error or no data.

Implements IFX_FileStream.

◆ Release()

virtual void CFX_CachedFileRead::Release ( )
protectedvirtual

Destroy the current instance.

Returns
None.

Implements IFX_FileStream.

◆ Retain()

virtual IFX_FileStream* CFX_CachedFileRead::Retain ( )
protectedvirtual

Create a shared instance.

Returns
File stream interface.

Implements IFX_FileStream.