LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
SubCache.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_DSC_SUBCACHE_H
16#define LIEF_DSC_SUBCACHE_H
19#include "LIEF/iterators.hpp"
20#include "LIEF/visibility.h"
21
22#include <memory>
23#include <string>
24
25
26namespace LIEF::dsc {
27class DyldSharedCache;
28
29namespace details {
30class SubCache;
31class SubCacheIt;
32}
33
40 public:
43 : public iterator_facade_base<Iterator, std::random_access_iterator_tag,
44 SubCache, std::ptrdiff_t, const SubCache*,
45 const SubCache&> {
46 public:
47 using implementation = details::SubCacheIt;
48
50
51 Iterator(std::unique_ptr<details::SubCacheIt> impl);
54
55 Iterator(Iterator&&) noexcept;
56 Iterator& operator=(Iterator&&) noexcept;
57
59 bool operator<(const Iterator& rhs) const;
60
61 std::ptrdiff_t operator-(const Iterator& R) const;
62
63 Iterator& operator+=(std::ptrdiff_t n);
64 Iterator& operator-=(std::ptrdiff_t n);
65
66 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
67
68 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
69 return !(LHS == RHS);
70 }
71
73
74 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
75 const SubCache* operator->() const LIEF_LIFETIMEBOUND;
76
79 std::unique_ptr<SubCache> yield();
80
81 private:
82 void load() const;
83
84 std::unique_ptr<details::SubCacheIt> impl_;
85 mutable std::unique_ptr<SubCache> cached_;
86 };
87
88 public:
89 SubCache(std::unique_ptr<details::SubCache> impl);
91
93 sc_uuid_t uuid() const;
94
96 uint64_t vm_offset() const;
97
100 std::string suffix() const;
101
103 std::unique_ptr<const DyldSharedCache> cache() const LIEF_LIFETIMEBOUND;
104
105 friend LIEF_API std::ostream& operator<<(std::ostream& os,
106 const SubCache& subcache);
107
108 private:
109 std::unique_ptr<details::SubCache> impl_;
110};
111
112}
113
114#endif
This class represents a dyld shared cache file.
Definition DyldSharedCache/DyldSharedCache.hpp:41
std::unique_ptr< SubCache > yield()
Transfer ownership of the subcache at the current position to the caller. Returns nullptr if the iter...
details::SubCacheIt implementation
Definition SubCache.hpp:47
const SubCache & operator*() const
Iterator(std::unique_ptr< details::SubCacheIt > impl)
Iterator(const Iterator &)
Iterator(Iterator &&) noexcept
Iterator & operator=(const Iterator &)
std::unique_ptr< const DyldSharedCache > cache() const
The associated DyldSharedCache object for this subcache.
SubCache(std::unique_ptr< details::SubCache > impl)
sc_uuid_t uuid() const
The uuid of the subcache file.
uint64_t vm_offset() const
The offset of this subcache from the main cache base address.
std::string suffix() const
The file name suffix of the subCache file (e.g. .25.data, .03.development).
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DyldSharedCache/DyldSharedCache.hpp:36
Namespace related to the dyld shared cache support.
Definition caching.hpp:21
std::array< uint8_t, 16 > sc_uuid_t
UUID used in different places of the shared cache.
Definition uuid.hpp:25
#define LIEF_API
Definition visibility.h:44