LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
ObjC/Class.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_CLASS_H
16#define LIEF_OBJC_CLASS_H
17#include <LIEF/visibility.h>
18#include <LIEF/ObjC/IVar.hpp>
20#include <LIEF/ObjC/Method.hpp>
22
23#include <memory>
24#include <string>
25
26namespace LIEF {
27namespace objc {
28
29namespace details {
30class Class;
31class ClassIt;
32}
33
36 public:
38 public:
39 using iterator_category = std::bidirectional_iterator_tag;
40 using value_type = std::unique_ptr<Class>;
41 using difference_type = std::ptrdiff_t;
42 using pointer = Class*;
43 using reference = std::unique_ptr<Class>&;
44 using implementation = details::ClassIt;
45
47 // Inspired from LLVM's iterator_facade_base
48 friend class Iterator;
49 public:
50 pointer operator->() const { return R.get(); }
51
52 private:
53 value_type R;
54
55 template <typename RefT>
56 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
57 };
58
60 Iterator(Iterator&&) noexcept;
61 Iterator(std::unique_ptr<details::ClassIt> impl);
63
64 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
65
66 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
67 return !(LHS == RHS);
68 }
69
72
74 Iterator tmp = *static_cast<Iterator*>(this);
75 --*static_cast<Iterator *>(this);
76 return tmp;
77 }
78
80 Iterator tmp = *static_cast<Iterator*>(this);
81 ++*static_cast<Iterator *>(this);
82 return tmp;
83 }
84
85 std::unique_ptr<Class> operator*() const;
86
88 return static_cast<const Iterator*>(this)->operator*();
89 }
90
91 private:
92 std::unique_ptr<details::ClassIt> impl_;
93 };
94
95 public:
98
101
104
107
108 Class(std::unique_ptr<details::Class> impl);
109
111 std::string name() const;
112
114 std::string demangled_name() const;
115
117 std::unique_ptr<Class> super_class() const;
118
119 bool is_meta() const;
120
123
126
129
131 ivars_t ivars() const;
132
134 private:
135 std::unique_ptr<details::Class> impl_;
136};
137
138}
139}
140#endif
Definition iterators.hpp:485
Definition ObjC/Class.hpp:46
pointer operator->() const
Definition ObjC/Class.hpp:50
Definition ObjC/Class.hpp:37
std::unique_ptr< Class > operator*() const
details::ClassIt implementation
Definition ObjC/Class.hpp:44
Iterator operator--(int)
Definition ObjC/Class.hpp:73
PointerProxy operator->() const
Definition ObjC/Class.hpp:87
std::unique_ptr< Class > & reference
Definition ObjC/Class.hpp:43
Iterator(const Iterator &)
std::ptrdiff_t difference_type
Definition ObjC/Class.hpp:41
Iterator operator++(int)
Definition ObjC/Class.hpp:79
std::bidirectional_iterator_tag iterator_category
Definition ObjC/Class.hpp:39
Iterator(Iterator &&) noexcept
std::unique_ptr< Class > value_type
Definition ObjC/Class.hpp:40
This class represents an Objective-C class (@interface)
Definition ObjC/Class.hpp:35
bool is_meta() const
std::string name() const
Name of the class.
properties_t properties() const
Iterator over the properties of this class.
Class(std::unique_ptr< details::Class > impl)
std::unique_ptr< Class > super_class() const
Parent class in case of inheritance.
ivars_t ivars() const
Iterator over the different instance variables defined in this class.
methods_t methods() const
Iterator over the different methods defined by this class.
std::string demangled_name() const
Demangled name of the class.
protocols_t protocols() const
Iterator over the different protocols implemented by this class.
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41