8#ifndef GRIDFORMAT_COMPRESSION_COMMON_HPP_
9#define GRIDFORMAT_COMPRESSION_COMMON_HPP_
15#include <gridformat/common/exceptions.hpp>
16#include <gridformat/common/serialization.hpp>
18namespace GridFormat::Compression {
26template<std::
integral HeaderType = std::
size_t>
28 const HeaderType block_size;
29 const HeaderType residual_block_size;
30 const HeaderType number_of_blocks;
32 Blocks(HeaderType size_in_bytes, HeaderType block_size)
33 : block_size{block_size}
34 , residual_block_size{size_in_bytes%block_size}
35 , number_of_blocks{residual_block_size ? size_in_bytes/block_size + 1 : size_in_bytes/block_size}
40template<std::
integral HeaderType = std::
size_t>
42 const HeaderType block_size;
43 const HeaderType residual_block_size;
44 const HeaderType number_of_blocks;
45 const std::vector<HeaderType> compressed_block_sizes;
48 std::vector<HeaderType>&& comp_block_sizes)
49 : block_size{blocks.block_size}
50 , residual_block_size{blocks.residual_block_size}
51 , number_of_blocks{blocks.number_of_blocks}
52 , compressed_block_sizes{std::move(comp_block_sizes)} {
53 if (compressed_block_sizes.size() != number_of_blocks)
54 throw SizeError(
"Mismatch between blocks and number of compressed blocks");
57 std::size_t compressed_size()
const {
58 return std::accumulate(
59 compressed_block_sizes.begin(),
60 compressed_block_sizes.end(),
constexpr std::size_t default_block_size
as in VTK (https://gitlab.kitware.com/vtk/vtk/-/blob/65fc526a83ac829628a9462f61fa57f1801e2c7e/IO/XML/...
Definition: common.hpp:23