CartoType C++ API 8.8-7-gb35e4dc71
for Windows, Linux, Qt and other platforms supporting C++ development
Public Member Functions | List of all members
CartoTypeCore::InputStream Class Referenceabstract

#include <cartotype_stream.h>

Inheritance diagram for CartoTypeCore::InputStream:
CartoTypeCore::FileInputStreamBase CartoTypeCore::MemoryInputStream CartoTypeCore::SimpleFileInputStream CartoTypeCore::FileInputStream

Public Member Functions

virtual ~InputStream ()
 
virtual std::unique_ptr< InputStreamCopy ()=0
 
virtual int64_t StreamLength ()=0
 
virtual std::string StreamName ()
 
void Seek (int64_t aPosition)
 
int64_t Position () const
 
bool EndOfData () const
 
uint8_t ReadUint8 ()
 
uint16_t ReadUint16 ()
 
uint16_t ReadUint16LE ()
 
uint32_t ReadUint32 ()
 
uint32_t ReadUint32LE ()
 
uint64_t ReadUint40 ()
 
int64_t ReadFilePos ()
 
int64_t ReadFilePosWithDegreeSquare ()
 
int32_t FilePosBytes () const
 
void SetFilePosBytes (int32_t aBytes)
 
uint32_t ReadUintOfSize (int32_t aSize)
 
uint32_t ReadUintOfSizeLE (int32_t aSize)
 
uint64_t ReadUint ()
 
int64_t ReadInt ()
 
uint32_t ReadUintMax32 ()
 
int32_t ReadIntMax32 ()
 
float ReadFloat ()
 
float ReadFloatLE ()
 
double ReadDouble ()
 
double ReadDoubleLE ()
 
void ReadLine (uint8_t *aBuffer, size_t aMaxBytes, size_t &aActualBytes)
 
void ReadBytes (uint8_t *aBuffer, size_t aMaxBytes, size_t &aActualBytes)
 
void Read (const uint8_t *&aPointer, size_t &aLength)
 
String ReadNullTerminatedString ()
 
String ReadUtf8StringWithLength ()
 
std::string ReadUtf8StringWithLengthToStdString ()
 
std::string ReadUtf8StringToStdString ()
 
String ReadString (size_t *aBytesRead=nullptr)
 
void SkipUtf8String (size_t *aBytesRead=nullptr)
 
void Skip (int64_t aBytes)
 
const uint8_t * Read (size_t aBytes)
 
uint64_t ReadUint48 ()
 
uint64_t ReadUint56 ()
 

Detailed Description

The input stream base class. Streams that do not support random access always throw exceptions for StreamSeek and may throw exceptions for StreamPosition and StreamLength.

Exceptions that are not caused by lack or memory are of the type Result. Common values are KErrorEndOfData and KErrorIo.

Constructor & Destructor Documentation

◆ ~InputStream()

virtual CartoTypeCore::InputStream::~InputStream ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ Copy()

virtual std::unique_ptr< InputStream > CartoTypeCore::InputStream::Copy ( )
pure virtual

◆ EndOfData()

bool CartoTypeCore::InputStream::EndOfData ( ) const
inline

Returns true if this stream is at the end of the data.

◆ FilePosBytes()

int32_t CartoTypeCore::InputStream::FilePosBytes ( ) const
inline

Returns the number of bytes storing a file position; by default 4. The number is always 4 or 5.

◆ Position()

int64_t CartoTypeCore::InputStream::Position ( ) const
inline

Returns the current position as a byte offset from the start of the stream.

◆ Read() [1/2]

void CartoTypeCore::InputStream::Read ( const uint8_t *&  aPointer,
size_t &  aLength 
)

Reads some data and returns it as a pointer into an internal buffer and a length.

◆ Read() [2/2]

const uint8_t * CartoTypeCore::InputStream::Read ( size_t  aBytes)
inline

Reads the next aBytes bytes, returning a pointer to them, or return nullptr if fewer than that number of bytes is cached.

◆ ReadBytes()

void CartoTypeCore::InputStream::ReadBytes ( uint8_t *  aBuffer,
size_t  aMaxBytes,
size_t &  aActualBytes 
)

Read up to aMaxBytes to a buffer supplied and owned by the caller. This function only reads fewer than aMaxBytes if there are not enough bytes available in the stream.

◆ ReadDouble()

double CartoTypeCore::InputStream::ReadDouble ( )

Reads an IEEE double precision floating point number, big-endian.

◆ ReadDoubleLE()

double CartoTypeCore::InputStream::ReadDoubleLE ( )

Reads an IEEE double precision floating point number, little-endian.

◆ ReadFilePos()

int64_t CartoTypeCore::InputStream::ReadFilePos ( )
inline

Reads a file position: that is, an unsigned integer stored in the number of bytes returned by FilePosBytes.

◆ ReadFilePosWithDegreeSquare()

int64_t CartoTypeCore::InputStream::ReadFilePosWithDegreeSquare ( )
inline

Reads a file position combined with a degree square code: that is, an unsigned integer stored in two more bytes than FilePosBytes.

◆ ReadFloat()

float CartoTypeCore::InputStream::ReadFloat ( )

Reads an IEEE single precision floating point number, big-endian.

◆ ReadFloatLE()

float CartoTypeCore::InputStream::ReadFloatLE ( )

Reads an IEEE single precision floating point number, little-endian.

◆ ReadInt()

int64_t CartoTypeCore::InputStream::ReadInt ( )

Reads a variable-length signed integer stored in up to 10 bytes. The value is read using ReadUint and bit 0, the low bit, is the sign: 0 is positive and 1 is negative. The other bits from bit 1 upward, are the value.

◆ ReadIntMax32()

