Coverage Report

Created: 2025-07-23 06:41

/src/sleuthkit/tsk/util/span.hpp
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <cstddef>
4
#include <iterator>
5
#include <stdexcept>
6
#include <type_traits>
7
8
// TODO(JTS): We really should just use gsl::span
9
10
template <typename T>
11
class span {
12
  // TODO(JTS): Finish this to make it useful
13
 public:
14
  using element_type = T;
15
  using index_type = size_t;
16
  using pointer = T*;
17
  using reference = T&;
18
  using value = std::remove_cv_t<T>;
19
20
 protected:
21
  pointer _storage{};
22
  index_type _count{};
23
24
 public:
25
0
  span() = default;
26
  span(std::nullptr_t) noexcept : span() {}
27
28
0
  span(pointer p, index_type n) noexcept : _storage{p}, _count{n} {}
Unexecuted instantiation: span<char>::span(char*, unsigned long)
Unexecuted instantiation: span<unsigned char const>::span(unsigned char const*, unsigned long)
29
30
  template <size_t N>
31
  span(element_type (&arr)[N]) noexcept : span(arr, N) {}
32
33
  span(pointer first, pointer last) noexcept
34
      : span(first, std::distance(first, last)) {}
35
36
0
  index_type count() const noexcept { return _count; }
Unexecuted instantiation: span<char>::count() const
Unexecuted instantiation: span<unsigned char const>::count() const
37
38
0
  bool valid() const noexcept { return _storage != nullptr; }
39
0
  pointer data() const noexcept { return _storage; }
40
};
41
42
struct memory_view : public span<char> {
43
  using span::span;
44
45
  template <typename T>
46
0
  T* as() const {
47
    // if ((size_t) count() < sizeof(T)) {
48
    //  throw std::runtime_error("not enough space");
49
    //}
50
51
0
    return reinterpret_cast<T*>(_storage);
52
0
  }
Unexecuted instantiation: APFSJObjKey* memory_view::as<APFSJObjKey>() const
Unexecuted instantiation: apfs_inode* memory_view::as<apfs_inode>() const
Unexecuted instantiation: apfs_fs.cpp:APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::dir_record_key* memory_view::as<APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::dir_record_key>() const
Unexecuted instantiation: apfs_dir_record* memory_view::as<apfs_dir_record>() const
Unexecuted instantiation: apfs_fs.cpp:APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::file_extent_key* memory_view::as<APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::file_extent_key>() const
Unexecuted instantiation: apfs_file_extent* memory_view::as<apfs_file_extent>() const
Unexecuted instantiation: apfs_fs.cpp:APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::xattr_key* memory_view::as<APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::xattr_key>() const
Unexecuted instantiation: apfs_xattr* memory_view::as<apfs_xattr>() const
Unexecuted instantiation: apfs_fs.cpp:APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::ixattr* memory_view::as<APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::ixattr>() const
Unexecuted instantiation: apfs_fs.cpp:APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::nrattr* memory_view::as<APFSJObject::add_entry(APFSBtreeNodeIterator<APFSJObjBtreeNode>::value_type const&)::nrattr>() const
Unexecuted instantiation: apfs.cpp:APFSFileSystem::snapshots() const::key_type* memory_view::as<APFSFileSystem::snapshots() const::key_type>() const
Unexecuted instantiation: apfs_snap_metadata* memory_view::as<apfs_snap_metadata>() const
Unexecuted instantiation: APFSPhysicalExtentKey* memory_view::as<APFSPhysicalExtentKey>() const
53
};