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

#include <cartotype_stream.h>

Inheritance diagram for CartoType::TDataInputStream:
CartoType::TDataStream

Public Member Functions

 TDataInputStream (MInputStream &aInputStream)
 
void Set (MInputStream &aInputStream)
 
void Seek (int64_t aPosition)
 
int64_t Position () const
 
bool EndOfData () const
 
uint8_t ReadUint8 ()
 
uint16_t ReadUint16 ()
 
uint32_t ReadUint32 ()
 
uint16_t ReadUint16BigEndian ()
 
uint32_t ReadUint32BigEndian ()
 
uint64_t ReadUint40BigEndian ()
 
virtual int64_t ReadFilePos ()
 
virtual int64_t ReadFilePosWithDegreeSquare ()
 
virtual int32_t FilePosBytes () const
 
uint32_t ReadUintOfSize (int32_t aSize)
 
uint64_t ReadUint ()
 
int64_t ReadInt ()
 
uint32_t ReadUintMax32 ()
 
int32_t ReadIntMax32 ()
 
float ReadFloatFP ()
 
double ReadDoubleFP ()
 
int32_t ReadFloatRounded ()
 
int32_t ReadDoubleRounded ()
 
void ReadLine (uint8_t *aBuffer, size_t aMaxBytes, size_t &aActualBytes)
 
void ReadNullTerminatedBytes (const uint8_t *&aBuffer, size_t &aLength, bool &aNullFound)
 
void ReadBytes (uint8_t *aBuffer, size_t aMaxBytes, size_t &aActualBytes)
 
CString ReadNullTerminatedString ()
 
CString ReadUtf8StringWithLength ()
 
CString ReadString (size_t *aBytesRead=0)
 
std::string ReadUtf8StringToStdString ()
 
CString ReadUtf8String (size_t *aBytesRead=0)
 
CString ReadUtf16String (size_t *aBytesRead=0)
 
void Skip (int64_t aBytes)
 
const uint8_t * Read (size_t aBytes)
 
- Public Member Functions inherited from CartoType::TDataStream
TStreamEncoding Encoding () const
 
void SetEncoding (TStreamEncoding aEncoding)
 
TStreamEndianness Endianness () const
 
void SetEndianness (TStreamEndianness aEndianness)
 

Protected Member Functions

uint64_t ReadUint48BigEndian ()
 
uint64_t ReadUint56BigEndian ()
 

Additional Inherited Members

- Protected Attributes inherited from CartoType::TDataStream
TStreamEncoding iEncoding
 
TStreamEndianness iEndianness
 

Detailed Description

A data input stream. It reads integers, strings and blocks of data from a data source provided by a class derived from MInputStream.

Constructor & Destructor Documentation

◆ TDataInputStream()

CartoType::TDataInputStream::TDataInputStream ( MInputStream aInputStream)
inline

Construct a data input stream, specifying the data source.

Member Function Documentation

◆ EndOfData()

bool CartoType::TDataInputStream::EndOfData ( ) const
inline

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

◆ FilePosBytes()

virtual int32_t CartoType::TDataInputStream::FilePosBytes ( ) const
inlinevirtual

A virtual function to return the number of bytes storing a file position. The base class returns 4.

◆ Position()

int64_t CartoType::TDataInputStream::Position ( ) const
inline

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

◆ Read()

const uint8_t * CartoType::TDataInputStream::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 CartoType::TDataInputStream::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.

◆ ReadDoubleFP()

double CartoType::TDataInputStream::ReadDoubleFP ( )

Reads an IEEE double precision floating point number.

◆ ReadDoubleRounded()

int32_t CartoType::TDataInputStream::ReadDoubleRounded ( )

Reads an IEEE double precision float and rounds it to a 4 byte integer.

◆ ReadFilePos()

virtual int64_t CartoType::TDataInputStream::ReadFilePos ( )
inlinevirtual

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

◆ ReadFilePosWithDegreeSquare()

virtual int64_t CartoType::TDataInputStream::ReadFilePosWithDegreeSquare ( )
inlinevirtual

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

◆ ReadFloatFP()

float CartoType::TDataInputStream::ReadFloatFP ( )

Reads an IEEE single precision floating point number.

◆ ReadFloatRounded()

int32_t CartoType::TDataInputStream::ReadFloatRounded ( )

Reads an IEEE single precision float and rounds it to a 4 byte integer.

◆ ReadInt()

int64_t CartoType::TDataInputStream::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 CartoType::TDataInputStream::ReadIntMax32 ( )

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

◆ ReadLine()

void CartoType::TDataInputStream::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.

◆ ReadNullTerminatedBytes()

void CartoType::TDataInputStream::ReadNullTerminatedBytes ( const uint8_t *&  aBuffer,
size_t &  aLength,
bool &  aNullFound 
)

Read some data into a buffer owned by the underlying input stream. Data is only read up to but not including the first null terminator, and aNullFound will indicate whether a null terminator was actually found. The next read will start after the null terminator.

◆ ReadNullTerminatedString()

CString CartoType::TDataInputStream::ReadNullTerminatedString ( )

Read a null terminated string in the current encoding and endianness from the input stream.

◆ ReadString()

CString CartoType::TDataInputStream::ReadString ( size_t *  aBytesRead = 0)
inline

Reads a string preceded by its length. The length is a single byte for lengths 0...254. Greater lengths are encoded as the byte value 255 followed by a four-byte length. The current encoding and endianness are used. If aBytesRead is non-null the number of bytes read from the stream is returned there.

◆ ReadUint()

uint64_t CartoType::TDataInputStream::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 CartoType::TDataInputStream::ReadUint16 ( )

Reads a 16-bit unsigned integer.

◆ ReadUint16BigEndian()

uint16_t CartoType::TDataInputStream::ReadUint16BigEndian ( )
inline

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

◆ ReadUint32()

uint32_t CartoType::TDataInputStream::ReadUint32 ( )

Reads a 32-bit unsigned integer.

◆ ReadUint32BigEndian()

uint32_t CartoType::TDataInputStream::ReadUint32BigEndian ( )
inline

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

◆ ReadUint40BigEndian()

uint64_t CartoType::TDataInputStream::ReadUint40BigEndian ( )
inline

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

◆ ReadUint48BigEndian()

uint64_t CartoType::TDataInputStream::ReadUint48BigEndian ( )
inlineprotected

Reads an unsigned big-endian 48-bit number.

◆ ReadUint56BigEndian()

uint64_t CartoType::TDataInputStream::ReadUint56BigEndian ( )
inlineprotected

Reads an unsigned big-endian 56-bit number.

◆ ReadUint8()

uint8_t CartoType::TDataInputStream::ReadUint8 ( )
inline

Reads an 8-bit unsigned integer.

◆ ReadUintMax32()

uint32_t CartoType::TDataInputStream::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 CartoType::TDataInputStream::ReadUintOfSize ( int32_t  aSize)

Reads an integer stored in a certain numbr of bytes, which must be 1, 2 or 4.

◆ ReadUtf16String()

CString CartoType::TDataInputStream::ReadUtf16String ( size_t *  aBytesRead = 0)

Read a UTF16 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. The string may be big-endian or little-endian according to the stream's setting.If aBytesRead is non-null the number of bytes read from the stream is returned there.

◆ ReadUtf8String()

CString CartoType::TDataInputStream::ReadUtf8String ( size_t *  aBytesRead = 0)

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.

◆ ReadUtf8StringToStdString()

std::string CartoType::TDataInputStream::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()

CString CartoType::TDataInputStream::ReadUtf8StringWithLength ( )

Reads a string and puts it into aString. 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 CartoType::TDataInputStream::Seek ( int64_t  aPosition)

Move to a specified position in the input stream.

◆ Set()

void CartoType::TDataInputStream::Set ( MInputStream aInputStream)
inline

Sets the data source.

◆ Skip()

void CartoType::TDataInputStream::Skip ( int64_t  aBytes)

Skip forward by a certain number of bytes.


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