17 static const std::uint8_t kFcb[3] = {
'f',
'c',
'b'};
18 if (std::memcmp(b.
data() + 0, kFcb, 3) != 0)
20 if (std::memcmp(b.
data() + 4, kFcb, 3) != 0)
31 "invalid index_node_size: " + std::to_string(node_size));
37 const std::uint64_t ns = node_size;
38 std::uint64_t n = num_items;
39 std::uint64_t num_nodes = n;
42 num_nodes =
checked_add(num_nodes, n,
"rtree num_nodes");
50 std::uint16_t index_node_size, std::uint64_t attr_index_size) {
53 "illegal header size: " + std::to_string(header_size));
61 l.
rtree_size = (index_node_size == 0 || features_count == 0)
74 "sections extend past end of file: feature_begin=" + std::to_string(l.
feature_begin) +
75 " total_size=" + std::to_string(total_size));
Every failure the library reports is one of these.
std::size_t size() const noexcept
T * data() const noexcept
std::uint64_t checked_mul(std::uint64_t a, std::uint64_t b, const char *what="mul")
std::uint64_t checked_add(std::uint64_t a, std::uint64_t b, const char *what="add")
std::uint64_t ceil_div(std::uint64_t a, std::uint64_t b)
ceil(a / b) without the (a + b - 1) overflow hazard.
std::uint64_t rtree_index_size(std::uint64_t num_items, std::uint16_t node_size)
Mirrors PackedRTree::index_size (packed_rtree/mod.rs:879-898).
std::uint64_t checked_mul(std::uint64_t a, std::uint64_t b, const char *what="mul")
constexpr std::size_t kNodeItemSize
span< const std::uint8_t > bytes_view
The workhorse alias: a read-only view over bytes.
constexpr std::size_t kHeaderMaxBufferSize
constexpr std::size_t kHeaderSizeSize
FileLayout compute_layout(std::uint32_t header_size, std::uint64_t features_count, std::uint16_t index_node_size, std::uint64_t attr_index_size)
Throws fcb::Error{IllegalHeaderSize} when header_size is out of range or any size arithmetic overflow...
std::uint64_t checked_add(std::uint64_t a, std::uint64_t b, const char *what="add")
constexpr std::uint8_t kVersion
void validate_layout_against_size(const FileLayout &l, std::uint64_t total_size)
Throws unless the computed sections fit inside the resource.
bool check_magic_bytes(bytes_view b)
Mirrors fcb_core::check_magic_bytes (src/rust/fcb_core/src/lib.rs:56-58).
constexpr std::size_t kMagicBytesSize
std::uint64_t ceil_div(std::uint64_t a, std::uint64_t b)
ceil(a / b) without the (a + b - 1) overflow hazard.
Byte offsets of each section.
std::uint64_t rtree_begin
std::uint64_t attr_index_size
std::uint64_t attr_index_begin
std::uint64_t feature_begin