LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
ObjC/Method.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2024 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_OBJC_METHOD_H
16#define LIEF_OBJC_METHOD_H
17#include <LIEF/visibility.h>
18
19#include <memory>
20#include <string>
21
22namespace LIEF {
23namespace objc {
24
25namespace details {
26class Method;
27class MethodIt;
28}
29
32 public:
34 public:
35 using iterator_category = std::bidirectional_iterator_tag;
36 using value_type = std::unique_ptr<Method>;
37 using difference_type = std::ptrdiff_t;
38 using pointer = Method*;
39 using reference = std::unique_ptr<Method>&;
40 using implementation = details::MethodIt;
41
43 // Inspired from LLVM's iterator_facade_base
44 friend class Iterator;
45 public:
46 pointer operator->() const { return R.get(); }
47
48 private:
49 value_type R;
50
51 template <typename RefT>
52 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
53 };
54
56 Iterator(Iterator&&) noexcept;
57 Iterator(std::unique_ptr<details::MethodIt> impl);
59
60 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
61
62 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
63 return !(LHS == RHS);
64 }
65
68
70 Iterator tmp = *static_cast<Iterator*>(this);
71 --*static_cast<Iterator *>(this);
72 return tmp;
73 }
74
76 Iterator tmp = *static_cast<Iterator*>(this);
77 ++*static_cast<Iterator *>(this);
78 return tmp;
79 }
80
81 std::unique_ptr<Method> operator*() const;
82
84 return static_cast<const Iterator*>(this)->operator*();
85 }
86
87 private:
88 std::unique_ptr<details::MethodIt> impl_;
89 };
90
91 public:
92 Method(std::unique_ptr<details::Method> impl);
93
95 std::string name() const;
96
98 std::string mangled_type() const;
99
101 uintptr_t address() const;
102
104 bool is_instance() const;
105
107 private:
108 std::unique_ptr<details::Method> impl_;
109};
110
111}
112}
113#endif
Definition ObjC/Method.hpp:42
pointer operator->() const
Definition ObjC/Method.hpp:46
Definition ObjC/Method.hpp:33
Iterator(Iterator &&) noexcept
std::ptrdiff_t difference_type
Definition ObjC/Method.hpp:37
Iterator(const Iterator &)
std::unique_ptr< Method > value_type
Definition ObjC/Method.hpp:36
std::unique_ptr< Method > operator*() const
Iterator operator++(int)
Definition ObjC/Method.hpp:75
std::bidirectional_iterator_tag iterator_category
Definition ObjC/Method.hpp:35
details::MethodIt implementation
Definition ObjC/Method.hpp:40
std::unique_ptr< Method > & reference
Definition ObjC/Method.hpp:39
Iterator operator--(int)
Definition ObjC/Method.hpp:69
PointerProxy operator->() const
Definition ObjC/Method.hpp:83
This class represents an Objective-C Method.
Definition ObjC/Method.hpp:31
bool is_instance() const
Whether it's an instance method.
Method(std::unique_ptr< details::Method > impl)
std::string name() const
Name of the method.
std::string mangled_type() const
Prototype of the method in its mangled representation (e.g. @16@0:8)
uintptr_t address() const
Virtual address where this method is implemented in the binary.
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41