LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
ObjC/Class.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 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_OBJC_CLASS_H
16#define LIEF_OBJC_CLASS_H
17
18#include <LIEF/visibility.h>
20
21#include <LIEF/ObjC/IVar.hpp>
23#include <LIEF/ObjC/Method.hpp>
25#include <LIEF/ObjC/DeclOpt.hpp>
26
27#include <memory>
28#include <string>
29
30namespace LIEF {
31namespace objc {
32
33namespace details {
34class Class;
35class ClassIt;
36}
37
40 public:
41 class Iterator final
42 : public iterator_facade_base<Iterator, std::bidirectional_iterator_tag, Class,
43 std::ptrdiff_t, const Class*, const Class&> {
44 public:
45 using implementation = details::ClassIt;
46 using iterator_facade_base::operator++;
47 using iterator_facade_base::operator--;
48
50
51 LIEF_API Iterator(std::unique_ptr<details::ClassIt> impl);
52
55
57 LIEF_API Iterator& operator=(Iterator&&) noexcept;
58
60
61 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
62
63 friend bool operator!=(const Iterator& LHS, const Iterator& RHS) {
64 return !(LHS == RHS);
65 }
66
67 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
69
70 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
72
73 LIEF_API const Class& operator*() const;
74
75 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
76 LIEF_API const Class* operator->() const;
77
80 LIEF_API std::unique_ptr<Class> yield();
81
82 private:
83 void load() const;
84
85 std::unique_ptr<details::ClassIt> impl_;
86 mutable std::unique_ptr<Class> cached_;
87 };
88
89 public:
92
95
98
101
102 Class(std::unique_ptr<details::Class> impl);
103
105 std::string name() const;
106
108 std::string demangled_name() const;
109
116 std::unique_ptr<Class> super_class() const LIEF_LIFETIMEBOUND;
117
120 std::string super_name() const;
121
123 std::string demangled_super_name() const;
124
125 bool is_meta() const;
126
129
132
135
138
142 std::string to_decl(const DeclOpt& opt = DeclOpt()) const;
143
145
146 private:
147 std::unique_ptr<details::Class> impl_;
148};
149
150}
151}
152#endif
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:750
Definition iterators.hpp:603
std::unique_ptr< Class > yield()
Transfer ownership of the class at the current position to the caller. Returns nullptr if the iterato...
const Class * operator->() const
details::ClassIt implementation
Definition ObjC/Class.hpp:45
const Class & operator*() const
Iterator(std::unique_ptr< details::ClassIt > impl)
Iterator(const Iterator &)
Iterator(Iterator &&) noexcept
Iterator & operator=(const Iterator &)
iterator_range< Method::Iterator > methods_t
Iterator for the class's methods.
Definition ObjC/Class.hpp:91
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::string to_decl(const DeclOpt &opt=DeclOpt()) const
Generate a header-like string for this specific class.
std::unique_ptr< Class > super_class() const
Parent class in case of inheritance.
iterator_range< Property::Iterator > properties_t
Iterator for the properties declared by this class.
Definition ObjC/Class.hpp:97
ivars_t ivars() const
Iterator over the different instance variables defined in this class.
std::string demangled_super_name() const
Demangled name of the superclass.
std::string super_name() const
(raw) name of the superclass (empty for root classes or when it could not be resolved).
iterator_range< Protocol::Iterator > protocols_t
Iterator for the protocols implemented by this class.
Definition ObjC/Class.hpp:94
iterator_range< IVar::Iterator > ivars_t
Iterator for the instance variables defined by this class.
Definition ObjC/Class.hpp:100
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.
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition Category.hpp:32
Namespace related to ObjC metadata.
Definition MachO/Binary.hpp:43
LIEF namespace.
Definition Abstract/Binary.hpp:41
This structure wraps options to tweak the generated output of functions like LIEF::objc::Metadata::to...
Definition DeclOpt.hpp:22
#define LIEF_API
Definition visibility.h:45