libassetmap  1.0.0
Hash-table based archive format containing compressed data
MemMappedBucket.h
1 #ifndef LIBASSETMAP_MEMMAPPEDBUCKET_H
2 #define LIBASSETMAP_MEMMAPPEDBUCKET_H
3 
4 #include <cstdint>
5 
6 #include "MemMappedBucketEntry.h"
7 #include "MemOps.h"
8 
9 namespace AssetMap {
11  uint8_t* data;
13  ICompress* comp = nullptr;
14  IDecompress* decomp = nullptr;
15 
16  class Iterator {
18 
19  public:
20  using difference_type = ptrdiff_t;
21  using value_type = MemMappedBucketEntry;
22  using pointer = MemMappedBucketEntry*;
23  using reference = MemMappedBucketEntry&;
24  using iterator_category = std::forward_iterator_tag;
25 
26  explicit Iterator(MemMappedBucketEntry&& entry);
27 
28  MemMappedBucketEntry& operator*() noexcept;
29 
30  MemMappedBucketEntry& operator->() noexcept;
31 
32  Iterator& operator++() noexcept;
33 
34  bool operator==(const Iterator& rhs) const noexcept;
35 
36  bool operator!=(const Iterator& rhs) const noexcept;
37  };
38 
39  public:
50  uint8_t* bucketsTbl,
51  lam_size_t id,
52  IDecompress& decomp) noexcept;
53 
62  uint8_t* bucketsTbl,
63  ptrdiff_t offset,
64  lam_size_t bucketId,
65  ICompress& comp) noexcept;
66 
69  [[nodiscard]] MemMappedBucketEntry Append() noexcept;
70 
78  [[nodiscard]] MemMappedBucketEntry operator[](std::string_view name) const;
79 
82  [[nodiscard]] Iterator begin() const noexcept;
83 
86  [[nodiscard]] Iterator end() const noexcept;
87  };
88 } // namespace AssetMap
89 #endif // LIBASSETMAP_MEMMAPPEDBUCKET_H
AssetMap::IDecompress
Definition: IDecompress.h:10
AssetMap::ICompress
Definition: ICompress.h:10
AssetMap::MemMappedBucket::MemMappedBucket
MemMappedBucket(uint8_t *begin, uint8_t *bucketsTbl, ptrdiff_t offset, lam_size_t bucketId, ICompress &comp) noexcept
Initialises an empty bucket at the given location.
AssetMap::MemMappedBucket
Definition: MemMappedBucket.h:10
AssetMap::MemMappedBucket::Append
MemMappedBucketEntry Append() noexcept
Returns an empty entry instance intended to be populated.
AssetMap::MemMappedBucketEntry
Definition: MemMappedBucketEntry.h:15
AssetMap::MemMappedBucket::end
Iterator end() const noexcept
Returns an iterator to one-past-the-end as for C++ iterators.
AssetMap::MemMappedBucket::begin
Iterator begin() const noexcept
Returns an iterator to the beginning of the bucket.
AssetMap
Definition: DirectoryMetadata.h:65
AssetMap::MemMappedBucket::MemMappedBucket
MemMappedBucket(uint8_t *begin, uint8_t *bucketsTbl, lam_size_t id, IDecompress &decomp) noexcept
Constructs a bucket over existing data.