31 BinaryReader reader(&stream);
38 if (reader.readUInt32LE() != 0x5367674f) {
42 m_streamStructureVersion = reader.readByte();
43 m_headerTypeFlag = reader.readByte();
44 m_absoluteGranulePosition = reader.readUInt64LE();
45 m_streamSerialNumber = reader.readUInt32LE();
46 m_sequenceNumber = reader.readUInt32LE();
47 m_checksum = reader.readUInt32LE();
48 m_segmentCount = reader.readByte();
49 m_segmentSizes.clear();
50 if (m_segmentCount > 0) {
51 if (maxSize < m_segmentCount) {
54 maxSize -= m_segmentCount;
57 m_segmentSizes.emplace_back(0);
58 for (std::uint8_t i = 0; i < m_segmentCount;) {
59 std::uint8_t entry = reader.readByte();
61 m_segmentSizes.back() += entry;
62 if (++i < m_segmentCount && entry < 0xFF) {
63 m_segmentSizes.emplace_back(0);
64 }
else if (i == m_segmentCount && entry == 0xFF) {
65 m_lastSegmentUnconcluded =
true;
82 std::uint32_t crc = 0x0;
84 for (std::uint32_t i = 0, segmentLength = 27; i != segmentLength; ++i) {
88 stream.seekg(4, ios_base::cur);
97 segmentLength += (
segmentTableSize = (value =
static_cast<std::uint8_t
>(stream.get())));
100 value =
static_cast<std::uint8_t
>(stream.get());
103 segmentLength += value;
107 crc = (crc << 8) ^ BinaryReader::crc32Table[((crc >> 24) & 0xFF) ^ value];
void parseHeader(std::istream &stream, std::uint64_t startOffset, std::int32_t maxSize)
Parses the header read from the specified stream at the specified startOffset.
static std::uint32_t makeSegmentSizeDenotation(std::ostream &stream, std::uint32_t size)
Writes the segment size denotation for the specified segment size to the specified stream.
std::uint64_t startOffset() const
Returns the start offset of the page.
static std::uint32_t computeChecksum(std::istream &stream, std::uint64_t startOffset)
Computes the actual checksum of the page read from the specified stream at the specified startOffset.
static void updateChecksum(std::iostream &stream, std::uint64_t startOffset)
Updates the checksum of the page read from the specified stream at the specified startOffset.
std::uint8_t segmentTableSize() const
Returns the size of the segment table.