CartoType C++ API 7.8.2, 2022-03-25
for Windows, Linux, Qt and other platforms supporting C++ development
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
CartoType::CFileInputStream Class Reference

#include <cartotype_stream.h>

Inheritance diagram for CartoType::CFileInputStream:
CartoType::MInputStream

Classes

class  CBuffer
 

Public Member Functions

 CFileInputStream (const std::string &aFileName, size_t aBufferSize=KDefaultBufferSize, size_t aMaxBuffers=KDefaultMaxBuffers)
 
virtual std::unique_ptr< CFileInputStreamCopy ()
 
void Read (const uint8_t *&aPointer, size_t &aLength) override
 
bool EndOfStream () const override
 
void Seek (int64_t aPosition) override
 
int64_t Position () override
 
int64_t Length () override
 
std::string Name () override
 
 CFileInputStream (const CFileInputStream &)=delete
 
 CFileInputStream (CFileInputStream &&)=delete
 
void operator= (const CFileInputStream &)=delete
 
void operator= (CFileInputStream &&)=delete
 
- Public Member Functions inherited from CartoType::MInputStream
virtual ~MInputStream ()
 
virtual void Read (const uint8_t *&aPointer, size_t &aLength)=0
 
virtual bool EndOfStream () const =0
 
virtual void Seek (int64_t aPosition)=0
 
virtual int64_t Position ()=0
 
virtual int64_t Length ()=0
 
virtual std::string Name ()
 

Static Public Member Functions

static std::unique_ptr< CFileInputStreamNew (TResult &aError, const std::string &aFileName, size_t aBufferSize=KDefaultBufferSize, size_t aMaxBuffers=KDefaultMaxBuffers)
 

Static Public Attributes

static constexpr size_t KDefaultBufferSize = 64 * 1024
 
static constexpr size_t KDefaultMaxBuffers = 32
 

Protected Types

using CBufferList = CList< CBuffer >
 

Protected Member Functions

virtual void ReadBuffer (CBuffer &aBuffer, int64_t aPos)
 

Protected Attributes

CBinaryInputFile iFile
 
CBufferList iBuffers
 
size_t iBufferSize = KDefaultBufferSize
 
int64_t iPositionInFile = 0
 
int64_t iLogicalPosition = 0
 
int64_t iLength = 0
 
std::string iName
 

Detailed Description

Input stream for a file. The user of this stream determines the buffer size that is used to read from the file.

Member Typedef Documentation

◆ CBufferList

A type for the data cache.

Constructor & Destructor Documentation

◆ CFileInputStream()

CartoType::CFileInputStream::CFileInputStream ( const std::string &  aFileName,
size_t  aBufferSize = KDefaultBufferSize,
size_t  aMaxBuffers = KDefaultMaxBuffers 
)

Creates a CFileInputStream to read from the file aFileName. Throws an exception if the file cannot be opened.

Member Function Documentation

◆ Copy()

std::unique_ptr< CFileInputStream > CartoType::CFileInputStream::Copy ( )
virtual

Returns a copy of this CFileInputStream.

◆ EndOfStream()

bool CartoType::CFileInputStream::EndOfStream ( ) const
overridevirtual

Return whether the end of the stream has been reached.

Implements CartoType::MInputStream.

◆ Length()

int64_t CartoType::CFileInputStream::Length ( )
inlineoverridevirtual

Return the number of bytes in the stream.

Implements CartoType::MInputStream.

◆ Name()

std::string CartoType::CFileInputStream::Name ( )
inlineoverridevirtual

Return the file name or URI associated with the stream if any. Return the empty string is there is no file name or URI.

Reimplemented from CartoType::MInputStream.

◆ New()

std::unique_ptr< CFileInputStream > CartoType::CFileInputStream::New ( TResult aError,
const std::string &  aFileName,
size_t  aBufferSize = KDefaultBufferSize,
size_t  aMaxBuffers = KDefaultMaxBuffers 
)
static

Creates a CFileInputStream to read from the file aFileName. Returns the result in aError.

◆ Position()

int64_t CartoType::CFileInputStream::Position ( )
inlineoverridevirtual

Return the current position.

Implements CartoType::MInputStream.

◆ Read()

void CartoType::CFileInputStream::Read ( const uint8_t *&  aPointer,
size_t &  aLength 
)
overridevirtual

Read some data into a buffer owned by the MInputStream object and return a pointer to it in aPointer. Return the number of bytes of data in aLength. This function will return at least one byte if there are bytes remaining in the stream. The pointer is valid until the next call to Read.

Implements CartoType::MInputStream.

◆ ReadBuffer()

void CartoType::CFileInputStream::ReadBuffer ( CBuffer aBuffer,
int64_t  aPos 
)
protectedvirtual

Override this function to read a buffer at a certain position in the file.

◆ Seek()

void CartoType::CFileInputStream::Seek ( int64_t  aPosition)
overridevirtual

Seek to the specified position.

Implements CartoType::MInputStream.

Member Data Documentation

◆ iBuffers

CBufferList CartoType::CFileInputStream::iBuffers
protected

Cached data from the file.

◆ iBufferSize

size_t CartoType::CFileInputStream::iBufferSize = KDefaultBufferSize
protected

The size of a buffer in bytes.

◆ iFile

CBinaryInputFile CartoType::CFileInputStream::iFile
protected

The file.

◆ iLength

int64_t CartoType::CFileInputStream::iLength = 0
protected

the length of the file in bytes.

◆ iLogicalPosition

int64_t CartoType::CFileInputStream::iLogicalPosition = 0
protected

The position in the file from the user's point of view.

◆ iName

std::string CartoType::CFileInputStream::iName
protected

The name of the file.

◆ iPositionInFile

int64_t CartoType::CFileInputStream::iPositionInFile = 0
protected

The physical position in the file.

◆ KDefaultBufferSize

constexpr size_t CartoType::CFileInputStream::KDefaultBufferSize = 64 * 1024
staticconstexpr

The default size of each buffer in bytes.

◆ KDefaultMaxBuffers

constexpr size_t CartoType::CFileInputStream::KDefaultMaxBuffers = 32
staticconstexpr

The default maximum number of buffers.


The documentation for this class was generated from the following files: