CartoType C++ API 8.8-7-gb35e4dc71
for Windows, Linux, Qt and other platforms supporting C++ development
|
#include <cartotype_stream.h>
Public Member Functions | |
virtual | ~InputStream () |
virtual std::unique_ptr< InputStream > | Copy ()=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 () |
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.
|
inlinevirtual |
Virtual destructor.
|
pure virtual |
Creates a copy of the stream.
Implemented in CartoTypeCore::MemoryInputStream, CartoTypeCore::FileInputStream, and CartoTypeCore::SimpleFileInputStream.
|
inline |
Returns true if this stream is at the end of the data.
|
inline |
Returns the number of bytes storing a file position; by default 4. The number is always 4 or 5.
|
inline |
Returns the current position as a byte offset from the start of the stream.
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.
|
inline |
Reads the next aBytes bytes, returning a pointer to them, or return nullptr if fewer than that number of bytes is cached.
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.
double CartoTypeCore::InputStream::ReadDouble | ( | ) |
Reads an IEEE double precision floating point number, big-endian.
double CartoTypeCore::InputStream::ReadDoubleLE | ( | ) |
Reads an IEEE double precision floating point number, little-endian.
|
inline |
Reads a file position: that is, an unsigned integer stored in the number of bytes returned by FilePosBytes.
|
inline |
Reads a file position combined with a degree square code: that is, an unsigned integer stored in two more bytes than FilePosBytes.
float CartoTypeCore::InputStream::ReadFloat | ( | ) |
Reads an IEEE single precision floating point number, big-endian.
float CartoTypeCore::InputStream::ReadFloatLE | ( | ) |
Reads an IEEE single precision floating point number, little-endian.
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.
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.
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.
String CartoTypeCore::InputStream::ReadNullTerminatedString | ( | ) |
Reads a null-terminated UTF-8 string.
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.
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.
uint16_t CartoTypeCore::InputStream::ReadUint16 | ( | ) |
Reads a 16-bit unsigned integer, big-endian.
uint16_t CartoTypeCore::InputStream::ReadUint16LE | ( | ) |
Reads a 16-bit unsigned integer, little-endian.
uint32_t CartoTypeCore::InputStream::ReadUint32 | ( | ) |
Reads a 32-bit unsigned integer, big-endian.
uint32_t CartoTypeCore::InputStream::ReadUint32LE | ( | ) |
Reads a 32-bit unsigned integer, little-endian.
|
inline |
Reads a 40-bit unsigned integer in big-endian form.
|
inline |
Reads an unsigned big-endian 48-bit number.
|
inline |
Reads an unsigned big-endian 56-bit number.
|
inline |
Reads an 8-bit unsigned integer.
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.
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.
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.
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.
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.
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.
void CartoTypeCore::InputStream::Seek | ( | int64_t | aPosition | ) |
Move to a specified position in the input stream.
|
inline |
Sets the number of bytes used to store a file position: must be 4 or 5.
void CartoTypeCore::InputStream::Skip | ( | int64_t | aBytes | ) |
Skip forward by a certain number of bytes.
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.
|
pure virtual |
Returns the number of bytes in the stream.
Implemented in CartoTypeCore::MemoryInputStream, CartoTypeCore::FileInputStreamBase, and CartoTypeCore::SimpleFileInputStream.
|
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.