int32_t CartoTypeCore::InputStream::ReadIntMax32 ( )

Reads a variable-length 32-bit signed integer but throws an exception if an integer that will not fit in 32 bits is supplied.

◆ ReadLine()

void CartoTypeCore::InputStream::ReadLine ( uint8_t *  aBuffer,
size_t  aMaxBytes,
size_t &  aActualBytes 
)

Read a line of text into a buffer supplied and owned by the caller. Read up to aMaxBytes, stopping beforehand if the stream ends or a newline is encountered, defined as either CR, LF, or CR+LF. The newline is skipped but not appended to the buffer.

◆ ReadNullTerminatedString()

String CartoTypeCore::InputStream::ReadNullTerminatedString ( )

Reads a null-terminated UTF-8 string.

◆ ReadString()

String CartoTypeCore::InputStream::ReadString ( size_t *  aBytesRead = nullptr)

Reads a UTF8 string preceded by a length. A single byte of 0...254 is a valid length. The byte value 255 indicates that a four-byte length follows. If aBytesRead is non-null the number of bytes read from the stream is returned there.

◆ ReadUint()

uint64_t CartoTypeCore::InputStream::ReadUint ( )

Reads a variable-length unsigned integer stored in up to 10 bytes. All bytes except the last one have the top bit set. The value is made by reading the low 7 bits of the bytes in little-endian order; thus the first byte supplies bits 0-6, the second byte supplies bits 7-13, and so on.

◆ ReadUint16()

uint16_t CartoTypeCore::InputStream::ReadUint16 ( )

Reads a 16-bit unsigned integer, big-endian.

◆ ReadUint16LE()

uint16_t CartoTypeCore::InputStream::ReadUint16LE ( )

Reads a 16-bit unsigned integer, little-endian.

◆ ReadUint32()

uint32_t CartoTypeCore::InputStream::ReadUint32 ( )

Reads a 32-bit unsigned integer, big-endian.

◆ ReadUint32LE()

uint32_t CartoTypeCore::InputStream::ReadUint32LE ( )

Reads a 32-bit unsigned integer, little-endian.

◆ ReadUint40()

uint64_t CartoTypeCore::InputStream::ReadUint40 ( )
inline

Reads a 40-bit unsigned integer in big-endian form.

◆ ReadUint48()

uint64_t CartoTypeCore::InputStream::ReadUint48 ( )
inline

Reads an unsigned big-endian 48-bit number.

◆ ReadUint56()

uint64_t CartoTypeCore::InputStream::ReadUint56 ( )
inline

Reads an unsigned big-endian 56-bit number.

◆ ReadUint8()

uint8_t CartoTypeCore::InputStream::ReadUint8 ( )
inline

Reads an 8-bit unsigned integer.

◆ ReadUintMax32()

uint32_t CartoTypeCore::InputStream::ReadUintMax32 ( )

Reads a variable-length 32-bit unsigned integer stored in up to 5 bytes using the same format as ReadUint, but returns an error if more than 5 bytes are supplied.

◆ ReadUintOfSize()

uint32_t CartoTypeCore::InputStream::ReadUintOfSize ( int32_t  aSize)

Reads a big-endian integer stored in a certain number of bytes, which must be 1, 2 or 4.

◆ ReadUintOfSizeLE()

uint32_t CartoTypeCore::InputStream::ReadUintOfSizeLE ( int32_t  aSize)

Reads a little-endian integer stored in a certain number of bytes, which must be 1, 2 or 4.

◆ ReadUtf8StringToStdString()

std::string CartoTypeCore::InputStream::ReadUtf8StringToStdString ( )

Reads a UTF8 string preceded by a length. A single byte of 0...254 is a valid length. The byte value 255 indicates that a four-byte length follows.

◆ ReadUtf8StringWithLength()

String CartoTypeCore::InputStream::ReadUtf8StringWithLength ( )

Reads a UTF-8 string. The string is stored as a variable-length unsigned integer, read using ReadUint, containing the length in bytes, then the bytes in UTF-8 format.

◆ ReadUtf8StringWithLengthToStdString()

std::string CartoTypeCore::InputStream::ReadUtf8StringWithLengthToStdString ( )

Reads a UTF-8 string. The string is stored as a variable-length unsigned integer, read using ReadUint, containing the length in bytes, then the bytes in UTF-8 format.

◆ Seek()

void CartoTypeCore::InputStream::Seek ( int64_t  aPosition)

Move to a specified position in the input stream.

◆ SetFilePosBytes()

void CartoTypeCore::InputStream::SetFilePosBytes ( int32_t  aBytes)
inline

Sets the number of bytes used to store a file position: must be 4 or 5.

◆ Skip()

void CartoTypeCore::InputStream::Skip ( int64_t  aBytes)

Skip forward by a certain number of bytes.

◆ SkipUtf8String()

void CartoTypeCore::InputStream::SkipUtf8String ( size_t *  aBytesRead = nullptr)

Skips a UTF8 string preceded by a length. A single byte of 0...254 is a valid length. The byte value 255 indicates that a four-byte length follows. If aBytesRead is non-null the number of bytes skipped is returned there.

◆ StreamLength()

virtual int64_t CartoTypeCore::InputStream::StreamLength ( )
pure virtual

Returns the number of bytes in the stream.

Implemented in CartoTypeCore::MemoryInputStream, CartoTypeCore::FileInputStreamBase, and CartoTypeCore::SimpleFileInputStream.

◆ StreamName()

virtual std::string CartoTypeCore::InputStream::StreamName ( )
inlinevirtual

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

Reimplemented in CartoTypeCore::FileInputStreamBase, and CartoTypeCore::SimpleFileInputStream.


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